Originally posted by: Antoine_Mtl
Hi,
Thanks for the answer.
I'm using CPLEX 12.5.
There is the output:
Min 0 and Max -7
! ----------------------------------------------------------------------------
! Minimization problem - 2 variables, 2 constraints
Min 0 and Max -7
! Initial process time : 0.00s (0.00s extraction + 0.00s propagation)
! . Log search space : 52.0 (before), 52.0 (after)
! . Memory usage : 531.8 kB (before), 531.8 kB (after)
! Using sequential search.
! ----------------------------------------------------------------------------
! Best Branches Non-fixed Branch decision
Min 0 and Max 0
* 0 1 0.00s on _itv0
Min 0 and Max 0
! ----------------------------------------------------------------------------
! Search terminated normally, 1 solution found.
! Best objective : 0 (optimal - effective tol. is 0)
! Number of branches : 3
! Number of fails : 2
! Total memory usage : 604.4 kB (563.9 kB CP Optimizer + 40.6 kB Concert)
! Time spent in solve : 0.00s (0.00s engine + 0.00s extraction)
! Search speed (br. / s) : 300.0
! ----------------------------------------------------------------------------
The output is wrong while the branching process haven't started.
The source:
#include <iostream>
#include <ilcp/cp.h>
#include <ilcp/cpext.h>
/*
* Definition of IlcCtrI
*/
class IlcCtrI: public IlcConstraintI{
IlcIntVar _begin;
public:
IlcCtrI(IloCP cp, IlcIntVar begin);
~IlcCtrI();
void post();
void propagate();
};
/*
* Handle for IlcCtrI
*/
IlcConstraint IlcCtr(IloCP cp, IlcIntVar begin){
return (new (cp.getHeap()) IlcCtrI(cp, begin));
}
/*
* Wrapper for IlcCtr => use the constraint in concert (model.add(..))
*/
ILOCPCONSTRAINTWRAPPER1(IloCtr, cp, IloIntVar, begin){
use(cp, begin);
IlcIntVar c_begin(cp.getIntVar(begin));
return (IlcCtr(cp, c_begin));
}
int main() {
// TODO Auto-generated method stub
IloEnv env;
try {
IloModel model(env);
IloIntVar begin(env);
IloIntervalVar tasks(env,5);
model.add(begin == IloStartOf(tasks));
model.add(IloCtr(env, begin));
model.add(IloMinimize(env, begin));
IloCP cp(model);
cp.solve();
cp.end();
model.end();
} catch(IloException& e){
env.out() << " ERROR: " << e << "\n";
}
env.end();
}
/*
* Definition IlcCtrI's methods
*/
IlcCtrI::IlcCtrI(IloCP cp, IlcIntVar begin):
IlcConstraintI(cp),
_begin(begin) {}
IlcCtrI::~IlcCtrI() {}
void IlcCtrI::propagate() {
//update bounds
int beginLB(_begin.getMin());
int beginUB(_begin.getMax());
std::cout << "Min " << beginLB << " and Max " << beginUB << std::endl;
}
void IlcCtrI::post(){
_begin.whenDomain(this);
}
#CPOptimizer#DecisionOptimization