Hello everyone!

I have two variables in my MIP modle, x[i][j] ∈ {0,1}, y[i] ∈ R and I use C++ to work with Cplex.

I have obtained the values of the two variables using a heuristic algorithm now, and I want to pass these values to CPLEX as start solution using these values.

I using addMIPStart() method for this. After reading the related problem https://www.or-exchange.org/questions/8191/addmipstart-problem, I learn about some information -- but there still some errors.

My approach is as:

I defined

IloIntArray tstart(env);
IloIntArray2 xstart(env); 
IloIntArray xstartyiwei(env); // Turn 2D xstart to 1D xstartyiwei

and similarly

IIloArray<iloboolvararray> X(env, TotalNode);
IloNumVarArray Xyiwei(env, TotalNodeTotalNode, 0, 1) // Turn 2D X to 1D Xyiwei 
IloIntVarArray t(env, TotalNode, 0, Tteam);

and also defined memory for both of these arrays.

Then I stored the values of x[i][j], y[i] in xstart(env), tstart(env)

Now I am calling addMipStart as follows:

cplex.exportModel("model.lp");
IloNumVarArray startVar(env);
IloNumArray startVal(env);

for (int i = 0; i < TotalNode*TotalNode; i++) {
    startVar.add(Xyiwei[i]);
    startVal.add(xstartyiwei[i]);
}

for (int i = 0; i < TotalNode; i++) {
    startVar.add(t[i]);
    startVal.add(tstart[i]);
}

IloCplex::MIPStartEffort effort = IloCplex::MIPStartEffort::MIPStartAuto;
cplex.addMIPStart(startVar, startVal, effort, "startsolusion.mst");     
cplex.readMIPStarts("startsolusion.mst");
cplex.solve();      
startVal.end();
startVar.end();

When it turns to the statement

cplex.addMIPStart(startVar, startVal, effort, "startsolusion.mst")

it gives me the error Error: IloExtractable 1 IloNumVarI has not been extracted by IloAlgorithm 0000028CD910E0D0.

But if I comment out the follow statement:

for (int i = 0; i < TotalNode*TotalNode; i++) { 
   startVar.add(Xyiwei[i]);
   startVal.add(xstartyiwei[i]);
}

there is no error Error: IloExtractable 1 IloNumVarI has not been extracted by IloAlgorithm 0000028CD910E0D0. However, another error will be when it turns to the statement:

cplex.readMIPStarts("startsolusion.mst");"

Actually, there is not a startsolusion.mst file accur after the ststement

cplex.addMIPStart(startVar, startVal, effort, "startsolusion.mst");

So,I think the last two parameters effort and startsolusion.mst in

cplex.addMIPStart(startVar, startVal, effort, "startsolusion.mst");

are not true.

My English is poor, please bear with me.

I have two questions:

  1. Why when I use cplex.addMIPStart() to pass the 2D variable x[i][j] the error Error: IloExtractable 1 IloNumVarI has not been extracted by IloAlgorithm 0000028CD910E0D0 appears, but it won't appear if there is only pass to the variable y[i]? Is it related to variable type or to variable dimension? I have turned 2D to 1D before.

  2. How to set the last two parameters in the cplex.addMIPStart()? Can the cplex.addMIPStart generate a .mst file through the last parameter?

I am a new learner in this area, and I can find more information about this problems,I will be greatful if you can help me.

This question is marked "community wiki".

asked 16 Apr '18, 23:16

Jun's gravatar image

Jun
111
accept rate: 0%

edited 10 May '18, 15:11

fbahr's gravatar image

fbahr ♦
4.6k716


You have not shown the statements that create the model, so I cannot point to the specific error, but the first thing to check is that Xyiwei[i] appears in either the objective function or at least one constraint for every value of i. Sometimes an index value gets skipped during model construction. The error message means that you are asking CPLEX to accept an initial value for a variable it does not see in the extracted model.

link

answered 17 Apr '18, 11:42

Paul%20Rubin's gravatar image

Paul Rubin ♦♦
14.6k412
accept rate: 19%

Dear professor Paul Rubin, thanks for your answer! You are right that " The error message means that you are asking CPLEX to accept an initial value for a variable it does not see in the extracted model." And I have already corrected the first error. Although there is no syntax error, this statement cplex.addMIPStart() does not work according to the operation result, the initial solution is not passed in cplex. Are there any other considerations in this function cplex.addMIPStart()?

(18 Apr '18, 07:52) Jun

The first thing to do is be sure that the starting solution you are using is actually feasible. Even then, CPLEX might not take it due to rounding/tolerance issues. Take a look at the documentation for IloCplex::MIPStartEffort, an optional argument to addMIPStart(). One of the higher levels might be appropriate in your case.

(18 Apr '18, 13:45) Paul Rubin ♦♦
Your answer
toggle preview

Follow this question

By Email:

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

By RSS:

Answers

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

Tags:

×191

Asked: 16 Apr '18, 23:16

Seen: 304 times

Last updated: 10 May '18, 15:11

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