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 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:

price(t) price
$LOAD price"

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:

binary variable x(t, household)

So I have to set for instance

x(1,1).L =0; x(2,1) =1; x(3,1) = 0 ...

How can generalise these value assignments with the gdx files?

I tried it and in the log there is the following information:

Reading 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.
…

Does this mean that the solution that I specified is infeasible. Because when CPLEX starts with the interation the number of solutions is 0

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 ?

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.

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?

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)

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;

What do you get if you try something like this for your “feasible” solution ? How did you obtain it ?

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.

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

Reading 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

I do not understand why a boolean value is expected. In the documentation of GAMS for mipstart https://www.gams.com/latest/docs/S_CPLEX.html#CPLEXmipstart 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 me

Hmm, we are now in the realm of official help, your question is valid. My guess is that this option was fully implemented in the newer GAMS versions. I will expect an answer with you

As already mentioned by Claudio, you might want to test whether your provided initial values actually allow for a feasible solution. An easy way to test that is to fix the variables instead of just setting the levels:

Even if it turns out that x_Initial and y_Initial allow a feasible solution in general, there is still no guarantee that CPLEX accepts them as a MIP starting point. As you already mentioned, you provide only the levels for some of the variables. Hence, this is at best a partial solution. CPLEX spends limited resources on constructing a full solution for the entire problem but if it fails to find one quickly, Cplex might reject your MIP start.

Currently, there is no way to provide multiple MIP starts to CPLEX via GAMS. If you think, being able to provide multiple MIP starts would be a significant benefit for you model, could you please provide the following to support@gams.com?

no, I do not think that multiple solutions would change the performance significantly. I justed wanted to know if that is possible or not. Anyways, thanks for your help

it’s me again having a question regarding a MIP start (sorry to bother you with my questions but I do not have that much experience with GAMS and I have no one to ask except this forum; I am really thankful for your help and appreciate it).

I have a solution which I think is feasible. To check the solution I entered - as suggested by Fred - the following lines:

x and y are binary variables. However I get an error message: “Infeasible column ‘temperature_level_bufferTank(4.household_4)’.”

The problem is that the violation of this contrain is not understandable for me if you have a look at the variables x and y. In the results file you see that there are no values for all equations (except the equation for the objective function) and there are no entries for the variable except the variable that causes the infeasibility (according to CPLEX) “temperature_level_bufferTank”. But for this variable only the inital value is correct (at 30) and then all other values are 0 which cannot be the case according to x and y. I use an updating equation for temperature_level_bufferTank which looks like this:

Unfortunately the values are not updated when fixing x(t, household). Could someone imaging a reason for this problem? The model itself is okay. When not fixing the values of the variable evertything is alright and both the equations and the variables are created and updated. Also the input parameters x_Initial(t, household), and y_Initial(t, household); are read correctly according to the result file.

It seems there is no way to assign a value to variable temperature_level_bufferTank(4.household_4) such that the solution is feasible. That can have many reasons. For example your initial solution may force the level of temperature_level_bufferTank(4.household_4) to be outside the corresponding variable bounds or the values of different variables implied by your start “solution” are inconsistent because some constraints (like temperature_level_bufferTank) cannot be satisfied.

If the infeasible “solution” you get back from CPLEX does not make sense to you (e.g. because infeasibilty was determined at an early stage), you may want to rerun with Cplex option feasopt (https://www.gams.com/latest/docs/S_CPLEX.html#CPLEXfeasopt). That way you should get a minimum-cost relaxation to make an infeasible model feasible and the infeasibilities should be reported in the lst file.

So this solution is feasible and GAMS also accepts this solution. However when I want to do a MIP start with this solution I get the (previously mentioned) message from CPLEX:

Processing 1 MIP starts.
MIP start ‘m1’ defined no solution.
Warning: No solution found from 1 MIP starts.

I also tried each of the 6 mipstart levels of the CPLEX option file, but all yield the same result. Can anyone of you think about a reason why this is happening (the solution is doubtlessly feasible)?

So, running with fixed variables finishes in “optimal solution” ? Are you initializing all variables in your problem ?

Well GAMS says that it is an optimal solution (but of course this is not an optimal solution; it is just a feasible solution that I generated using a heuristic approach). And I have not specified the values for all variables; only for my binary variables x(t, household) and y(t, household). Here is what GAMS reports when running the model with the fixed variables:

Best possible: 609212.489503
Absolute gap: 0.000000
Relative gap: 0.000000"

Remember that, because of your GAMS version you don’t have full access to mipstart options.

I’m just rehashing this post by Fred, but you don’t specify if it is a full solution, and if you have updated GAMS in your last one.

It is not a full solution (see explanation above) and meanwhile I am using the latest GAMS and CPLEX version (and the new editor GAMS studio). So I tested every mipstart option of CPLEX. Some of them are supposed to cope with incomplete solution. However I always get the same error message telling me that m1 does not define a solution