Changeset 2870


Ignore:
Timestamp:
Feb 14, 2020 11:55:55 AM (22 months ago)
Author:
unxusr
Message:

C interface: Cbc_solveLinearProgram to solve only LP relaxation

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/Cbc_C_Interface.cpp

    r2866 r2870  
    14891489static void Cbc_addMS( Cbc_Model *model );
    14901490
    1491 
    14921491COINLIBAPI int COINLINKAGE
    1493 Cbc_solve(Cbc_Model *model)
     1492Cbc_solveLinearProgram(Cbc_Model *model)
    14941493{
    14951494  CoinMessages generalMessages = model->solver_->getModelPtr()->messages();
     
    15291528        "Revision Number: %d \n", CBC_SVN_REV);
    15301529#endif
    1531       //printf("%s", generalPrint); fflush(stdout);
    1532       //
    15331530      solver->messageHandler()->setPrefix(false);
    15341531      solver->messageHandler()->message(CLP_GENERAL, generalMessages)
     
    15391536  }
    15401537
    1541   if (solver->getNumIntegers() == 0 || model->relax_ == 1) {
    1542     model->lastOptimization = ContinuousOptimization;
    1543 
    1544     if (solver->basisIsAvailable()) {
    1545       solver->resolve();
     1538  model->lastOptimization = ContinuousOptimization;
     1539
     1540  if (solver->basisIsAvailable()) {
     1541    solver->resolve();
     1542    if (solver->isProvenOptimal())
    15461543      return 0;
    1547     } // resolve
    1548   } // solve only lp relaxation
     1544    if (solver->isIterationLimitReached())
     1545      return 1;
     1546    if (solver->isProvenDualInfeasible())
     1547      return 3;
     1548    if (solver->isProvenPrimalInfeasible())
     1549      return 2;
     1550  } // resolve
    15491551
    15501552  /* checking if options should be automatically tuned */
     
    16131615  }
    16141616
    1615 
    16161617  /* for integer or linear optimization starting with LP relaxation */
    16171618  ClpSolve clpOptions;
     
    16721673      }
    16731674  }
    1674 
    16751675 
    16761676  if (model->int_param[INT_PARAM_LOG_LEVEL] > 0)
     
    16851685    sprintf(msg, "Starting solution of the %s using %s\n", phaseName, methodName );
    16861686    printf("%s\n", msg); fflush(stdout);
    1687 
    16881687  }
    16891688
    16901689  model->lastOptimization = ContinuousOptimization;
    16911690  solver->initialSolve();
     1691
     1692  if (solver->isProvenOptimal())
     1693    return 0;
     1694  if (solver->isIterationLimitReached())
     1695    return 1;
     1696  if (solver->isProvenDualInfeasible())
     1697    return 3;
     1698  if (solver->isProvenPrimalInfeasible())
     1699    return 2;
     1700
     1701  return -1;
     1702}
     1703
     1704COINLIBAPI int COINLINKAGE
     1705Cbc_solve(Cbc_Model *model)
     1706{
     1707  CoinMessages generalMessages = model->solver_->getModelPtr()->messages();
     1708
     1709  int res = Cbc_solveLinearProgram(model);
     1710  if (res == 1)
     1711    return 1;
     1712  if (res==2 || res==3)
     1713    return 0;
     1714
     1715  OsiSolverInterface *solver = model->solver_;
    16921716
    16931717  if (solver->isProvenPrimalInfeasible() || solver->isProvenDualInfeasible() ||
  • trunk/src/Cbc_C_Interface.h

    r2851 r2870  
    926926COINLIBAPI int COINLINKAGE
    927927Cbc_solve(Cbc_Model *model);
     928
     929/** @brief Solves only the linear programming relaxation
     930  *
     931  * @param model problem object
     932  * @return execution status
     933  *   0  optimal
     934  *   1  incomplete search (stopped on time, iterations)
     935  *   2  unfeasible
     936  *   3  unbounded
     937  **/
     938COINLIBAPI int COINLINKAGE
     939Cbc_solveLinearProgram(Cbc_Model *model);
     940
     941
    928942/*@}*/
    929943
Note: See TracChangeset for help on using the changeset viewer.