Decision Optimization

 View Only
  • 1.  How to get access to the coefficients in the LP model

    Posted Fri August 26, 2016 08:43 AM

    Originally posted by: GP_Song


    Hi Everyone,

    I am doing branch-and-price with CPLEX using C++ API, currently I am struggling with getting access to the columns already generated. The only way I found is to use IloExpr::LinearIterator.getCoef(), which needs to extract each constraint as expression thus seems not efficient nor convenient. Or the other way is to duplicate all the columns generated into another matrix. I was wondering if there is any function defined for direct accessing the coefficients in the LP model, especially the column-wise built model.

    Thanks in advance! 


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: How to get access to the coefficients in the LP model

    Posted Wed August 31, 2016 02:16 AM

    I'm afraid there is no better way. The Concert API does not have a matrix-oriented view on the model and thus does not offer any means to directly access the problem matrix.
     


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: How to get access to the coefficients in the LP model

    Posted Wed August 31, 2016 05:19 AM

    Originally posted by: GP_Song


    Thanks a lot for your reply, guess I have to duplicate the matrix in a 2D vector. Another question is, whether the newly added variables (coefficient columns as well) in CPLEX will always be appended to the end and their positions (or indices) will not be changed during the solving procedure. Only then, I can make sure the duplicated matrix is exactly the same as that of the CPLEX model.


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: How to get access to the coefficients in the LP model

    Posted Sun September 04, 2016 04:08 AM

    Right now, this assumption is correct.

    However, I feel that it would be safer if you stored the copy of the matrix as a map that maps IloRange/IloNumVar pairs to coefficients (to get the coefficient of a variable in a particular row). This may also allow for faster lookup. Note that each IloExtractable has a unique id, so you can use IloRange::getId() and IloNumVar::getId() as keys in such a map.


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  RE: How to get access to the coefficients in the LP model

    Posted Wed January 05, 2022 01:45 PM

    hi, I now also want to read the coefficient matrix of the model. And I was lucky enough to find your post, but I am confused about 'Or the other way is to duplicate all the columns generated into another matrix.' 
    I wonder if it is convenient for you to provide a piece of C + + code for reference?

    Thanks in advance!



    ------------------------------
    Musheng Li
    ------------------------------



  • 6.  RE: How to get access to the coefficients in the LP model

    Posted Wed January 05, 2022 01:55 PM

    hi, I now also want to read the coefficient matrix of the model. And I was lucky enough to find your post, but I am confused about 'Or the other way is to duplicate all the columns generated into another matrix.' 

    I wonder if it is convenient for you to provide a piece of C + + code for reference?

    Thanks in advance!



    ------------------------------
    Musheng Li
    ------------------------------



  • 7.  RE: How to get access to the coefficients in the LP model

    Posted Wed January 05, 2022 01:58 PM

    How to get access to the coefficient matrix in a QCQP model that already been built in the C++ API?

    Hi Everyone,

    I am solving a Quadratic Programming Problem with Quadratic Constraints (QCQP) with CPLEX using C++ API. Currently, I am struggling with getting access to the coefficient matrix in a model that has already been built. The objective function of the model is quadratic, and the constraints include Second-order cone programming (SOCP) constraints, Quadratic constraints, and linear constraints.
    And I have the following ideas:
    1) Use IloModel::Iterator to traverse the variables, constraints, and objectives in the model.
    2) Use IloExtractable to judge their types.
    I wonder if this idea is correct, and can anyone provide a piece of C + + code for reference?

    Thanks in advance!



    ------------------------------
    Musheng Li
    ------------------------------