15 model_type::expression_type expr;
17 std::vector<model_type::variable_type> vVar;
18 for (
int i = 0; i < 5; ++i)
21 limboAssertMsg(optModel.addConstraint(vVar[0]+1+2*vVar[1]-vVar[2]*10 <= 10),
"fail to add constraint");
22 limboAssertMsg(optModel.addConstraint(-3*vVar[0]-1.5-vVar[1]+1.5+vVar[3] >= 5),
"fail to add constraint");
23 limboAssertMsg(optModel.addConstraint(1-vVar[0]-2*(vVar[1]+vVar[3]) == 5),
"fail to add constraint");
24 expr = (vVar[4]*4-vVar[2]*3)/2;
25 expr = vVar[1]*2 + expr;
28 limboAssertMsg(optModel.addConstraint(expr >= 1),
"fail to add constraint");
29 limboAssertMsg(optModel.addConstraint(vVar[1]-vVar[0]-(1-vVar[1]) <= -1),
"fail to add constraint");
32 expr = vVar[0]*4 + vVar[1]*2 + vVar[2]/2 + (vVar[3]/4 - (-vVar[4])*5);
33 expr -= vVar[0] + -vVar[2]/4;
34 optModel.setObjective(expr);
37 std::cout <<
"////////////////////// " << __func__ <<
"//////////////////////\n";
38 optModel.print(std::cout);
43 void test2(std::string
const& filename)
47 optModel.
read(filename);
49 std::cout <<
"////////////////////// " << __func__ <<
"//////////////////////\n";
50 optModel.print(std::cout);
56 int main(
int argc,
char** argv)
65 else std::cout <<
"at least one argument is required to test file API\n";
void test2(std::string const &filename)
test file API
Basic utilities such as variables and linear expressions in solvers.
void test1()
test function API
int main(int argc, char **argv)
main function
void read(std::string const &filename)
read lp format
model to describe an optimization problem
#define limboAssertMsg(condition, args...)
custom assertion with message