Bugfix. Rows not in cplex should have index -1

master
Alinson S. Xavier 11 years ago
parent 188367e189
commit f8943fb1ec

@ -165,11 +165,11 @@ int LP_optimize(struct LP *lp, int *infeasible)
*infeasible = 0;
#if LOG_LEVEL >= LOG_LEVEL_DEBUG
#if LOG_LEVEL >= LOG_LEVEL_DEBUG
int numrows = CPXgetnumrows(lp->cplex_env, lp->cplex_lp);
int numcols = CPXgetnumcols(lp->cplex_env, lp->cplex_lp);
log_debug("Optimizing LP (%d rows %d cols)...\n", numrows, numcols);
#endif
#endif
double time_before = get_current_time();
rval = CPXdualopt(lp->cplex_env, lp->cplex_lp);
@ -229,7 +229,7 @@ int LP_remove_old_cuts(struct LP *lp)
log_verbose("Old cplex row index:\n");
for (int i = 0; i < lp->cut_pool_size; i++)
log_verbose(" %d\n", lp->cut_pool[i]->cplex_row_index);
log_verbose(" %d\n", lp->cut_pool[i]->cplex_row_index);
log_verbose("Should remove:\n");
for (int i = 0; i < lp->cut_pool_size; i++)
@ -251,7 +251,7 @@ int LP_remove_old_cuts(struct LP *lp)
{
struct Row *cut = lp->cut_pool[j];
if (cut->cplex_row_index == i - count) cut->cplex_row_index = 0;
if (cut->cplex_row_index == i - count) cut->cplex_row_index = -1;
else if (cut->cplex_row_index > i - count) cut->cplex_row_index--;
}
@ -260,7 +260,7 @@ int LP_remove_old_cuts(struct LP *lp)
log_verbose("New cplex row index:\n");
for (int i = 0; i < lp->cut_pool_size; i++)
log_verbose(" %d\n", lp->cut_pool[i]->cplex_row_index);
log_verbose(" %d\n", lp->cut_pool[i]->cplex_row_index);
int start = 0;
int end = -1;
@ -365,7 +365,6 @@ int LP_write(struct LP *lp, const char *fname)
int compare_cuts(struct Row *cut1, struct Row *cut2)
{
return_if_neq(cut1->nz, cut2->nz);
assert(cut1->nz == cut2->nz);
for (int i = 0; i < cut1->nz; i++)
{
@ -390,6 +389,9 @@ int LP_add_cut(struct LP *lp, struct Row *cut)
if (lp->cut_pool[i]->hash != cut->hash) continue;
if (!compare_cuts(lp->cut_pool[i], cut))
{
log_verbose("Discarding duplicate cut (same as cplex row %d)\n",
lp->cut_pool[i]->cplex_row_index);
free(cut->rmatval);
free(cut->rmatind);
free(cut);