Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
Expand all | Collapse all

Warmstart by setStart

  • 1.  Warmstart by setStart

    Posted 10/09/13 07:03 AM

    Originally posted by: VKV7_Anulark_Naber


    I try to give a warmstart to cplex to solve an opl model, using the codes below to fix some binary variables (when I fixed all binary, also the same results). I am quite certain that the warmstart solution is feasible as it comes from a heuristic algorithm, but for some instances the solution is not feasible, giving the following warning:

    Warning:  No solution found from 1 MIP starts.
    Retaining values of one MIP start for possible repair.

    Repair could not get any either.

    I am not sure what cplex does with the warmstart solution. Even if I give all binary variables, the resulting LP should be solved for a feasible solution. I would appreciate any explanations and suggestions if the codes below do contribute to the false result. I also attach "model.mst" containing the warmstart, and the model model.sav.

    //First, set values of AfterStart[IdjeSet], AfterStop[IdjeSet]
        IloIntMap AfterStartValues = opl->getElement("AftStartVal").asIntMap();
        IloIntMap AfterStopValues = opl->getElement("AftStopVal").asIntMap();
        IloTupleSet TupleSet = opl->getElement("IdjeSet").asTupleSet();
        IloTuple Tuple;
        IloInt id0 = 0, id1 = 1;
        for (IloTupleIterator it(TupleSet); it.ok(); ++it) {
            Tuple = *it;
            int j = (int)Tuple.getIntValue(id0);
            int e = (int)Tuple.getIntValue(id1);
            int starte = xxxx;
            int ende = yyyy;;

            if (e >= starte) AfterStartValues.set(Tuple, id1);
            else AfterStartValues.set(Tuple, id0);

            if (e <= ende) AfterStopValues.set (Tuple, id0);
            else AfterStopValues.set (Tuple, id1);
        }

    //Second, attach and setStart to cplex
        IloOplCplexVectors AfterStartVector(env);
        IloOplCplexVectors AfterStopVector(env);
        IloIntVarMap xMap = opl->getElement("AfterStart").asIntVarMap();
        IloIntVarMap yMap = opl->getElement("AfterStop").asIntVarMap();
        AfterStartVector.attach (xMap, AfterStartValues);
        AfterStartVector.setStart(cplex);
        AfterStopVector.attach (yMap, AfterStopValues);
        AfterStopVector.setStart(cplex);

    Thanks in advance.

    Ann


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Warmstart by setStart

    Posted 10/09/13 11:54 AM

    I suggest to use the conflict refiner in the interactive to analyze that. If you give a numeric argument N to the 'conflict' command then the command examines why that MIP start is infeasible. So what you should do is

    CPLEX> read model.sav
    CPLEX> read model.mst
    CPLEX> set conflict display 1
    CPLEX> conflict 1
    CPLEX> display conflict all

    This should show the constraints (in LP format) that conflict with your MIP start. See also the conflict refiner chapter in the user manual.

    Refining the conflict may take a while, so be prepared to wait :-)


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Warmstart by setStart

    Posted 10/09/13 02:49 PM

    Originally posted by: VKV7_Anulark_Naber


    Thank you for the suggestions. I tried, but unfortunately there are more than thousand conflicts. It is rather impractical to check it that way.

    I did fix some important  variables to ones in the opl model itself (although not as many as in cplex setstart), and the solution was feasible. So, I really don't know how to proceed further.

    Another obstracle is how I can map the cplex variable numbers to the opl variables which use tuple indices.

    One more question is if it is possible to fix certain variables using IloIntVarMap and IloIntMap and not the whióle Array as shown in my first post.

    I would appreciate any help.

    Ann


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Warmstart by setStart

    Posted 10/10/13 04:30 AM

    Hm, for me the conflict has only 592 constraints (see the attached file). If that is still too big to analyze I don't know of a general purpose recipe. Ideas that come to mind are:

    1. Fix a subset of the variables in the MIP start for which you know that those fixings are feasible. Then run the conflict refiner on the reduced model/MIP start. Hopefully the conflict will be more expressive.
    2. Use feasopt. Again fix as many variables from the MIP start but make sure that the fixings are still result in a feasible model. Then fix the remaining variables from the MIP start but allow feasopt to relax their bounds. Maybe the relaxations suggested by feasopt will tell you what is wrong with your MIP start.

    As for mapping OPL names to names in an LP/SAV file: You can use an instance of IloOplSettings, call setWithNames(true) and use that setting in your run configuration. This will generate variable names that are similar to the tuple and index names in the OPL model. With this it should be easy to map names. if you have trouble with that look at the opl/examples/opl_interfaces/cpp/src/oplrunsample.cpp example that does exactly that.


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Warmstart by setStart

    Posted 10/10/13 08:26 AM

    Originally posted by: VKV7_Anulark_Naber


    Hi Daniel,

    Thank you very much; your reply was very helpful. I did some homework as you suggested, and now the concrete questions:

    Firstly, I put setWithNames(true), and that reduced lots of frustrations as now the warmstart also speaks the same language as I do.

    1. What I found out is that the following codes do not work for AfterStop variables, but only AfterStart, which are correctly listed in model.mst (see attached):. No AfterStop are listed.

    //Second, attach and setStart to cplex
        IloOplCplexVectors AfterStartVector(env);
        IloOplCplexVectors AfterStopVector(env);
        IloIntVarMap xMap = opl->getElement("AfterStart").asIntVarMap();
        IloIntVarMap yMap = opl->getElement("AfterStop").asIntVarMap();
        AfterStartVector.attach (xMap, AfterStartValues);
        AfterStartVector.setStart(cplex);
        AfterStopVector.attach (yMap, AfterStopValues);
        AfterStopVector.setStart(cplex);

    Are these codes correct? Due to my programming deficiency, please feel free to correct me.

    2. Never mind with the first result, I went ahead and fixed these AfterStart variables to the same values as in model.mst, and explicitly put them in my opl model, which is the same as with opl_interface. The resulting lp model is attached. The starting solution is found feasible, although not optimal. That was a good news. The bad news is that cplex does not consider this starting solution (model.mst) as a fesible solution. I still got this meesage from cplex:

    Warning:  No solution found from 1 MIP starts.
    Retaining values of one MIP start for possible repair.

    Repair heuristic found nothing.  //in the root node

    I also attached cplexmodel.sav for your checking. BTW, I did check individual variables according to the given AfterStart names and exactly the same variables are fixed to certain values.

    i do not know how to go from here, as the initial solution is supposed to be feasible and it would help speed up solving my larger instances. i would appreciate any further help.

    Thanks in advance.

    Ann


    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: Warmstart by setStart

    Posted 10/10/13 05:41 PM

    I did not look at your data but here are two answers anyway:

    1. This code does not look good to me:

    AfterStartVector.attach (xMap, AfterStartValues);
    AfterStartVector.setStart(cplex);
    AfterStopVector.attach (yMap, AfterStopValues);
    AfterStopVector.setStart(cplex);

       If you call setStart() twice then the second call will overwrite what the first one did. I guess what you want to do is

    IloOplCplexVectors start(env);
    start.attach (xMap, AfterStartValues);
    start.attach (yMap, AfterStopValues);
    start.setStart(cplex);

       In order to debug and figure out what MIP starts were in fact used call cplex.writeMIPStarts('file.xml') and then look at the start vector specified in file.xml. Make sure it contains all the variable settings it should have.

    2. The message "Warning:  No solution found from 1 MIP starts." does not necessarily mean that the MIP start is infeasible. If the MIP start does not fix all integer variables then CPLEX has to solve a reduced MIP in order to try to turn the MIP start into a feasible solution. There is a work limit for solving that MIP. If that limit is hit without finding a solution then you may also see this message. Does your MIP start fix all integer variables?


    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: Warmstart by setStart

    Posted 10/11/13 04:17 AM

    Originally posted by: VKV7_Anulark_Naber


    1. I changed my code as you suggested, but the start vector in file.xml (attached) contains only AfterStart. When I attached yMap before xMap, then only AfterStop variables are fixed in file2.xml (attached). It seems that only the first attach works.

    2. In my first Trial, I fixed all binary variables, and still the same warning: " no solution found..." To debug warmstarts, I fixed only 2 sets (AfterStart and AfterStop) of binary variables, but only one set is fixed. The result is as reported in (1).


    #CPLEXOptimizers
    #DecisionOptimization


  • 8.  Re: Warmstart by setStart

    Posted 10/16/13 10:37 AM

    Originally posted by: VKV7_Anulark_Naber


    Hi Daniel,

    have you looked at this problem with IloOplCplexVectors::attach, that it attached only the first call and not subsequent call? See my first post on Oct 11 that has file.xml and file2.xml attached. Is there any fix for that?

    Thanks in advance.

    Anulark


    #CPLEXOptimizers
    #DecisionOptimization


  • 9.  Re: Warmstart by setStart

    Posted 10/17/13 01:35 AM

    Sorry, I had not looked at that yet. It looks like the second attach() will overwrite what the first did. This came unexpected to me.

    Anyway, in order to get both vectors into a MIP start you can setup the MIP start like this (instead of using IloOplVectors::setStart()):

          IloNumVarArray var(env);
          IloNumArray val(env);

          for (IloTupleIterator it(opl.getElement("IdjeSet").asTupleSet()); it.ok(); ++it) {
             IloTuple t = *it;
             var.add(xMap.get(t));
             val.add(AfterStartValues.get(t));
             var.add(yMap.get(t));
             val.add(AfterStopValues.get(t));
          }
          cplex.addMIPStart(var, val);
          var.end();
          val.end();

    This will put everything into a single MIP start.


    #CPLEXOptimizers
    #DecisionOptimization


  • 10.  Re: Warmstart by setStart

    Posted 10/17/13 05:15 AM

    Originally posted by: VKV7_Anulark_Naber


    Thank you very much. This works.


    #CPLEXOptimizers
    #DecisionOptimization


  • 11.  Re: Warmstart by setStart

    Posted 10/10/13 05:56 PM

    Something else you could try: Instead of setting the solution as MIP start do the following: Loop over all variables in xMap and yMap and set their LB and UB properties to the values in the MIP start (that is, fix the variables to the values in the MIP start). Then do the following:

    cplex.setParam(IloCplex::IntSolLim, 1);
    cplex.solve();
    // Reset LB and UB to original values
    ...
    cplex.setParam(IloCplex::IntSolLim, 9223372036800000000);
    cplex.solve();

    The first solve is with the variables fixed to the MIP start (that is what CPLEX would do internally but this time you see the output). The first solve stops as soon as a feasible solution is found. If you never find a feasible solution in that first solve then something is wrong with your MIP start.

    The second solve is just a normal solve. However, CPLEX should automatically use the solution it found in the first solve as a starting point for the second solve. This is sort of a "hand-crafted" MIP start. It has the advantage that you can explicitly see in the log of the first solve what is happening to your MIP start.


    #CPLEXOptimizers
    #DecisionOptimization


  • 12.  Re: Warmstart by setStart

    Posted 10/11/13 08:52 AM

    Originally posted by: VKV7_Anulark_Naber


    I did try to assign bounds to variables. Yes, it worked when I fix variables.

    It also seems to me that the IntSolLim only works after the branch and bound is invoked. Because at the root node, more than one solution are found, but cplex did not stop.

    I still hope that I can elegantly use setStart to give a Warmstart rather than this rather debug method.

    BTW, you mentioned in the other message that there is a limit in working on an MIP start. How can I increase that Limit?

    Thanks in advance.


    #CPLEXOptimizers
    #DecisionOptimization


  • 13.  Re: Warmstart by setStart

    Posted 10/11/13 09:46 AM

    OK, if the MIP start does not work because CPLEX requires too many nodes to solve the submip for the MIP start then you can extend that limit via CPX_PARAM_SUBMIPNODELIM. On the other hand, you say that feasible solutions are found at the root if you fix the MIP start variables? Then the issue is not the submip node limit.

    Did you already change the code so that setStart() is invoked only once? Does this still result in "no solution found from MIP start"?

    That IntSolLim=1 does not work is weird. What version of CPLEX do you use?


    #CPLEXOptimizers
    #DecisionOptimization


  • 14.  Re: Warmstart by setStart

    Posted 10/11/13 10:01 AM

    Originally posted by: VKV7_Anulark_Naber


    setStart was tried - did not work - see my previous reply.

    I am using cplex 12.5.1.

    My question regarding submipnodelim is for my experiment which I have to solve more than 2000 instances with different sizes. In case of large instances in which the mip start cannot be solved within the lmit, it may be worthwhile to let cplex spend more time to find a meaningful start (bound).


    #CPLEXOptimizers
    #DecisionOptimization