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; *infeasible = 0;
#if LOG_LEVEL >= LOG_LEVEL_DEBUG #if LOG_LEVEL >= LOG_LEVEL_DEBUG
int numrows = CPXgetnumrows(lp->cplex_env, lp->cplex_lp); int numrows = CPXgetnumrows(lp->cplex_env, lp->cplex_lp);
int numcols = CPXgetnumcols(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); log_debug("Optimizing LP (%d rows %d cols)...\n", numrows, numcols);
#endif #endif
double time_before = get_current_time(); double time_before = get_current_time();
rval = CPXdualopt(lp->cplex_env, lp->cplex_lp); rval = CPXdualopt(lp->cplex_env, lp->cplex_lp);
@ -251,7 +251,7 @@ int LP_remove_old_cuts(struct LP *lp)
{ {
struct Row *cut = lp->cut_pool[j]; 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--; else if (cut->cplex_row_index > i - count) cut->cplex_row_index--;
} }
@ -365,7 +365,6 @@ int LP_write(struct LP *lp, const char *fname)
int compare_cuts(struct Row *cut1, struct Row *cut2) int compare_cuts(struct Row *cut1, struct Row *cut2)
{ {
return_if_neq(cut1->nz, cut2->nz); return_if_neq(cut1->nz, cut2->nz);
assert(cut1->nz == cut2->nz);
for (int i = 0; i < cut1->nz; i++) 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 (lp->cut_pool[i]->hash != cut->hash) continue;
if (!compare_cuts(lp->cut_pool[i], cut)) 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->rmatval);
free(cut->rmatind); free(cut->rmatind);
free(cut); free(cut);