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

Boolean_Functions

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)

```   ILP_Problem IP(Optsense_Max);
```
Then we add some variables to the IP with different objective function coefficients.
```   var x0 = IP.add_binary_variable(0.);
```
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 and is set to . Because is changed after adding it to this change has no effect on .
```   bf1->add(IMP, bf2);
```
Then we add two boolean functions and to the objective function of IP.
```   IP.add_boolfunction(bf1, 1.);
```
Finally we construct a boolean constraint of type `C1` which means that every boolean function in the given list must be true for every feasible solution.
```   list<boolfunction*> cl;
cl.push_back(bf4);
cl.push_back(bf5);
Now we can compute an optimal solution by calling `optimize`.
```   IP.optimize();
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 .
```   delete bf3;
Generated on Mon Mar 28 22:03:46 2011 for SCIL by 1.6.3