Esempio n. 1
0
 // domain synchronization between obj&vars (Ilog) and wcsp (ToulBar2)
 void synchronize()
 {
     if (ToulBar2::verbose >= 2)
         cout << "Domain synchronization between IlogSolver and Toulbar2!" << endl;
     for (int i = 0; i < size; i++) {
         if (ToulBar2::verbose >= 2)
             cout << vars[i] << " (" << wcsp->getInf(i) << "," << wcsp->getSup(i) << ")" << endl;
         vars[i].setMin(wcsp->getInf(i));
         vars[i].setMax(wcsp->getSup(i));
         for (int d = wcsp->getInf(i); d <= wcsp->getSup(i); d++) {
             if (wcsp->cannotbe(i, d)) {
                 vars[i].removeValue(d);
             }
         }
         wcsp->increase(i, vars[i].getMin());
         wcsp->decrease(i, vars[i].getMax());
         for (int d = vars[i].getMin(); d <= vars[i].getMax(); d++) {
             if (!vars[i].isInDomain(d)) {
                 wcsp->remove(i, d);
             }
         }
     }
     obj.setMin(wcsp->getLb());
     obj.setMax(wcsp->getUb() - 1);
     wcsp->decreaseUb(obj.getMax() + 1);
     UpperBound = wcsp->getUb();
 }
Esempio n. 2
0
 // check only modifications on the objective variable
 void whenRange()
 {
     checkFailure();
     wcsp->enforceUb(); // fail if lower bound >= upper bound and enforce NC*
     if (obj.getMax() + 1 < wcsp->getUb()) {
         wcsp->decreaseUb(obj.getMax() + 1);
     }
     push(); // global propagation done after local propagation
 }
Esempio n. 3
0
 // global propagation using WCSP propagation queues
 void propagate()
 {
     checkFailure();
     if (synchronized) {
         synchronized.setValue(getSolver(), IlcFalse);
         synchronize();
     }
     if (ToulBar2::verbose >= 2)
         cout << "ILOG: propagate wcsp index " << wcsp->getIndex() << endl;
     wcsp->decreaseUb(obj.getMax() + 1);
     wcsp->propagate();
 }
Esempio n. 4
0
void IlcWeightedCSPI::post()
{
    ToulBar2::setvalue = ::tb2setvalue;
    ToulBar2::removevalue = ::tb2removevalue;
    ToulBar2::setmin = ::tb2setmin;
    ToulBar2::setmax = ::tb2setmax;
    ToulBar2::setminobj = ::tb2setminobj;
    for (int i = 0; i < size; i++) {
        vars[i].whenValue(IlcWeightedCSPWhenValueDemon(getSolver(), this, i));
        vars[i].whenDomain(IlcWeightedCSPWhenDomainDemon(getSolver(), this, i));
    }
    obj.whenRange(IlcWeightedCSPWhenRangeDemon(getSolver(), this));
}
Esempio n. 5
0
 // variable varIndex has been assigned
 void whenValue(const IlcInt varIndex)
 {
     checkFailure();
     if (ToulBar2::verbose >= 2)
         cout << "ILOG: " << vars[varIndex].getName() << " = " << vars[varIndex].getValue() << endl;
     wcsp->assign(varIndex, vars[varIndex].getValue());
     if (unassignedVars->canbe(varIndex)) {
         unassignedVars->erase(varIndex);
         if (unassignedVars->empty()) {
             assert(wcsp->verify());
             obj.setValue(wcsp->getLb());
         }
     }
     push(); // global propagation done after local propagation
 }
Esempio n. 6
0
IlcConstraint IlcWeightedCSP(IlcIntVar objective, IlcIntVarArray variables, const char* filename)
{
    IloSolver solver = objective.getSolver();
    return IlcConstraint(new (solver.getHeap())
            IlcWeightedCSPI(solver, objective, variables, filename));
}
Esempio n. 7
0
IlcInt IlcIntSelectMaxI::select(IlcIntVar var){
    return var.getMax();
}
Esempio n. 8
0
void rulers::print(IlcIntVar var)
{
 if (var.isBound())
	 var.getManager().out() << " " << var.getValue();
 else  var.getManager().out() << " ||";
}