Main Page   Class Hierarchy   Compound List   File List   Contact   Download   Symbolic Constraints   Examples  


This example shows the proper handling of the class SCIL::polynomial.

We first create a new instance of SCIL::ILP_Problem.

   ILP_Problem IP(Optsense_Max);

Then we add some binary variables to our model.

   var a = IP.add_binary_variable(0.);
   var b = IP.add_binary_variable(0.);
   var c = IP.add_binary_variable(0.);

With these variables we are now able to create some polynomials. Polynomials can be created conveniently with the overloaded operators +, - and *.

   polynomial p1 = a*b + a + 3*a*b*c;
   polynomial p2 = p1 - 3*a*b;
   polynomial p3 = a*b*c;
   p3 -= b*c*a;

Next we normalize the polynomials which means we summarize and simplify them. If normalize is called with the parameter clean=true, monomials with coefficient 0 are deleted.

   polynomial p1n(p1);
   polynomial p2n(p2);
   polynomial p3n(p3);
   polynomial p3nc(p3);

Now we add the just created polynomials to our objective function.


The creation of polynomial constraints follows the same intuitive way as with basic constraints.

   polynomial p_cons = c*b + 2*c;
   IP.add_pol_constraint(p_cons <= 1.);

Finally we can call optimize to solve the problem.


Generated on Mon Mar 28 22:03:47 2011 for SCIL by  doxygen 1.6.3