Page **1** of **3**

### MIP Start with CPLEX from a file

Posted: **Fri May 11, 2018 11:37 am**

by **PeterBe**

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.

### Re: MIP Start with CLEP from a file

Posted: **Fri May 11, 2018 4:16 pm**

by **cladelpino**

### Re: MIP Start with CLEP from a file

Posted: **Fri May 11, 2018 5:15 pm**

by **PeterBe**

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

Code: Select all

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

How can generalise these value assignments with the gdx files?

### Re: MIP Start with CPLEX from a file

Posted: **Fri May 11, 2018 6:47 pm**

by **cladelpino**

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

Posted: **Mon May 14, 2018 4:10 pm**

by **PeterBe**

Thanks for your answer "cladelpino ",

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

### Re: MIP Start with CPLEX from a file

Posted: **Tue May 15, 2018 2:47 am**

by **cladelpino**

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

### Re: MIP Start with CPLEX from a file

Posted: **Tue May 15, 2018 11:50 am**

by **PeterBe**

Thanks for your answer cladelpino,

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:

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);
...
```

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?

### Re: MIP Start with CPLEX from a file

Posted: **Tue May 15, 2018 11:33 pm**

by **cladelpino**

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)

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;
```

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

Best

### Re: MIP Start with CPLEX from a file

Posted: **Tue May 15, 2018 11:43 pm**

by **cladelpino**

Do I have to specifiy every value for each variable (even if it is not a decision variable) to make a solution complete?

This may be the problem.

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

Posted: **Wed May 16, 2018 11:16 am**

by **PeterBe**

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

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_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 me