Hi everyone,

I have values as integer array x[i][j], y[i][j], p[i][j][e], u[j].

These values are obtained using a heuristic algorithm now, I want to pass these values to CPLEX as start solution using these values.

I using addMIPStart() method for this.

My approach is as:

  1. I defined

    IloNumVar2DArray Xcplex(env,T), Ycplex(env,T)
    IloNumVar3DArray Pcplex(env,T)
    IloNumVarArray Ucplex(env,K)
    and similarly
    IloNumVar2DArray x_val(env,T), y_val(env,T)
    IloNumVar3DArray p_val(env,T)
    IloNumVarArray u_val(env,K)
    (and also defined memory for both of these arrays).

  2. Then I stored the values of x[i][j], y[i][j], p[i][j][e], u[j]
    in x_val(env), y_val(env), p_val(env), u_val(env) using loops.

  3. Now I am calling addMipStart as follows:

    IloNumVarArray XstartVar(env), YstartVar(env);
    IloNumArray XstartVal(env), YstartVal(env);
    for(int i=0;i<T;i++) {
      for(int j=0;j<W;j++) {
    cplex.addMIPStart(XstartVar, XstartVal); cplex.addMIPStart(YstartVar, YstartVal); XstartVar.end(); XstartVal.end(); YstartVar.end(); YstartVal.end();
    IloNumVarArray PstartVar(env); IloNumArray PstartVal(env); for(int i=0;i<T;i++) {   for(int j=0;j<W;j++) {     for(int e=0;e<=NE;e++) {       PstartVar.add(Pcplex[i][j][e]);       PstartVal.add(P_val[i][j][e]);     }   } }
    cplex.addMIPStart(PstartVar,PstartVal); PstartVar.end(); PstartVal.end();
    IloNumVarArray UstartVar(env); IloNumArray UstartVal(env); for(int j=0;j<Kmax;j++) {   UstartVar.add(ucplex[j]);   UstartVal.add(u_val[j]); }
    cplex.addMIPStart(UstartVar,UstartVal); cplex.addMIPStart(KstartVar,KstartVal);
    UstartVar.end(); UstartVal.end();

But it is giving me error as:

IloExtractable 100 IloNumVarl has not been extracted by iloalgorithm 0047DB0

asked 20 Jun '13, 15:19

mohitapm10's gravatar image

accept rate: 0%

edited 21 Jun '13, 05:47

fbahr's gravatar image

fbahr ♦

Your post is too messy to understand what you've done. But, here is my two cents.

The error "IloExtractable 100 IloNumVarl has not been extracted by by iloalgorithm" means that you've tried to access a variable array that is not initialized yet. Remember that just defining a variable in its environment does not initialize it. To initialize a variable array, you should define its size and variables type besides its environment.

IloNumVarArray xVar(env, nbNodes, 0, 1, ILOINT);

Also, according to your code, you're trying to define a 2D variable array by just defining its environment. You have to define the size of its first dimension as well.

IloNumVar2DArray yVar(env, nbNodes);

for(i = 0; i < nbNodes; i++)

    yVar[i] = IloNumVarArray(env, yVar, 0, 1, ILOINT);

answered 20 Jun '13, 15:33

Ehsan's gravatar image

Ehsan ♦
accept rate: 16%

Sorry for that massy code: But I have already defined 2D array with number rows now also it is giving problem is my addMipStart is correct or not

(20 Jun '13, 16:36) mohitapm10

I think the problem is that you're defining the necessary variables to store the MIP Start values as IloNumVarArray, and not IloNumArray. See the CPLEX documentation for the correct example.

 IloNumVarArray startVar(env);
 IloNumArray startVal(env);
 for (int i = 0; i < m; ++i)
     for (int j = 0; j < n; ++j) {
 cplex.addMIPStart(startVar, startVal);
(20 Jun '13, 17:24) Ehsan ♦

Yeah I modified that but still it is not working for the. for the one problem instance problem was occurred at 3D array. for another it gives problem for one 2D array and 3D array. When I commented out addMipStart() command for these code runs properly can you tell me what may be the problem.

(21 Jun '13, 03:26) mohitapm10

@Ehsan thank you for the answers. I agree.

Let me add that this kind of question can be asked on the CPLEX support forum.

(21 Jun '13, 04:56) jfpuget

@mohitapm10: It's hard to tell. Maybe since you're having problem with different instances, there is an error in dimensions of the data. In other words, perhaps you are trying to pass 2D or #D arrays smaller than the ones you've initialized.

You should also try @jfpuget's suggestion.

(21 Jun '13, 07:07) Ehsan ♦

I assume that Xcplex ... Ucplex are the variables used in your IloModel. I suggest that you assign them names, so that (hopefully) the error message identifies the offending variable with something more helpful than "IloNumVar1".

I'm not sure what happens if you attempt to assign a starting value to a variable that is not actually part of the problem being solved, but I wouldn't be surprised if the error message looked like the one you got. Remember that defining a variable w[i][j][k] does not guarantee that it appears in the extracted IloCplex object; it will only be extracted if it is used in either a constraint or the objective function.

One note unrelated (I think) to the error message: I'm pretty sure you are using addMIPStart incorrectly. It is not cumulative, so by calling it multiple times you are actually trying to create multiple starting solutions. The first starting solution specifies values for the X variables and leaves it to CPLEX to find/guess values for the others. The second starting solution specifies values for the Y variables but leaves the other ones (including the X variables) for CPLEX to figure out, and so on. If you are trying to create one starting solution, cram all the variables into a single IloNumVarArray (and all their values into a single IloNumArray) and call addMIPStart once with those as arguments.


answered 21 Jun '13, 10:51

Paul%20Rubin's gravatar image

Paul Rubin ♦♦
accept rate: 19%

@Paul Rubin , Thanks for such a nice response.

So you are saying that addMIPstart() can only be used once in the program.

Ok, is this a correct code please check.

IloNumVarArray startVar(env);
IloNumArray startVal(env);
for(int i=0;i<T;i++) {
  for(int j=0;j<W;j++) {

for(int i=0;i<T;i++) {
  for(int j=0;j<W;j++) {

for(int i=0;i<T;i++) {
  for(int j=0;j<W;j++) {
    for(int e=0;e<=NE;e++) {

for(int j=0;j<Kmax;j++) {


Is the sequence of these statements (i.e. In which we have to add starting solution).

(21 Jun '13, 12:38) mohitapm10

I concur with Paul answers so far.

i don't see where you call IloCplex::solve(). I would not end startVar and startVal before having solved the model.

(21 Jun '13, 12:57) jfpuget

ok yes thats right and earlier I was ending before calling CPLEX.SOLVE() is my approach is correct for warm start actually this works fine when I commented add values for 3D array can you tell is cplex does not allow to add 3D array or somthing else.

(21 Jun '13, 13:35) mohitapm10

@paul rubin I don't understand what do you mean by giving name to Xcplex...Ucplex so that I would know which variable is giving problem. Please clarify that. I my very new to this please help I need to complete my project.

(21 Jun '13, 13:40) mohitapm10

Your modified code has some typos but is generally correct. You can call addMIPStart more than once in a program, but each call adds a new starting solution (so three calls = three potential starting solutions).

(21 Jun '13, 14:07) Paul Rubin ♦♦

You may know a variable as XCplex[i][j] in your code, but by default CPLEX represents it in the problem (and in any exported LP or MPS files) as something like IloNumVar1, IloNumVar2, ... If you look at the constructors for IloNumVar, you will see versions with an optional final argument "const char * name=0". Specify a string there (such as "XCplex_2_9") and CPLEX will use that string, rather than IloNumVar42, to represent the variable ... and, in particular, that string will display in the error message.

(21 Jun '13, 14:07) Paul Rubin ♦♦

@paul rubin hi I am using addMIPstart only once in the code so it is adding all the arrays to the colex is I am correct or wrong. Please correct me if I am doing somthing wrong

(21 Jun '13, 17:35) mohitapm10
showing 5 of 7 show 2 more comments
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: 20 Jun '13, 15:19

Seen: 3,475 times

Last updated: 16 Apr '18, 10:06

OR-Exchange! Your site for questions, answers, and announcements about operations research.