Commit 12332983 authored by David Bommes's avatar David Bommes

added coin CBC optimizer

git-svn-id: http://www.openflipper.org/svnrepo/CoMISo/trunk@275 1355f012-dd97-4b2f-ae87-10fa9f823a57
parent 9e0c9b5e
......@@ -220,6 +220,56 @@ else ()
set (COMISO_DCO_CONFIG_FILE_SETTINGS "#define COMISO_DCO_AVAILABLE 0" )
endif ()
find_package (CBC)
if (CBC_FOUND )
set (COMISO_CBC_CONFIG_FILE_SETTINGS "#define COMISO_CBC_AVAILABLE 1" )
list( APPEND COMISO_INCLUDE_DIRECTORIES ${CBC_INCLUDE_DIRS} )
list( APPEND COMISO_LINK_LIBRARIES ${CBC_LIBRARIES} )
else ()
message (STATUS "CBC not found!")
set (COMISO_CBC_CONFIG_FILE_SETTINGS "#define COMISO_CBC_AVAILABLE 0" )
endif ()
find_package (CLP)
if (CLP_FOUND )
set (COMISO_CLP_CONFIG_FILE_SETTINGS "#define COMISO_CLP_AVAILABLE 1" )
list( APPEND COMISO_INCLUDE_DIRECTORIES ${CLP_INCLUDE_DIRS} )
list( APPEND COMISO_LINK_LIBRARIES ${CLP_LIBRARIES} )
else ()
message (STATUS "CLP not found!")
set (COMISO_CLP_CONFIG_FILE_SETTINGS "#define COMISO_CLP_AVAILABLE 0" )
endif ()
find_package (CGL)
if (CGL_FOUND )
set (COMISO_CGL_CONFIG_FILE_SETTINGS "#define COMISO_CGL_AVAILABLE 1" )
list( APPEND COMISO_INCLUDE_DIRECTORIES ${CGL_INCLUDE_DIRS} )
list( APPEND COMISO_LINK_LIBRARIES ${CGL_LIBRARIES} )
else ()
message (STATUS "CGL not found!")
set (COMISO_CGL_CONFIG_FILE_SETTINGS "#define COMISO_CGL_AVAILABLE 0" )
endif ()
find_package (COINUTILS)
if (COINUTILS_FOUND )
set (COMISO_COINUTILS_CONFIG_FILE_SETTINGS "#define COMISO_COINUTILS_AVAILABLE 1" )
list( APPEND COMISO_INCLUDE_DIRECTORIES ${COINUTILS_INCLUDE_DIRS} )
list( APPEND COMISO_LINK_LIBRARIES ${COINUTILS_LIBRARIES} )
else ()
message (STATUS "COINUTILS not found!")
set (COMISO_COINUTILS_CONFIG_FILE_SETTINGS "#define COMISO_COINUTILS_AVAILABLE 0" )
endif ()
find_package (OSI)
if (OSI_FOUND )
set (COMISO_OSI_CONFIG_FILE_SETTINGS "#define COMISO_OSI_AVAILABLE 1" )
list( APPEND COMISO_INCLUDE_DIRECTORIES ${OSI_INCLUDE_DIRS} )
list( APPEND COMISO_LINK_LIBRARIES ${OSI_LIBRARIES} )
else ()
message (STATUS "OSI not found!")
set (COMISO_OSI_CONFIG_FILE_SETTINGS "#define COMISO_OSI_AVAILABLE 0" )
endif ()
find_package (Taucs)
if (TAUCS_FOUND )
set (COMISO_TAUCS_CONFIG_FILE_SETTINGS "#define COMISO_TAUCS_AVAILABLE 1" )
......
......@@ -21,5 +21,7 @@
@COMISO_CPLEX_CONFIG_FILE_SETTINGS@
@COMISO_EIGEN3_CONFIG_FILE_SETTINGS@
@COMISO_DCO_CONFIG_FILE_SETTINGS@
@COMISO_CBC_CONFIG_FILE_SETTINGS@
@COMISO_CLP_CONFIG_FILE_SETTINGS@
@COMISO_CGL_CONFIG_FILE_SETTINGS@
@COMISO_COINUTILS_CONFIG_FILE_SETTINGS@
......@@ -32,6 +32,7 @@
#include <CoMISo/NSolver/NPDerivativeChecker.hh>
#include <CoMISo/NSolver/CPLEXSolver.hh>
#include <CoMISo/NSolver/GUROBISolver.hh>
#include <CoMISo/NSolver/CBCSolver.hh>
// minimize linear problem E = 8*x + 2*y + 3*z subject to x+y+z >= 2 and z-y >= 1 and x, y, z binary
......@@ -100,6 +101,18 @@ int main(void)
for( int i=0; i<n; ++i)
std::cerr << "x_" << i << " = " << lp.x()[i] << std::endl;
// check if CBC solver available in current configuration
#if( COMISO_CBC_AVAILABLE)
std::cout << "---------- 6) Get CBC and optimize... " << std::endl;
COMISO::CBCSolver cbc_sol;
cbc_sol.solve(&lp, constraints, dc);
#endif
std::cout << "---------- 8) Print solution..." << std::endl;
for( int i=0; i<n; ++i)
std::cerr << "x_" << i << " = " << lp.x()[i] << std::endl;
return 0;
}
......
//=============================================================================
//
// CLASS CBCSolver - IMPLEMENTATION
//
//=============================================================================
//== INCLUDES =================================================================
//== COMPILE-TIME PACKAGE REQUIREMENTS ========================================
#include <CoMISo/Config/config.hh>
#if COMISO_CBC_AVAILABLE
//=============================================================================
#include "CBCSolver.hh"
// For Branch and bound
#include "OsiSolverInterface.hpp"
#include "CbcModel.hpp"
#include "CbcCutGenerator.hpp"
#include "CbcStrategy.hpp"
#include "CbcHeuristicLocal.hpp"
#include "OsiClpSolverInterface.hpp"
// Cuts
#include <CbcModel.hpp>
#include <OsiClpSolverInterface.hpp>
#include "CglGomory.hpp"
#include "CglProbing.hpp"
#include "CglKnapsackCover.hpp"
#include "CglRedSplit.hpp"
#include "CglClique.hpp"
#include "CglFlowCover.hpp"
#include "CglMixedIntegerRounding2.hpp"
// Preprocessing
#include "CglPreProcess.hpp"
// Heuristics
#include "CbcHeuristic.hpp"
#include <stdexcept>
#define CBC_INFINITY COIN_DBL_MAX
//== NAMESPACES ===============================================================
namespace COMISO {
//== IMPLEMENTATION ==========================================================
// These are some "tweaks" for the CbcModel, copied from some sample Cbc code
// I have no idea what any of these do!
void model_tweak(CbcModel& model)
{
CglProbing generator1;
generator1.setUsingObjective(true);
generator1.setMaxPass(1);
generator1.setMaxPassRoot(5);
// Number of unsatisfied variables to look at
generator1.setMaxProbe(10);
generator1.setMaxProbeRoot(1000);
// How far to follow the consequences
generator1.setMaxLook(50);
generator1.setMaxLookRoot(500);
// Only look at rows with fewer than this number of elements
generator1.setMaxElements(200);
generator1.setRowCuts(3);
CglGomory generator2;
// try larger limit
generator2.setLimit(300);
CglKnapsackCover generator3;
CglRedSplit generator4;
// try larger limit
generator4.setLimit(200);
CglClique generator5;
generator5.setStarCliqueReport(false);
generator5.setRowCliqueReport(false);
CglMixedIntegerRounding2 mixedGen;
CglFlowCover flowGen;
// Add in generators
// Experiment with -1 and -99 etc
//model.addCutGenerator(&generator1, -1, "Probing");
model.addCutGenerator(&generator2, -1, "Gomory");
//model.addCutGenerator(&generator3, -1, "Knapsack");
//model.addCutGenerator(&generator4,-1,"RedSplit");
//model.addCutGenerator(&generator5, -1, "Clique");
//model.addCutGenerator(&flowGen, -1, "FlowCover");
//model.addCutGenerator(&mixedGen, -1, "MixedIntegerRounding");
// Say we want timings
int numberGenerators = model.numberCutGenerators();
int iGenerator;
for (iGenerator = 0; iGenerator < numberGenerators; iGenerator++)
{
CbcCutGenerator* generator = model.cutGenerator(iGenerator);
generator->setTiming(true);
}
//auto osiclp = dynamic_cast<OsiClpSolverInterface*>(model.solver());
//// go faster stripes
//if (osiclp)
//{
// // Turn this off if you get problems
// // Used to be automatically set
// osiclp->setSpecialOptions(128);
// if (osiclp->getNumRows() < 300 && osiclp->getNumCols() < 500)
// {
// //osiclp->setupForRepeatedUse(2,0);
// osiclp->setupForRepeatedUse(0, 0);
// }
//}
// Uncommenting this should switch off all CBC messages
// model.messagesPointer()->setDetailMessages(10,10000,NULL);
// Allow rounding heuristic
CbcRounding heuristic1(model);
model.addHeuristic(&heuristic1);
// And local search when new solution found
//CbcHeuristicLocal heuristic2(model);
//model.addHeuristic(&heuristic2);
}
#define P(X) ((X).data())
void solve_impl(
NProblemInterface* _problem,
const std::vector<NConstraintInterface*>& _constraints,
const std::vector<PairIndexVtype>& _discrete_constraints,
const double /*_time_limit*/
)
{
if(!_problem->constant_hessian())
std::cerr << "Warning: CBCSolver received a problem with non-constant hessian!" << std::endl;
if(!_problem->constant_gradient())
std::cerr << "Warning: CBCSolver received a problem with non-constant gradient!" << std::endl;
const int n_rows = _constraints.size(); // Constraints #
const int n_cols = _problem->n_unknowns(); // Unknowns #
// expand the variable types from discrete mtrx array
std::vector<VariableType> var_type(n_cols, Real);
for (size_t i = 0; i < _discrete_constraints.size(); ++i)
var_type[_discrete_constraints[i].first] = _discrete_constraints[i].second;
//----------------------------------------------
// set up constraints
//----------------------------------------------
std::vector<double> x(n_cols, 0.0); // solution
CoinPackedMatrix mtrx(false, 0, 0);// make a row-ordered, empty mtrx
mtrx.setDimensions(0, n_cols);
std::vector<double> row_lb(n_rows, -CBC_INFINITY);
std::vector<double> row_ub(n_rows, CBC_INFINITY);
for (size_t i = 0; i < _constraints.size(); ++i)
{
if(!_constraints[i]->is_linear())
std::cerr << "Warning: constraint " << i << " is non-linear" << std::endl;
NConstraintInterface::SVectorNC gc;
_constraints[i]->eval_gradient(P(x), gc);
// the setup below appears inefficient, the interface is rather restrictive
CoinPackedVector lin_expr;
lin_expr.reserve(gc.size());
for (NConstraintInterface::SVectorNC::InnerIterator v_it(gc); v_it; ++v_it)
lin_expr.insert(v_it.index(), v_it.value());
mtrx.appendRow(lin_expr);
const double b = -_constraints[i]->eval_constraint(P(x));
switch (_constraints[i]->constraint_type())
{
case NConstraintInterface::NC_EQUAL :
row_lb[i] = row_ub[i] = b;
break;
case NConstraintInterface::NC_LESS_EQUAL :
row_ub[i] = b;
break;
case NConstraintInterface::NC_GREATER_EQUAL :
row_lb[i] = b;
break;
}
// TRACE_CBT("Constraint " << i << " is of type " <<
// _constraints[i]->constraint_type() << "; RHS val", b);
}
//----------------------------------------------
// setup energy
//----------------------------------------------
std::vector<double> objective(n_cols);
_problem->eval_gradient(P(x), P(objective));
// TRACE_CBT("Objective linear term", objective);
const double c = _problem->eval_f(P(x));
// ICGB: Where does objective constant term go in CBC?
// MCM: I could not find this either: It is possible that the entire model
// can be translated to accomodate the constant (if != 0). Ask DB!
// DEB_error_if(c > FLT_EPSILON, "Ignoring a non-zero constant objective term: "
// << c);
// TRACE_CBT("Objective constant term", c);
// CBC Problem initialize
OsiClpSolverInterface si;
si.setHintParam(OsiDoReducePrint, true, OsiHintTry);
const std::vector<double> col_lb(n_cols, -CBC_INFINITY);
const std::vector<double> col_ub(n_cols, CBC_INFINITY);
si.loadProblem(mtrx, P(col_lb), P(col_ub), P(objective), P(row_lb), P(row_ub));
// set variables
for (int i = 0; i < n_cols; ++i)
{
switch (var_type[i])
{
case Real:
si.setContinuous(i);
break;
case Integer:
si.setInteger(i);
break;
case Binary :
si.setInteger(i);
si.setColBounds(i, 0.0, 1.0);
break;
}
}
si.initialSolve();
// TODO: make this accessible through the DEB system instead
volatile static bool dump_problem = false; // change on run-time if necessary
if (dump_problem)
si.writeMps("CBC_problem_dump"); //output problem as .MPS
// Pass the OsiSolver with the problem to be solved to CbcModel
CbcModel model(si);
model.solver()->setHintParam(OsiDoReducePrint, true, OsiHintTry);
model.setMaximumSolutions(4);
// TRACE_CBT("CbcModel::getMaximumSolutions()", model.getMaximumSolutions());
//model.setMaximumSeconds(_time_limit);
// TRACE_CBT("CbcModel::getMaximumSeconds()", model.getMaximumSeconds());
model_tweak(model);
model.branchAndBound();
const double* solution = model.bestSolution();
// THROW_OUTCOME_if(solution == nullptr, UNSPECIFIED_CBC_EXCEPTION);
// store if solution available
if(solution != 0)
_problem->store_result(solution);
}
#undef P
void CBCSolver::solve(
NProblemInterface* _problem,
const std::vector<NConstraintInterface*>& _constraints,
const std::vector<PairIndexVtype>& _discrete_constraints,
const double _time_limit
)
{
try
{
solve_impl(_problem, _constraints, _discrete_constraints, _time_limit);
}
catch (CoinError& ce)
{
std::cerr << "CoinError code = " << ce.message() << std::endl;
// THROW_OUTCOME(UNSPECIFIED_CBC_EXCEPTION);
}
}
//=============================================================================
} // namespace COMISO
//=============================================================================
#endif // COMISO_CBC_AVAILABLE
//=============================================================================
//=============================================================================
//
// CLASS CBCSolver
//
//=============================================================================
#ifndef COMISO_CBCSolver_HH
#define COMISO_CBCSolver_HH
//== COMPILE-TIME PACKAGE REQUIREMENTS ========================================
#include <CoMISo/Config/config.hh>
#if COMISO_CBC_AVAILABLE
//== INCLUDES =================================================================
#include <CoMISo/Config/CoMISoDefines.hh>
#include <vector>
#include <string>
#include "NProblemInterface.hh"
#include "NConstraintInterface.hh"
#include "VariableType.hh"
//== FORWARDDECLARATIONS ======================================================
class GRBModel;
class GRBVar;
//== NAMESPACES ===============================================================
namespace COMISO {
//== CLASS DEFINITION =========================================================
/**
Solver interface for Coin-or Cbc.
A more elaborate description follows.
*/
class COMISODLLEXPORT CBCSolver
{
public:
/// Default constructor
CBCSolver() {}
/// Destructor
~CBCSolver() {}
// ********** SOLVE **************** //
//! \throws Outcome
void solve(
NProblemInterface* _problem, // problem instance
const std::vector<NConstraintInterface*>& _constraints, // linear constraints
const std::vector<PairIndexVtype>& _discrete_constraints, // discrete constraints
const double _time_limit = 60); // time limit in seconds
//! \throws Outcome
void solve(
NProblemInterface* _problem, // problem instance
const std::vector<NConstraintInterface*>& _constraints, // linear constraints
const double _time_limit = 60) // time limit in seconds
{
std::vector<PairIndexVtype> dc;
return solve(_problem, _constraints, dc, _time_limit);
}
};
//=============================================================================
} // namespace COMISO
//=============================================================================
#endif // COMISO_CBC_AVAILABLE
//=============================================================================
#endif // COMISO_CBCSolver_HH
//=============================================================================
......@@ -1241,7 +1241,7 @@ add_constraint_to_model( NConstraintInterface* _constraint, std::vector<IloNumVa
NConstraintInterface::SVectorNC::InnerIterator v_it(gc);
for(; v_it; ++v_it)
{
assert(v_it.index() >= 0 && v_it.index() < _vars.size());
assert(v_it.index() >= 0 && v_it.index() < (int)_vars.size());
lin_expr += _vars[v_it.index()]*v_it.value();
}
......@@ -1260,7 +1260,7 @@ add_constraint_to_model( NConstraintInterface* _constraint, std::vector<IloNumVa
BoundConstraint* bnd_ptr = dynamic_cast<BoundConstraint*>(_constraint);
if(bnd_ptr)
{
assert( int(bnd_ptr->idx()) < _vars.size());
assert( int(bnd_ptr->idx()) < (int)_vars.size());
switch(bnd_ptr->constraint_type())
{
......@@ -1277,15 +1277,15 @@ add_constraint_to_model( NConstraintInterface* _constraint, std::vector<IloNumVa
IloExpr soc_lhs(_env);
IloExpr soc_rhs(_env);
assert(cone_ptr->i() >= 0 && cone_ptr->i() <= _vars.size());
assert(cone_ptr->i() >= 0 && cone_ptr->i() <= (int)_vars.size());
soc_rhs= 0.5*cone_ptr->c()*_vars[cone_ptr->i()]*_vars[cone_ptr->i()];
NConstraintInterface::SMatrixNC::iterator q_it = cone_ptr->Q().begin();
for(; q_it != cone_ptr->Q().end(); ++q_it)
{
assert( int(q_it.col()) < _vars.size());
assert( int(q_it.row()) < _vars.size());
assert( int(q_it.col()) < (int)_vars.size());
assert( int(q_it.row()) < (int)_vars.size());
soc_lhs += 0.5*(*q_it)*_vars[q_it.col()]*_vars[q_it.row()];
}
......
......@@ -34,6 +34,30 @@ if( GUROBI_FOUND)
list( APPEND COMISO_LINK_LIBRARIES ${GUROBI_LIBRARY} )
endif()
#find_package(CBC)
if( CBC_FOUND)
list( APPEND COMISO_INCLUDE_DIRECTORIES ${CBC_INCLUDE_DIRS} )
list( APPEND COMISO_LINK_LIBRARIES ${CBC_LIBRARIES} )
endif()
#find_package(CLP)
if( CLP_FOUND)
list( APPEND COMISO_INCLUDE_DIRECTORIES ${CLP_INCLUDE_DIRS} )
list( APPEND COMISO_LINK_LIBRARIES ${CLP_LIBRARIES} )
endif()
#find_package(CGL)
if( CGL_FOUND)
list( APPEND COMISO_INCLUDE_DIRECTORIES ${CGL_INCLUDE_DIRS} )
list( APPEND COMISO_LINK_LIBRARIES ${CGL_LIBRARIES} )
endif()
#find_package(COINUTILS)
if( COINUTILS_FOUND)
list( APPEND COMISO_INCLUDE_DIRECTORIES ${COINUTILS_INCLUDE_DIRS} )
list( APPEND COMISO_LINK_LIBRARIES ${COINUTILS_LIBRARIES} )
endif()
#find_package(ARPACK)
if( ARPACK_FOUND)
list( APPEND COMISO_INCLUDE_DIRECTORIES ${ARPACK_INCLUDE_DIR} )
......
# - Try to find CBC
# Once done this will define
# CBC_FOUND - System has CBC
# CBC_INCLUDE_DIRS - The CBC include directories
# CBC_LIBRARIES - The libraries needed to use CBC
if (CBC_INCLUDE_DIR)
# in cache already
set(CBC_FOUND TRUE)
set(CBC_INCLUDE_DIRS "${CBC_INCLUDE_DIR}" )
set(CBC_LIBRARIES "${CBC_LIBRARY};${CBC_SOLVER_LIBRARY}" )
else (CBC_INCLUDE_DIR)
find_path(CBC_INCLUDE_DIR
NAMES CbcConfig.h
PATHS "$ENV{CBC_DIR}/include/coin"
"/usr/include/coin"
"C:\\libs\\cbc\\include"
)
find_library( CBC_LIBRARY
NAMES Cbc
PATHS "$ENV{CBC_DIR}/lib"
"/usr/lib"
"/usr/lib/coin"
"C:\\libs\\cbc\\lib"
)
find_library( CBC_SOLVER_LIBRARY
NAMES CbcSolver
PATHS "$ENV{CBC_DIR}/lib"
"/usr/lib"
"/usr/lib/coin"
"C:\\libs\\cbc\\lib"
)
set(CBC_INCLUDE_DIRS "${CBC_INCLUDE_DIR}" )
set(CBC_LIBRARIES "${CBC_LIBRARY};${CBC_SOLVER_LIBRARY}" )
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set CBC_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(CBC DEFAULT_MSG
CBC_LIBRARY CBC_SOLVER_LIBRARY CBC_INCLUDE_DIR)
mark_as_advanced(CBC_INCLUDE_DIR CBC_LIBRARY CBC_SOLVER_LIBRARY)
endif(CBC_INCLUDE_DIR)
# - Try to find CGL
# Once done this will define
# CGL_FOUND - System has CGL
# CGL_INCLUDE_DIRS - The CGL include directories
# CGL_LIBRARIES - The libraries needed to use CGL
if (CGL_INCLUDE_DIR)
# in cache already
set(CGL_FOUND TRUE)
set(CGL_INCLUDE_DIRS "${CGL_INCLUDE_DIR}" )
set(CGL_LIBRARIES "${CGL_LIBRARY}" )
else (CGL_INCLUDE_DIR)
find_path(CGL_INCLUDE_DIR
NAMES CglConfig.h
PATHS "$ENV{CGL_DIR}/include/coin"
"$ENV{CBC_DIR}/include/coin"
"/usr/include/coin"
"C:\\libs\\cgl\\include"
"C:\\libs\\cbc\\include"
)
find_library( CGL_LIBRARY
NAMES Cgl
PATHS "$ENV{CGL_DIR}/lib"
"$ENV{CBC_DIR}/lib"
"/usr/lib"
"/usr/lib/coin"
"C:\\libs\\cgl\\lib"
"C:\\libs\\cbc\\lib"
)
set(CGL_INCLUDE_DIRS "${CGL_INCLUDE_DIR}" )
set(CGL_LIBRARIES "${CGL_LIBRARY}" )
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set CGL_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(CGL DEFAULT_MSG
CGL_LIBRARY CGL_INCLUDE_DIR)
mark_as_advanced(CGL_INCLUDE_DIR CGL_LIBRARY)
endif(CGL_INCLUDE_DIR)
# - Try to find CLP
# Once done this will define
# CLP_FOUND - System has CLP
# CLP_INCLUDE_DIRS - The CLP include directories
# CLP_LIBRARIES - The libraries needed to use CLP
if (CLP_INCLUDE_DIR)
# in cache already
set(CLP_FOUND TRUE)
set(CLP_INCLUDE_DIRS "${CLP_INCLUDE_DIR}" )
set(CLP_LIBRARIES "${CLP_LIBRARY}" )
else (CLP_INCLUDE_DIR)
find_path(CLP_INCLUDE_DIR
NAMES ClpConfig.h
PATHS "$ENV{CLP_DIR}/include/coin"
"$ENV{CBC_DIR}/include/coin"
"/usr/include/coin"
"C:\\libs\\clp\\include"
"C:\\libs\\cbc\\include"
)
find_library( CLP_LIBRARY
NAMES Clp
PATHS "$ENV{CLP_DIR}/lib"
"$ENV{CBC_DIR}/lib"
"/usr/lib"
"/usr/lib/coin"
"C:\\libs\\clp\\lib"
"C:\\libs\\cbc\\lib"
)
set(CLP_INCLUDE_DIRS "${CLP_INCLUDE_DIR}" )
set(CLP_LIBRARIES "${CLP_LIBRARY}" )
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set CLP_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(CLP DEFAULT_MSG
CLP_LIBRARY CLP_INCLUDE_DIR)
mark_as_advanced(CLP_INCLUDE_DIR CLP_LIBRARY)
endif(CLP_INCLUDE_DIR)
# - Try to find COINUTILS
# Once done this will define
# COINUTILS_FOUND - System has COINUTILS
# COINUTILS_INCLUDE_DIRS - The COINUTILS include directories
# COINUTILS_LIBRARIES - The libraries needed to use COINUTILS
if (COINUTILS_INCLUDE_DIR)
# in cache already
set(COINUTILS_FOUND TRUE)
set(COINUTILS_INCLUDE_DIRS "${COINUTILS_INCLUDE_DIR}" )
set(COINUTILS_LIBRARIES "${COINUTILS_LIBRARY}" )
else (COINUTILS_INCLUDE_DIR)
find_path(COINUTILS_INCLUDE_DIR
NAMES CoinUtilsConfig.h
PATHS "$ENV{COINUTILS_DIR}/include/coin"
"$ENV{CBC_DIR}/include/coin"
"/usr/include/coin"
"C:\\libs\\coinutils\\include"
"C:\\libs\\cbc\\include"
)
find_library( COINUTILS_LIBRARY
NAMES CoinUtils
PATHS "$ENV{COINUTILS_DIR}/lib"
"$ENV{CBC_DIR}/lib"
"/usr/lib"
"/usr/lib/coin"
"C:\\libs\\coinutils\\lib"
"C:\\libs\\cbc\\lib"
)
set(COINUTILS_INCLUDE_DIRS "${COINUTILS_INCLUDE_DIR}" )
set(COINUTILS_LIBRARIES "${COINUTILS_LIBRARY}" )
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set COINUTILS_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(COINUTILS DEFAULT_MSG
COINUTILS_LIBRARY COINUTILS_INCLUDE_DIR)
mark_as_advanced(COINUTILS_INCLUDE_DIR COINUTILS_LIBRARY)
endif(COINUTILS_INCLUDE_DIR)
# - Try to find OSI
# Once done this will define
# OSI_FOUND - System has OSI
# OSI_INCLUDE_DIRS - The OSI include directories
# OSI_LIBRARIES - The libraries needed to use OSI
if (OSI_INCLUDE_DIR)
# in cache already
set(OSI_FOUND TRUE)
set(OSI_INCLUDE_DIRS "${OSI_INCLUDE_DIR}" )
set(OSI_LIBRARIES "${OSI_LIBRARY};${OSI_CBC_LIBRARY};${OSI_CLP_LIBRARY}" )
else (OSI_INCLUDE_DIR)
find_path(OSI_INCLUDE_DIR
NAMES OsiConfig.h
PATHS "$ENV{OSI_DIR}/include/coin"
"$ENV{CBC_DIR}/include/coin"