0

I want to solve the MILP problem with CPLEX-C#. The size of my problem is large and in order to improve the CPU time I want to use initial solution. I want to add this solution into cplex and start to solve the problem with this given initial solution. I used the following code:

     try
        {
            startvar = new INumVar[numberOfAllNode * numberOfAllNode];
            startval = new double[numberOfAllNode * numberOfAllNode];

            for (int i = 0, idx = 0; i < numberOfAllNode; i++)
                for (int j = 0; j < numberOfAllNode; j++)
                {
                    startvar[idx] = X[i][j];
                    startval[idx] = start[i][j];
                    idx++;
                }

            startvar = null;
            startval = null;

            cplex.AddMIPStart(startvar, startval,Cplex.MIPStartEffort.SolveMIP);

        }
    catch (ILOG.Concert.Exception)
        {
            throw;
        }

In this code I have multidimensional array decision variables X[i][j] (binary decision variable) and the values are equal to start[i][j]. The values of the start[i][j] are stored as double [] array as parameter. When I run the code, following errors are appeared:

Warning:  No solution found from 1 MIP starts.

Root node processing (before b&c):
  Real time             =    5.07 sec. (2238.50 ticks)
Parallel b&c, 4 threads:
  Real time             =    0.00 sec. (0.00 ticks)
  Sync time (average)   =    0.00 sec.
  Wait time (average)   =    0.00 sec.
                          ------------
Total (root+branch&cut) =    5.07 sec. (2238.50 ticks)
Couldn't Solve The Problem! 

I have two questions: 1) in which part of the model I have to put this code? ( I mean after the all constraints and adding objective value and calling addMin or addMax or before them?)

2) When I commend out startvar = null; startval = null;I have following error:

An unhandled exception of type 'ILOG.CPLEX.Cplex.UnknownObjectException' occurred in CPLEX.exe

Additional information: CPLEX Error: object is unknown to IloCplex 

I would appreciate if you could help in order to handle this issue.

Hesam E
  • 105
  • 8

1 Answers1

0

Very similar to Error in using addMIPStart() in CPLEX C++ but in C#.

I would normally call the AddMIPStart() at the end of the model building, just before the solve(). That is (for me) the 'natural' place to put the call.

If there are variables in your model that are not mentioned in any constraints or the objective, then when CPLEX extracts the internal model from the Concert expressions etc, it will not include them in its internal model. Then if you try to set a value for those variables, CPLEX won't recognise them. I would check to see that all the variables in your mip start do actually get included somewhere in your constraints or objective.

Community
  • 1
  • 1
TimChippingtonDerrick
  • 2,042
  • 1
  • 12
  • 13
  • Thanks for your reply. My problem has 3 Decision variables (2 binary and 1 continues) in my MIPSTART I give the value only for one of them (X[i][j]). DO I need to put the initial values for the remaining two variables? – Hesam E May 16 '17 at 10:51
  • I don't think you need to provide values for all your variables. The error you reported is what you get if you try to provide a mipstart value for a variable that is not in your model. Also, how can you only have 2 binary and 1 continuous variable - the number of variables in your code should be a square number i.e. numberOfAllNode * numberOfAllNode. How big is numberOfAllNode? – TimChippingtonDerrick May 17 '17 at 13:07