Ignore:
Timestamp:
May 8, 2014 12:11:17 AM (5 years ago)
Author:
mlubin
Message:

Implement Cbc_setInitialSolution for providing a feasible solution.

File:
1 edited

Legend:

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

    r2026 r2032  
    348348    if (VERBOSE > 0) printf("%s return\n", prefix);
    349349    return;
     350}
     351
     352
     353COINLIBAPI void COINLINKAGE
     354Cbc_setInitialSolution(Cbc_Model *model, const double * sol)
     355{
     356    int n = Cbc_getNumCols(model);
     357    // We need to manually compute the objective here for some reason
     358    const double *objvec = Cbc_getObjCoefficients(model);
     359    double objval = 0;
     360    for (int i = 0; i < n; i++) {
     361        objval += objvec[i]*sol[i];
     362    }
     363    model->model_->setBestSolution(sol, n, objval, true);
    350364}
    351365
Note: See TracChangeset for help on using the changeset viewer.