lprec* lp;
uint64_t num = 6144570;
std::vector row(num+1, 0.0);
lp = make_lp(0,num);
set_add_rowmode(lp, FALSE);
for(int i=1; i<num; i++){
row[i] = i;
}
row[num] = -1e10;
set_obj_fn(lp, &row.front());
set_maxim(lp);
for(int i=0; i<num; i++){
row[i] = 1.0;
}
row[num] = 0.0;
set_add_rowmode(lp,TRUE);
add_constraint(lp,&row.front(),LE,num/4);
set_add_rowmode(lp,TRUE);
for(int i=0; i<num; i++){
set_binary(lp, i, TRUE);
}
set_int(lp, num, TRUE);
set_add_rowmode(lp,FALSE);
set_verbose(lp, FULL);
static char kBfpConfigurationString[] = "bfp_LUSOL"; //求解solver
set_BFP(lp, kBfpConfigurationString);
set_scaling(lp, SCALE_CURTISREID);
// Example presolver call from lp_solve documentation.
set_presolve(
lp, PRESOLVE_ROWS | PRESOLVE_COLS | PRESOLVE_LINDEP,
get_presolveloops(lp)); //
// It seems NODE_RANGESELECT does to trick for the optimizer to realize it
// need to adapt the slack variable. Other flags are default ones for
// lp_solve.
set_bb_rule(
lp,
NODE_RANGESELECT | NODE_GREEDYMODE | NODE_DYNAMICMODE | NODE_RCOSTFIXING);
int ret = solve(lp); //求解solver
printf("Objective value: %f\n", get_objective(lp));
REAL* variables_ptr;
get_ptr_variables(lp, &variables_ptr);
std::cout << "variables_ptr " << variables_ptr[0] << " " << variables_ptr[1] << " " << variables_ptr[2] << std::endl;
delete_lp(lp);