This example shows the proper handling of the class SCIL::boolfunction
We first create a new instance IP of an SCIL::ILP_Problem. (In this example it is a maximization problem)
Then we add some variables to the IP with different objective function coefficients.
var x0 = IP.add_binary_variable(0.);
var x1 = IP.add_binary_variable(2.);
var x2 = IP.add_binary_variable(0.);
var x3 = IP.add_binary_variable(0.);
var x4 = IP.add_binary_variable(1.);
Now we create a boolean function
. The last parameter is true, if the created boolean function should be negated.
boolfunction* bf1 = new boolfunction(x0, true);
The other boolean functions in this example are created with two variables and one operator. If the last boolean parameter has been omitted the boolean function is not negated. The created boolean functions are:
boolfunction* bf2 = new boolfunction(x1, x2, OR, true);
boolfunction* bf3 = new boolfunction(x3, x4, XOR);
boolfunction* bf4 = new boolfunction(x0, x3, IMP);
boolfunction* bf5 = new boolfunction(x0, x4, IMP);
Existing boolean functions can be connected with SCIL::boolfunction::add
is set to
is set to
is changed after adding it to
this change has no effect on
Then we add two boolean functions
to the objective function of IP.
Finally we construct a boolean constraint of type
which means that every boolean function in the given list must be true for every feasible solution.
Now we can compute an optimal solution by calling
After all we have to delete every created boolfunction which has not been added to the ILP_Problem in any way. In this example this only holds for