Changeset 2463


Ignore:
Timestamp:
Jan 1, 2019 5:17:38 PM (7 weeks ago)
Author:
unxusr
Message:

MIPStart with indexes

Location:
trunk/Cbc/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cbc/src/Cbc_C_Interface.cpp

    r2462 r2463  
    11281128}
    11291129
     1130COINLIBAPI void COINLINKAGE
     1131Cbc_setMIPStartI( Cbc_Model * model, int count, const int colIdxs[], const double colValues[] )
     1132{
     1133    CbcModel *cbcModel = model->model_;
     1134    OsiSolverInterface *solver = cbcModel->solver();
     1135
     1136    int charSpace = count;
     1137    for ( int i=0 ; (i<count) ; ++i )
     1138        charSpace += solver->getColName(colIdxs[i]).size();
     1139
     1140    char *allChars = new char[charSpace];
     1141    char *s = allChars;
     1142    char **names = new char*[count];
     1143    for ( int i=0 ; (i<count) ; ++i )
     1144    {
     1145        names[i] = s;
     1146        strcpy(s, solver->getColName(colIdxs[i]).c_str());
     1147        s += solver->getColName(colIdxs[i]).size()+1;
     1148    }
     1149
     1150    cbcModel->setMIPStart( count, (const char **) names, colValues );
     1151
     1152    delete [] names;
     1153    delete [] allChars;
     1154
     1155
     1156}
     1157
    11301158/** Print the solution */
    11311159COINLIBAPI void  COINLINKAGE
  • trunk/Cbc/src/Cbc_C_Interface.h

    r2462 r2463  
    235235    Cbc_setMIPStart( Cbc_Model * model, int count, const char **colNames, const double colValues[] );
    236236
     237
     238    /** @brief Enter initial feasible solution
     239     *
     240     * Enter an initial feasible solution. Only the non-zero main
     241     * binary/integer decision variables need to be informed.
     242     * Auxiliary and/or continuous variables are computed
     243     * automatically. Same as setMIPStart but using variable indexes.
     244     *
     245     * @param model problem object
     246     * @param count number of variables
     247     * @param colIdxs indexes of variables
     248     * @param colValues variable values
     249     *
     250     **/
     251     COINLIBAPI void COINLINKAGE
     252     Cbc_setMIPStartI( Cbc_Model * model, int count, const int colIdxs[], const double colValues[] );
     253
    237254    /** @brief Creates a copy of the current model
    238255     *
Note: See TracChangeset for help on using the changeset viewer.