Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  IloNumExpr into IlcConstraintI

    Posted 06/12/13 07:04 AM

    Originally posted by: mrmag


    Hello!
     
    How ist it possible to pass an objective expression IloNumExpr into IlcConstraintI? The following code throght an exception in the the wrapper ILOCPCONSTRAINTWRAPPER2(MyConstraint):
     
    Concert exception caught: IloExtractable 618 IloNumDivI has not been extracted by IloAlgorithm 00C4D
    728
     
    The code:
     
    class MyConstraintI : public IlcConstraintI {
    protected:
      IlcInt             _n;
      IlcIntVar *        _w;
      IlcFloatExp *      _obj;
     public:
      MyConstraintI(IloCP cp, IlcInt n, IlcIntVar * aa, IlcFloatExp * obj
      ) : IlcConstraintI(cp), _n(n), _w(aa), _obj(obj)
      {
      }
      ~MyConstraintI() {}
      virtual void post();
      virtual void propagate();
      void varDemon();
    };
     
    void MyConstraintI::propagate () {
     
      obj->setMax(...); // set bounds on the objective expressions
    }
     
    IlcConstraint MyConstraint(
      IloCP cp, IlcInt n, IlcIntVar *a, IlcFloatExp * b
    ) {
      return new (cp.getHeap()) MyConstraintI(cp, n, a, b);
    }
     
    ILOCPCONSTRAINTWRAPPER2(MyConstraint, cp,
                            IloIntVarArray, a,
                            IloNumExpr, obj
                            ) {
      for (IlcInt i = 0; i < a.getSize(); i++)
        use(cp, a[i]);
     
      //use(cp, obj);
      
      IlcInt dim2 = a.getSize();
      IlcIntVar * sa = new (cp.getHeap()) IlcIntVar [dim2];
      for (IlcInt j = 0; j < dim2; j++)
        sa[j] = cp.getIntVar(a[j]);
     
      IlcFloatExp * _obj = new (cp.getHeap()) IlcFloatExp;
      *_obj = cp.getFloatExp(obj);
      
      return MyConstraint(cp, a.getSize(), sa, _obj);
    }
     
     
    int main() {
     
     // initialize
     
      IloNumExpr obj = ...;
     
      model.add(IloMaximize(env, obj));
     
      model.add(MyConstraint(env, ivar, obj));
     
     // start solution
     
    }
     
     

    #CPOptimizer
    #DecisionOptimization


  • 2.  Re: IloNumExpr into IlcConstraintI

    Posted 06/13/13 05:15 AM

    Originally posted by: Philippe_Refalo


    The solution to this problem is the same as the one proposed in this post, that is to add a new variable for the objective function. In the latest release of CP Optimizer we have introduced presolve and there is no longer a one-to-one correspondance between Concert and engine objects

    Regards,

    Philippe


    #CPOptimizer
    #DecisionOptimization


  • 3.  Re: IloNumExpr into IlcConstraintI

    Posted 06/13/13 09:05 AM

    Originally posted by: mrmag


    Thank you!


    #CPOptimizer
    #DecisionOptimization