To use problem
statements here, you would have to rename the variable x and all of the constraints in the second model. But since you just want to assign values from one variable in the first model to some of the variables in the second model, there is an easier way. It uses the fact that the output of AMPL’s display
statement is in the same format as an AMPL data file.
After you solve the first model,
model ronda1.mod;
data data.dat;
solve;
assign the values of the x-variables to a param xval1, and write the output of “display xval1” to a file:
param xval1 {A,D,T};
let {i in A, d in D, t in T} xval1[i,d,t] := x[i,d,t];
display xval1 >xval1.out;
Now reset and read the second model:
reset;
model ronda2.mod;
data data.dat;
At this point, you can read the values from the file back into param xval1, with the following statements:
param xval1 {A,D,T};
data;
param include xval1.out;
model;
An finally, you can fix the variables x[i,d,t,1] to equal xval1[i,d,t], and solve again:
fix {i in A, d in D, t in T} x[i,d,t,1] := xval1[i,d,t];
solve;