Changeset 2016 for trunk/Cbc/src


Ignore:
Timestamp:
Mar 10, 2014 5:58:20 PM (6 years ago)
Author:
mlubin
Message:

More C interface work. Move C interface to libCbcSolver so that we can use CbcMain0 and CbcMain1.

Location:
trunk/Cbc/src
Files:
4 edited

Legend:

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

    r1898 r2016  
    232232    model->solver_->OsiClpSolverInterface::setHintParam(OsiDoReducePrint, true, OsiHintTry);
    233233    model->model_     = new CbcModel(solver1);
     234    CbcMain0(*model->model_);
    234235    model->handler_   = NULL;
    235236    model->information_ = NULL;
     
    310311    fflush(stdout);
    311312
    312     if (1) {
    313         solver->loadProblem(numcols, numrows, start, index, value,
    314                             collb, colub, obj, rowlb, rowub);
    315     } else {
    316         solver->loadProblem(0, 0, NULL, NULL, NULL,
    317                             NULL, NULL, NULL, NULL, NULL);
    318     }
     313    solver->loadProblem(numcols, numrows, start, index, value,
     314                        collb, colub, obj, rowlb, rowub);
    319315    if (VERBOSE > 1) printf("%s Finished solver->loadProblem()\n", prefix);
    320316    fflush(stdout);
     
    14791475
    14801476    if (VERBOSE > 0) printf("%s return %i\n", prefix, result);
     1477    return result;
     1478}
     1479COINLIBAPI int COINLINKAGE
     1480Cbc_solve(Cbc_Model * model)
     1481{
     1482    const char prefix[] = "Cbc_C_Interface::Cbc_solve(): ";
     1483    int result = 0;
     1484    const char *argv[] = {"Cbc_C_Interface","-solve", "-quit"};
     1485    try {
     1486       
     1487        CbcMain1(3, argv, *model->model_);
     1488    } catch (CoinError e) {
     1489        printf("%s ERROR: %s::%s, %s\n", prefix,
     1490               e.className().c_str(), e.methodName().c_str(), e.message().c_str());
     1491    }
     1492    result = model->model_->status();
     1493
    14811494    return result;
    14821495}
  • trunk/Cbc/src/Cbc_C_Interface.h

    r1898 r2016  
    400400    Cbc_branchAndBound(Cbc_Model * model)
    401401    ;
     402    /* Solve using CbcMain1. This is the recommended default solve function.
     403    */
     404    COINLIBAPI int COINLINKAGE
     405    Cbc_solve(Cbc_Model * model)
     406    ;
    402407    /** Sets or unsets scaling, 0 -off, 1 equilibrium, 2 geometric, 3, auto, 4 dynamic(later) */
    403408    COINLIBAPI void COINLINKAGE
  • trunk/Cbc/src/Makefile.am

    r2000 r2016  
    1919# List all source files for this library, including headers
    2020libCbc_la_SOURCES = \
    21         Cbc_C_Interface.cpp Cbc_C_Interface.h \
    2221        CbcConfig.h \
    2322        CbcBranchActual.hpp \
     
    9493
    9594libCbcSolver_la_SOURCES = \
     95        Cbc_C_Interface.cpp Cbc_C_Interface.h \
    9696        CbcCbcParam.cpp \
    9797        Cbc_ampl.cpp Cbc_ampl.h \
  • trunk/Cbc/src/Makefile.in

    r2000 r2016  
    9292@DEPENDENCY_LINKING_TRUE@libCbc_la_DEPENDENCIES =  \
    9393@DEPENDENCY_LINKING_TRUE@       $(am__DEPENDENCIES_1)
    94 am_libCbc_la_OBJECTS = Cbc_C_Interface.lo CbcBranchAllDifferent.lo \
    95         CbcBranchCut.lo CbcBranchDecision.lo \
    96         CbcBranchDefaultDecision.lo CbcBranchDynamic.lo \
    97         CbcBranchingObject.lo CbcBranchLotsize.lo \
     94am_libCbc_la_OBJECTS = CbcBranchAllDifferent.lo CbcBranchCut.lo \
     95        CbcBranchDecision.lo CbcBranchDefaultDecision.lo \
     96        CbcBranchDynamic.lo CbcBranchingObject.lo CbcBranchLotsize.lo \
    9897        CbcBranchToFixLots.lo CbcCompareDefault.lo CbcCompareDepth.lo \
    9998        CbcCompareEstimate.lo CbcCompareObjective.lo CbcConsequence.lo \
     
    121120@DEPENDENCY_LINKING_TRUE@libCbcSolver_la_DEPENDENCIES =  \
    122121@DEPENDENCY_LINKING_TRUE@       $(am__DEPENDENCIES_1) libCbc.la
    123 am_libCbcSolver_la_OBJECTS = CbcCbcParam.lo Cbc_ampl.lo CbcLinked.lo \
    124         CbcLinkedUtils.lo unitTestClp.lo CbcSolver.lo \
    125         CbcSolverHeuristics.lo CbcSolverAnalyze.lo CbcMipStartIO.lo \
    126         CbcSolverExpandKnapsack.lo
     122am_libCbcSolver_la_OBJECTS = Cbc_C_Interface.lo CbcCbcParam.lo \
     123        Cbc_ampl.lo CbcLinked.lo CbcLinkedUtils.lo unitTestClp.lo \
     124        CbcSolver.lo CbcSolverHeuristics.lo CbcSolverAnalyze.lo \
     125        CbcMipStartIO.lo CbcSolverExpandKnapsack.lo
    127126libCbcSolver_la_OBJECTS = $(am_libCbcSolver_la_OBJECTS)
    128127@COIN_HAS_CLP_TRUE@am__EXEEXT_1 = cbc$(EXEEXT)
     
    514513# List all source files for this library, including headers
    515514libCbc_la_SOURCES = \
    516         Cbc_C_Interface.cpp Cbc_C_Interface.h \
    517515        CbcConfig.h \
    518516        CbcBranchActual.hpp \
     
    589587
    590588libCbcSolver_la_SOURCES = \
     589        Cbc_C_Interface.cpp Cbc_C_Interface.h \
    591590        CbcCbcParam.cpp \
    592591        Cbc_ampl.cpp Cbc_ampl.h \
Note: See TracChangeset for help on using the changeset viewer.