Originally posted by: SystemAdmin
Hello,
> 1. If I call the method Model of class CP, I get an “invalid cast” exception.
Indeed, this method was not supposed to be documented. You should work on the current model of the instance of CP and add the constraints there: cp.Add(ct).
> 2. It is not possible to use the interfaces IAnd and IOr since the method Add throws
> a “not implemented” exception.
These functions are indeed missing. As a work-around, you can create constraint arrays as in the sample below:
CP cp =
new CP(); IIntVar x = cp.IntVar(0, 3); IIntVar y = cp.IntVar(0, 3); IIntVar z = cp.IntVar(0, 3); IConstraint[] cts =
new IConstraint[3]; cts[0] = cp.Eq(x, y); cts[1] = cp.Eq(x, z); cts[2] = cp.Eq(y, z); IOr orCt = cp.Or(cts); cp.Add(orCt);
Thank you for reporting these issues.
> 3. If I define a NumToNumStepFunction using the method NumToNumStepFunction(double xmin,
> double xmax, double dval) and attach it to an interval variable as intensity (using the
> method +SetIntensity+) I get an exception while solving the problem.
It works in last release (CPLEX Optimization Studio V12.2) but indeed crashes on earlier versions (CP Optimizer 6.3). A work-around in earlier versions is to create the step function without default value and define the function values using the SetValue member function.
> 4. Defining own constraints by implementing the interface IConstraint is not possible as
> the method ILOG.Concert.Cppimpl.IloConcertUtils.ToCppIloExtractable(IAddable v) tries to
> cast the constraint to ILOG.Concert.Cppimpl.IloExtractable although it only takes
> IAddable.
You cannot subclass in the C# interface. See the release notes, section on "Limitations of the Microsoft .NET Framework languages API". In fact, you cannot define your own constraints in C#. For defining your own constraints you need to use Java or C++. C++ will be much more efficient.
Philippe
#CPOptimizer#DecisionOptimization