[AMPL 25063] Relaxing Integer Variables/ Parameters

Hello team,

I am trying to solve a problem that includes a set of integer parameters. Is there a way to relax the integer parameter and make it a continuous parameter? May you suggest how I can write that in the script?

For now I have them define such as:

#in the model script I have:
param C_Max:= 6;
param R_Max := 3;

param c integer in 1..C_Max;
param r integer in 1..R_Max;

#in the run script I have:
param value {2..C_Max, 1..R_Max};
param bestobj default -Infinity;
param best_c;
param best_r;
suffix bestbound OUT;

for {cval in 2..C_Max, rval in 1..R_Max} {
   let c := cval;
   let r := rval;

   option gurobi_options 'nonconvex=2 bestbound=1 nodelim=1';
   solve;

   if obj.bestbound > bestobj then {

      option gurobi_options 'nonconvex=2';
      solve;

      if obj > bestobj then {
            display cval, rval, obj;
         let value[cval,rval] := obj;
         let bestobj := obj;
         let best_c := c;
         let best_r := r;
      }
   }
}

display value;

I hope to hear from you soon.

Best regards,
Davids

An AMPL param defines data that are assigned values before solving. When you write

param c integer in 1..C_Max;
param r integer in 1..R_Max;

then AMPL checks that c and r are assigned integer values, and gives an error message if you try to assign them fractional values. If you want fractional values to be accepted for these params, you can drop integer from the above definitions. However, since your loop begins

for {cval in 2..C_Max, rval in 1..R_Max} {
   let c := cval;
   let r := rval;

the values of c and r will always integers in your script.

The concept of relaxing integrality makes a lot more sense for variables (defined in var statements). Relaxing integrality of a variable means that the solver is allowed to give it a fractional value in the optimal solution. Do you want to relax the integrality of some of the integer variables in your model?

Thank you very much for the guidance.

Yes, I would like to relax the integrality of some of the integer variables.

Is it possible two write the variable in the form of:

var c integer in 1…C_Max;

and still execute the loop? If possible, how could we relax it?

or simply as

var r integer {r in 1…R_Max} >= 0; #with r must be integer

Best Regards,
Davids

Is there anyway to change this loop to make it continuous? and can take any non negative number including fractional numbers.

for {cval in 2…C_Max, rval in 1…R_Max} {
let c := cval;
let r := rval;

Thank you so much