2 #ifndef OPENGM_LP_SOLVER_CPLEX_HXX
3 #define OPENGM_LP_SOLVER_CPLEX_HXX
5 #include <ilcplex/ilocplex.h>
27 int numberOfThreads = 0,
28 double cutUp = 1.0e+75,
76 obj_(IloMinimize(env_)),
91 const LpValueType lowerBound = 1.0,
92 const LpValueType upperBound = 1.0
95 x_.add(IloNumVarArray(env_, numVar, lowerBound, upperBound));
98 x_.add(IloNumVarArray(env_, numVar, lowerBound, upperBound, ILOBOOL));
108 const LpValueType lowerBound,
109 const LpValueType upperBound,
110 const std::string & name = std::string()
112 c_.add(IloRange(env_, lowerBound, upperBound));
113 constraintCounter_+=1;
119 const LpValueType coeff
122 c_[constraintIndex].setLinearCoef(x_[lpVarIndex], coeff);
125 template<
class LPVariableIndexIterator,
class CoefficientIterator>
127 LPVariableIndexIterator lpVarBegin,
128 LPVariableIndexIterator lpVarEnd,
129 CoefficientIterator coeffBegin,
130 const LpValueType lowerBound,
131 const LpValueType upperBound,
132 const std::string & name = std::string()
134 c_.add(IloRange(env_, lowerBound, upperBound, name.c_str()));
135 while(lpVarBegin != lpVarEnd) {
137 c_[constraintCounter_].setLinearCoef(x_[*lpVarBegin], *coeffBegin);
144 constraintCounter_+=1;
149 objBuffer_ =
new IloNumArray(env_, numVar_);
155 (*objBuffer_)[lpVi]=obj;
161 obj_.setLinearCoefs(x_, *objBuffer_);
196 cplex_ = IloCplex(model_);
198 catch(IloCplex::Exception& e) {
199 std::cout << e << std::endl;
209 cplex_.setParam(IloCplex::MIPDisplay, 0);
210 cplex_.setParam(IloCplex::SimDisplay, 0);
211 cplex_.setParam(IloCplex::SiftDisplay, 0);
215 cplex_.setParam(IloCplex::EpOpt, 1e-9);
216 cplex_.setParam(IloCplex::EpInt, 0);
217 cplex_.setParam(IloCplex::EpAGap, 0);
218 cplex_.setParam(IloCplex::EpGap, param_.
epGap_);
221 cplex_.setParam(IloCplex::CutUp, param_.
cutUp_);
224 cplex_.setParam(IloCplex::WorkMem, param_.
workMem_);
225 cplex_.setParam(IloCplex::ClockType,2);
227 cplex_.setParam(IloCplex::MemoryEmphasis, 1);
230 cplex_.setParam(IloCplex::TiLim, param_.
timeLimit_);
240 cplex_.setParam(IloCplex::MIRCuts, param_.
MIRCutLevel_);
243 if(!cplex_.solve()) {
246 cplex_.getValues(sol_, x_);
248 catch(IloCplex::Exception e) {
249 std::cout <<
"caught CPLEX exception: " << e << std::endl;
254 LpValueType
lpArg(
const LpIndexType lpVi)
const{
260 return cplex_.getObjValue();
265 return cplex_.getBestObjValue();
273 return constraintCounter_;
287 IloNumArray * objBuffer_;
UInt64Type numbefOfVariables() const
LpValueType lpArg(const LpIndexType lpVi) const
void addConstraint(const LpValueType lowerBound, const LpValueType upperBound, const std::string &name=std::string())
void addConstraint(LPVariableIndexIterator lpVarBegin, LPVariableIndexIterator lpVarEnd, CoefficientIterator coeffBegin, const LpValueType lowerBound, const LpValueType upperBound, const std::string &name=std::string())
void addVariables(const UInt64Type numVar, const LpVarType varType, const LpValueType lowerBound=1.0, const LpValueType upperBound=1.0)
LpValueType bestLpValue() const
int disjunctiverCutLevel_
detail_types::UInt64Type UInt64Type
uint64
LpSolverCplex(const Parameter ¶meter=Parameter())
void setObjective(const UInt64Type lpVi, const LpValueType obj)
Parameter(int numberOfThreads=0, double cutUp=1.0e+75, double epGap=0)
constructor
#define OPENGM_CHECK_OP(A, OP, B, TXT)
UInt64Type numberOfVariables() const
#define OPENGM_CHECK(B, TXT)
LpValueType lpValue() const
void setObjectiveFinished()
void addToConstraint(const UInt64Type constraintIndex, const UInt64Type lpVarIndex, const LpValueType coeff)
UInt64Type numberOfConstraints() const