MIP Start with CPLEX from a file
MIP Start with CPLEX from a file
Hi guys,
I want to use a starting solution for CPLEX. In the CPLEX manual of the GAMS webpage the following is written:
"A MIP start will only be used by GAMS/CPLEX if the MipStart parameter is set to 1. The starting values must be set via the .L variable attribute in the GAMS model before the solve statement."
As I have 10K variables I want to read the values for a MIP Start solution from an Excel or csv file. How can I do that?
Thanks in advance for your help.
I want to use a starting solution for CPLEX. In the CPLEX manual of the GAMS webpage the following is written:
"A MIP start will only be used by GAMS/CPLEX if the MipStart parameter is set to 1. The starting values must be set via the .L variable attribute in the GAMS model before the solve statement."
As I have 10K variables I want to read the values for a MIP Start solution from an Excel or csv file. How can I do that?
Thanks in advance for your help.
Last edited by PeterBe 1 year ago, edited 1 time in total.

 User
 Posts: 108
 Joined: 3 years ago
Re: MIP Start with CLEP from a file
Thanks for the link. I know how parameters are exchanged between Excel and GAMS. For example if I want to load a price from a gdx file I have to write the following code:
But now I do not want to load parameters, I want to transfer feasible solutions to the solver (CPLEX) and I don't understand how I can do that. In the manual it is said that I have to use the ".L variable attribute". I have a binary variable:
So I have to set for instance
How can generalise these value assignments with the gdx files?
Code: Select all
price(t) price
$LOAD price"
Code: Select all
binary variable x(t, household)
Code: Select all
x(1,1).L =0; x(2,1) =1; x(3,1) = 0 ...

 User
 Posts: 108
 Joined: 3 years ago
Re: MIP Start with CPLEX from a file
In the manual it is said that I have to use the ".L variable attribute"
Following this path, you can:
Code: Select all
parameter xInitial(t,household);
binary variable x(t,household);
*I assume there is a proper $gdxin somewhere
$load xInitial
x.L(t,household) = xInitial(t,household);
Re: MIP Start with CPLEX from a file
Thanks for your answer "cladelpino ",
I tried it and in the log there is the following information:
I tried it and in the log there is the following information:
Does this mean that the solution that I specified is infeasible. Because when CPLEX starts with the interation the number of solutions is 0Reading parameter(s) from "C:\Users\wi9632\GAMS\cplex.opt"
>> mipstart=1
...
Reading data...
Starting Cplex...
Space for names approximately 2.77 Mb
Use option 'names no' to turn use of names off
Processing 1 MIP starts.
MIP start 'm1' defined no solution.
Warning: No solution found from 1 MIP starts.
Retaining values of one MIP start for possible repair.
Tried aggregator 2 times.
....

 User
 Posts: 108
 Joined: 3 years ago
Re: MIP Start with CPLEX from a file
I honestly don't know. Looking around also I couldn't find a clear reference for the errors.
On the other hand, it is "easy" to see if a given solution is infeasible. Why don't you figure that out so that you're sure ?
Best and good luck
Claudio
On the other hand, it is "easy" to see if a given solution is infeasible. Why don't you figure that out so that you're sure ?
Best and good luck
Claudio
Re: MIP Start with CPLEX from a file
Thanks for your answer cladelpino,
Nevertheless I will try to come up with a feasible solution
UPDATE: I now used a feasible solution for the input but I still get the same error message. I guess there is an error on the code. As suggested by cladelpino I used the following code:
I only set a value for the two variables x and y, because these are the only decision variables that I have. With regard to the gdx file everything is okay (I checked the file), but somehow I still get an error. I have further variables that are not decision variables whose values I do not read in advance. Maybe this is the error? Do I have to specifiy every value for each variable (even if it is not a decision variable) to make a solution complete?
Basically it is not that easy to test if a solution is feasible because I have around 10000 binary decision variables and about 10000 conditions. Just inserting the variables into these equations would take quite long.On the other hand, it is "easy" to see if a given solution is infeasible. Why don't you figure that out so that you're sure ?
Nevertheless I will try to come up with a feasible solution
UPDATE: I now used a feasible solution for the input but I still get the same error message. I guess there is an error on the code. As suggested by cladelpino I used the following code:
Code: Select all
Parameter
...
x_Initial(t, household)
$LOAD x_Initial
y_Initial(t, household)
$LOAD y_Initial
...
Variables
u objective;
binary ariable x(t, household) ;
binary variable y(t, household) ;
binary variable on(t, household);
x.L(t, household) = x_Initial(t, household);
y.L(t, household) = y_Initial(t, household);
...

 User
 Posts: 108
 Joined: 3 years ago
Re: MIP Start with CPLEX from a file
This is the kind of approach that I am thinking of when I say that to prove if a solution is feasible or not is "easy". It is as hard as writing the fixing of the variables for each variable block you have (and you don't seem to have many blocks, rather many elements within a block)
What do you get if you try something like this for your "feasible" solution ? How did you obtain it ?
Best
Code: Select all
set manyVariables /v1*v10/
set manyEquations /e1*e10/
parameter A;
A(manyEquations,manyVariables)=uniformint(10,10);
variables x(manyVariables),dummy;
equation someEquationsBlock,dummyFObj;
someEquationsBlock(manyEquations).. 0=e=sum(manyVariables,A(manyEquations,manyVariables)*x(manyVariables));
dummyFObj.. 1=e=dummy;
model test /all/;
*just fix all the variables and then solve the model
x.fx(manyVariables)=uniformint(0,10);
solve test using lp maximizing dummy;
Best

 User
 Posts: 108
 Joined: 3 years ago
Re: MIP Start with CPLEX from a file
This may be the problem.Do I have to specifiy every value for each variable (even if it is not a decision variable) to make a solution complete?
From https://www.gams.com/latest/docs/S_CPLE ... EXmipstart , mipstart=1 is set to be "auto" level, for which I cannot find a reference in the CPLEX docu.
The levels for the latest version of CPLEX are described in https://www.ibm.com/support/knowledgece ... 8612714531
Why don't you try setting the level explicitly (since some options do require all variables to be specified). If you only want to provide values for some discrete variables, you can try with 4 or 5 (level 5 can even handle an infeasible solution). If you can provide all discrete, you can also try 3. Let's see what happens.
Re: MIP Start with CPLEX from a file
Thanky for your answer,
I tried different values (1,2,3,4,5) for mipstart in the option file cplex.opt but all (execpt mipstart=1) yield the following errors
I tried different values (1,2,3,4,5) for mipstart in the option file cplex.opt but all (execpt mipstart=1) yield the following errors
I do not understand why a boolean value is expected. In the documentation of GAMS for mipstart https://www.gams.com/latest/docs/S_CPLE ... EXmipstart it is written that mipstart is an integer. But if you have a look at the documentation via the GAMS editor for CPLEX it is written that mipstart is a boolean (also if you create an option file via the GAMS editor the CPLEX variable mipstart is a boolean). This is really confusing meReading parameter(s) from "C:\Users\wi9632\bwSyncAndShare\Graduiertenkolleg\Code\GAMS\Residential Area\cplex.opt"
>> mipstart=5
*** Value Error line 1: Boolean value expected for option "mipstart" saw "5"
*** Value Error line 1: Option ignored