In this example we solve constrained logic optimization problems with boolean functions . Valid instances are in the LOGOPT format which is described on http://we.logoptimize.it .
First we create a new instance of SCIL::ILP_Problem and set the optimization sense to Optsense_Max
.
The read_instance
function successively adds boolean functions and/or boolean constraints to the ILP model. How this works in detail is described in the example Boolean_Functions
Because SCIL completely takes care of the linearization process all we have to do is call IP.optimize()
to solve the problem. After that we examine and print the solution.
int main(int argc, char** argv) { //create a new ILP problem ILP_Problem IP(Optsense_Max); //read an inputfile map<string, var> varMap; read_instance(argv[1], IP, varMap); //optimize IP.optimize(); //examine the solution cout<<"Optimal solution value: "<<IP.get_optimum()<<endl; for(map<string,var>::iterator it = varMap.begin(); it != varMap.end(); it++) cout<<it->first<<": "<<IP.get_solution(it->second)<<endl; }