Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  problem with AddMIPStart

    Posted 10/02/09 11:06 PM

    Originally posted by: SystemAdmin


    [elisa said:]

    Hi,
    I'm using Concert Technology to solve problems in CPLEX.
    I'm trying to use AddMipStart CPLEX function in my code.
    I have a bi-dimensional array of variables so defined:

    [b]IloNumVarArray2 var(env,n);
    for(int k=0; k<n; k++)<br />  var[k]=IloNumVarArray(env,n,0,1,ILOINT); [/b]

    and I create a matrix, with the same dimension of var:

    [b]IloNumArray2 SV(env,n)
    [/b]
    that I fill with starting values.

    I tried to use AddMIPStart in this way:

    [b]for(int k=0; k<n; i++)<br />  cplex.AddMIPStart(var[k],SV[k]);[/b]

    the code compiles, but during the execution it crashes with the following message:

    [b]Concert exception caught: The referenced IloExtractable has not been extracted by the IloAlgorithm
    [/b]
    so, after few tests I noticed that, AddMIPStart works in the first iteration, i.e. for:

    [b]cplex.AddMIPStart(var[0],SV[0])[/b]

    and it crashes for all others.
    Any ideas?

    Thanks.

    Elisa
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: problem with AddMIPStart

    Posted 10/03/09 03:49 AM

    Originally posted by: SystemAdmin


    [prubin said:]

    Is this the C++ API?  (It's clearly not Java, but I have no clue about the C# API.) What version of CPLEX is this?  I've never seen an AddMIPStart method -- might be new, or might be C# for all I know.

    The instance cplex on which you invoke this method should have extracted a model (usually in the constructor).  When you are trying to start with SV[1], are you using an instance of IloCplex that extracted a model containing all the variables in var[1] (which are different from the variables in var[0])?

    /Paul

    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: problem with AddMIPStart

    Posted 10/03/09 02:25 PM

    Originally posted by: SystemAdmin


    [elisa said:]

    Hi Paul,
    Thank you for the answer!
    I'm using C++ API, the version of CPLEX is 12.1, but AddMIPStart should exist also in 11.0.

    The instance of cplex that I invoked extract all variables in var, so var[0], var[1] ... until var[n].

    To move around the problem I was thinking to write the matrix var as an array with n[sup]2[/sup] elements, use AddMIPStart on it, and then transform it in a matrix, but I don't know if variables keep information given by AddMIPStart during the "transformation" from array mono-dimensional to bi-dimensional, and further I use this function a lot of times, so this kind of approach is not optimum.

    Elisa
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: problem with AddMIPStart

    Posted 10/03/09 08:33 PM

    Originally posted by: SystemAdmin


    [prubin said:]

    [quote author=elisa link=topic=1399.msg3889#msg3889 date=1254561924]
    I'm using C++ API, the version of CPLEX is 12.1, but AddMIPStart should exist also in 11.0.


    Perhaps, but if so it's undocumented (I can't find it in the 11.0 manuals).

    [quote author=elisa link=topic=1399.msg3889#msg3889 date=1254561924]
    The instance of cplex that I invoked extract all variables in var, so var[0], var[1] ... until var[n].


    ... unless there's a bug in the code somewhere, so that it's not extracting everything you think it's extracting.  For instance, for n=3, var[1] is an array of 3 variables; are all three (var[1][0], var[1][1], var[1][2]) used in the model?

    You might try surrounding the code that extracts and solves the model with a try-catch, catching exceptions of class IloAlgorithm::NotExtractedException.  If e is the exception, then e.getExtractable() should reference whatever it is that CPLEX thinks has not been extracted, and e.getExtractable().getName() should give you it's name (if you named it -- so I would name everything in sight).

    [quote author=elisa link=topic=1399.msg3889#msg3889 date=1254561924]
    To move around the problem I was thinking to write the matrix var as an array with n[sup]2[/sup] elements, use AddMIPStart on it, and then transform it in a matrix, but I don't know if variables keep information given by AddMIPStart during the "transformation" from array mono-dimensional to bi-dimensional, and further I use this function a lot of times, so this kind of approach is not optimum.


    I do not foresee a problem with "vectorizing" the matrix, but I would be surprised if it cured the problem.  I think you need to identify what is not being extracted (if in fact that is what the message means).

    /Paul
    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: problem with AddMIPStart

    Posted 10/03/09 11:06 PM

    Originally posted by: SystemAdmin


    [elisa said:]

    Thank you Paul.
    I try immediately.

    Elisa
    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: problem with AddMIPStart

    Posted 10/05/09 11:32 PM

    Originally posted by: SystemAdmin


    [elisa said:]

    Hi Paul,
    I tried to print on the output the exceptions. This is the message:

    [b]IloExtractable 11 IloNumVarI has not been extracted by IloAlgorithm 00DCAF98
    Not Extracted IloIntVar(11)[0..1][/b]

    The matrix instance is (10 x 10), and then it seems that it isn't extracted the array pointed by var[1]. So, probably there is something wrong in my code. Today, I tried to extract the variables in several different ways, but without success.

    Actually, my code is organized as follows:
    - I define the env and the model:

    [b]IloEnv env;
    IloModel TSPP(env);
    IloCplex cplex(env);[/b]

    the matrix of variables var is defined in this way:

    [b]typedef IloArray<IloNumVarArray> NumVarArray2
    NumVarArray2 var(env,n)
    for(IloInt k=0;k<n;k++){<br />var[k]=IloNumVarArray(env,n,0,1,ILOINT)
    }[/b]

    I define constraints, and I build the model by rows. Then, I extract the model by:

    [b]cplex.extract(TSPP);[/b]

    All variables var are used in the model, and I'm sure that the model is correct because I export it in a lp file. Everything else in the code works correctly if I remove AddMIPStart: cplex solves the model, takes solution values...
    Have you any ideas?

    Elisa
    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: problem with AddMIPStart

    Posted 10/07/09 10:41 PM

    Originally posted by: SystemAdmin


    [prubin said:]

    Without seeing more of the code (specifically the parts surrounding the calls to AddMIPStart), I really can't tell what's going on.  You might need to post more of the code here.

    I'm off to a conference for a week, so I won't be checking the forum for a while.  But perhaps someone else can spot the bug.

    /Paul
    #CPLEXOptimizers
    #DecisionOptimization


  • 8.  Re: problem with AddMIPStart

    Posted 10/27/09 08:55 PM

    Originally posted by: SystemAdmin


    [DanielJunglas said:]

    Elisa,

    have you tried something like this to make extra-sure that all variables are in the model:

          for (int k = 0; k < n; ++k) {<br />        for (int l = 0; l < n; ++l) {<br />            TSPP.add(IloRange(env, var[k][l].getLB(), var[k][l],
                                  var[k][l].getUB()));
            }
          }

    If not, can you give it a try and see if the exception still occurs? I implemented what
    you posted together with the snippet above and everything works fine.
    #CPLEXOptimizers
    #DecisionOptimization


  • 9.  Re: problem with AddMIPStart

    Posted 09/01/16 06:57 AM

    Originally posted by: BabakArh


    Maybe it is too late for that

     

    but I had the same problem.

    seems if u dont add var to constraint it means u nevr extract that var.

    i handle this exception by adding dummy constraint in order to extract.

     

    is it what u did to get rid of this exception?


     


    #CPLEXOptimizers
    #DecisionOptimization


  • 10.  Re: problem with AddMIPStart

    Posted 09/04/16 03:54 AM

    Note that instead of adding a dummy constraint you can also just do model.add(variable), i.e., explicitly add the variable to the model. This should have the same effect but is a little simpler than adding a dummy constraint.


    #CPLEXOptimizers
    #DecisionOptimization


  • 11.  Re: problem with AddMIPStart

    Posted 09/05/16 01:17 AM

    Originally posted by: BabakArh


    Hello.

    thank you for your concern, I knew my way sounded silly and there should be a simple way.

     

    you just solved all my problems. thank you


    #CPLEXOptimizers
    #DecisionOptimization