Rename greedy to infinity

selection
Alinson S. Xavier 9 years ago
parent 0ee68e01bc
commit 7142eb2d68

@ -114,32 +114,32 @@ instances/%.done: $(multirow) 2row-cont/%.yaml 2row-lift/%.yaml 3row-cont/%.yaml
2row-cont/%.yaml: $(multirow) instances/%.mps.gz bases/%.bas 2row-cont/%.yaml: $(multirow) instances/%.mps.gz bases/%.bas
@echo " 2row-cont $*..." @echo " 2row-cont $*..."
@$(multirow) --mir --greedy --problem instances/$*.mps.gz --basis bases/$*.bas --log 2row-cont/$*.log --stats $@ --solution solutions/$*.x || touch 2row-cont/$*.err.$$? @$(multirow) --mir --infinity --problem instances/$*.mps.gz --basis bases/$*.bas --log 2row-cont/$*.log --stats $@ --solution solutions/$*.x || touch 2row-cont/$*.err.$$?
@echo " 2row-cont $* [done]" @echo " 2row-cont $* [done]"
2row-lift/%.yaml: $(multirow) instances/%.mps.gz bases/%.bas 2row-lift/%.yaml: $(multirow) instances/%.mps.gz bases/%.bas
@echo " 2row-lift $*..." @echo " 2row-lift $*..."
@$(multirow) --mir --greedy --problem instances/$*.mps.gz --basis bases/$*.bas --log 2row-lift/$*.log --stats $@ --solution solutions/$*.x --lift || touch 2row-lift/$*.err.$$? @$(multirow) --mir --infinity --problem instances/$*.mps.gz --basis bases/$*.bas --log 2row-lift/$*.log --stats $@ --solution solutions/$*.x --lift || touch 2row-lift/$*.err.$$?
@echo " 2row-lift $* [done]" @echo " 2row-lift $* [done]"
3row-cont/%.yaml: $(multirow) instances/%.mps.gz bases/%.bas 3row-cont/%.yaml: $(multirow) instances/%.mps.gz bases/%.bas
@echo " 3row-cont $*..." @echo " 3row-cont $*..."
@$(multirow) --mir --greedy --problem instances/$*.mps.gz --basis bases/$*.bas --log 3row-cont/$*.log --stats $@ --solution solutions/$*.x --rows 3 || touch 3row-cont/$*.err.$$? @$(multirow) --mir --infinity --problem instances/$*.mps.gz --basis bases/$*.bas --log 3row-cont/$*.log --stats $@ --solution solutions/$*.x --rows 3 || touch 3row-cont/$*.err.$$?
@echo " 3row-cont $* [done]" @echo " 3row-cont $* [done]"
3row-lift/%.yaml: $(multirow) instances/%.mps.gz bases/%.bas 3row-lift/%.yaml: $(multirow) instances/%.mps.gz bases/%.bas
@echo " 3row-lift $*..." @echo " 3row-lift $*..."
@$(multirow) --mir --greedy --problem instances/$*.mps.gz --basis bases/$*.bas --log 3row-lift/$*.log --stats $@ --solution solutions/$*.x --rows 3 --lift || touch 3row-lift/$*.err.$$? @$(multirow) --mir --infinity --problem instances/$*.mps.gz --basis bases/$*.bas --log 3row-lift/$*.log --stats $@ --solution solutions/$*.x --rows 3 --lift || touch 3row-lift/$*.err.$$?
@echo " 3row-lift $* [done]" @echo " 3row-lift $* [done]"
5row-cont/%.yaml: $(multirow) instances/%.mps.gz bases/%.bas 5row-cont/%.yaml: $(multirow) instances/%.mps.gz bases/%.bas
@echo " 5row-cont $*..." @echo " 5row-cont $*..."
@$(multirow) --mir --greedy --problem instances/$*.mps.gz --basis bases/$*.bas --log 5row-cont/$*.log --stats $@ --solution solutions/$*.x --rows 5 || touch 5row-cont/$*.err.$$? @$(multirow) --mir --infinity --problem instances/$*.mps.gz --basis bases/$*.bas --log 5row-cont/$*.log --stats $@ --solution solutions/$*.x --rows 5 || touch 5row-cont/$*.err.$$?
@echo " 5row-cont $* [done]" @echo " 5row-cont $* [done]"
5row-lift/%.yaml: $(multirow) instances/%.mps.gz bases/%.bas 5row-lift/%.yaml: $(multirow) instances/%.mps.gz bases/%.bas
@echo " 5row-lift $*..." @echo " 5row-lift $*..."
@$(multirow) --mir --greedy --problem instances/$*.mps.gz --basis bases/$*.bas --log 5row-lift/$*.log --stats $@ --solution solutions/$*.x --rows 5 --lift || touch 5row-lift/$*.err.$$? @$(multirow) --mir --infinity --problem instances/$*.mps.gz --basis bases/$*.bas --log 5row-lift/$*.log --stats $@ --solution solutions/$*.x --rows 5 --lift || touch 5row-lift/$*.err.$$?
@echo " 5row-lift $* [done]" @echo " 5row-lift $* [done]"

@ -36,7 +36,7 @@ int SHOULD_DUMP_CUTS = 0;
int DUMP_CUT_N = 0; int DUMP_CUT_N = 0;
int GENERATE_MIR = 0; int GENERATE_MIR = 0;
int GENERATE_GREEDY = 0; int GENERATE_INFINITY = 0;
int KEEP_INTEGRALITY = 0; int KEEP_INTEGRALITY = 0;
int N_ROUNDS = 1; int N_ROUNDS = 1;
@ -63,7 +63,7 @@ static const struct option options_tab[] =
{"problem", required_argument, 0, 'p'}, {"problem", required_argument, 0, 'p'},
{"solution", required_argument, 0, 'x'}, {"solution", required_argument, 0, 'x'},
{"mir", no_argument, 0, 'm'}, {"mir", no_argument, 0, 'm'},
{"greedy", no_argument, 0, 'g'}, {"infinity", no_argument, 0, 'g'},
{"rounds", required_argument, 0, 'r'}, {"rounds", required_argument, 0, 'r'},
{"keep-integrality", no_argument, 0, 'k'}, {"keep-integrality", no_argument, 0, 'k'},
{"write-solution", required_argument, 0, OPTION_WRITE_SOLUTION}, {"write-solution", required_argument, 0, OPTION_WRITE_SOLUTION},
@ -86,8 +86,8 @@ static void print_usage(char **argv)
printf("%4s %-20s %s\n", "-b", "--basis=FILE", printf("%4s %-20s %s\n", "-b", "--basis=FILE",
"BAS file containing an optimal basis for the linear relaxation of " "BAS file containing an optimal basis for the linear relaxation of "
"the problem"); "the problem");
printf("%4s %-20s %s\n", "-g", "--greedy", printf("%4s %-20s %s\n", "-g", "--infinity",
"generate greedy intersection cuts"); "generate infinity cuts");
printf("%4s %-20s %s\n", "-k", "--keep-integrality", printf("%4s %-20s %s\n", "-k", "--keep-integrality",
"do not relax integrality of variables"); "do not relax integrality of variables");
printf("%4s %-20s %s\n", "-l", "--log=FILE", printf("%4s %-20s %s\n", "-l", "--log=FILE",
@ -135,7 +135,7 @@ static int parse_args(int argc,
break; break;
case 'g': case 'g':
GENERATE_GREEDY = 1; GENERATE_INFINITY = 1;
break; break;
case 'k': case 'k':
@ -207,7 +207,7 @@ static int parse_args(int argc,
rval = 1; rval = 1;
} }
if (KEEP_INTEGRALITY && (GENERATE_GREEDY + GENERATE_MIR > 0)) if (KEEP_INTEGRALITY && (GENERATE_INFINITY + GENERATE_MIR > 0))
{ {
fprintf(stderr, "Cutting planes cannot be added when integrality is " fprintf(stderr, "Cutting planes cannot be added when integrality is "
"kept\n"); "kept\n");
@ -242,8 +242,7 @@ void print_header(int argc,
time_printf("Compile-time parameters:\n"); time_printf("Compile-time parameters:\n");
time_printf(" EPSILON: %e\n", EPSILON); time_printf(" EPSILON: %e\n", EPSILON);
time_printf(" GREEDY_BIG_E: %e\n", GREEDY_BIG_E); time_printf(" INFINITY_BIG_E: %e\n", INFINITY_BIG_E);
time_printf(" GREEDY_MAX_GAP: %e\n", GREEDY_MAX_GAP);
char cmdline[5000] = {0}; char cmdline[5000] = {0};
for (int i = 0; i < argc; i++) for (int i = 0; i < argc; i++)
@ -356,7 +355,7 @@ int main(int argc,
abort_if(rval, "LP_write_basis failed"); abort_if(rval, "LP_write_basis failed");
} }
if(GENERATE_MIR || GENERATE_GREEDY) if(GENERATE_MIR || GENERATE_INFINITY)
{ {
cg = (struct CG *) malloc(sizeof(struct CG)); cg = (struct CG *) malloc(sizeof(struct CG));
abort_if(!cg, "could not allocate cg"); abort_if(!cg, "could not allocate cg");
@ -409,11 +408,11 @@ int main(int argc,
STATS_finish_round(); STATS_finish_round();
} }
if (GENERATE_GREEDY) if (GENERATE_INFINITY)
{ {
for(int k = MIN_N_ROWS; k <= MAX_N_ROWS; k++) for(int k = MIN_N_ROWS; k <= MAX_N_ROWS; k++)
{ {
log_info("Adding greedy intersection cuts (%d rows)...\n", k); log_info("Adding infinity cuts (%d rows)...\n", k);
rval = CG_add_multirow_cuts(cg, k, rval = CG_add_multirow_cuts(cg, k,
(MultiRowGeneratorCallback) INFINITY_generate_cut); (MultiRowGeneratorCallback) INFINITY_generate_cut);

@ -545,7 +545,7 @@ int INFINITY_2D_generate_lfree(const struct MultiRowModel *model,
lfree->rays.nrays = nrays; lfree->rays.nrays = nrays;
memcpy(rays, model->rays.values, 2 * nrays * sizeof(double)); memcpy(rays, model->rays.values, 2 * nrays * sizeof(double));
memcpy(f, model->f, 2 * sizeof(double)); memcpy(f, model->f, 2 * sizeof(double));
for (int i = 0; i < nrays; i++) beta[i] = GREEDY_BIG_E; for (int i = 0; i < nrays; i++) beta[i] = INFINITY_BIG_E;
scale = (double*) malloc(nrays * sizeof(double)); scale = (double*) malloc(nrays * sizeof(double));
abort_if(!scale, "could not allocate scale"); abort_if(!scale, "could not allocate scale");
@ -561,7 +561,7 @@ int INFINITY_2D_generate_lfree(const struct MultiRowModel *model,
abort_if(count++ > 2 * nrays, "infinite loop"); abort_if(count++ > 2 * nrays, "infinite loop");
rval = get_bounding_box(2, nrays, rays, beta, GREEDY_BIG_E, lb, ub); rval = get_bounding_box(2, nrays, rays, beta, INFINITY_BIG_E, lb, ub);
abort_if(rval, "get_bounding_box failed"); abort_if(rval, "get_bounding_box failed");
log_verbose(" box=[%.2lf %.2lf] [%.2lf %.2lf]\n", lb[0], ub[0], lb[1], ub[1]); log_verbose(" box=[%.2lf %.2lf] [%.2lf %.2lf]\n", lb[0], ub[0], lb[1], ub[1]);

@ -942,7 +942,7 @@ static int bound(int nrows,
double prev_epsilon; double prev_epsilon;
int count = 0; int count = 0;
*epsilon = GREEDY_BIG_E; *epsilon = INFINITY_BIG_E;
rx = (int *) malloc(nrays * sizeof(int)); rx = (int *) malloc(nrays * sizeof(int));
fbar = (double *) malloc(nrows * sizeof(double)); fbar = (double *) malloc(nrows * sizeof(double));
@ -990,7 +990,7 @@ static int bound(int nrows,
for(int i = 0; i < nrays; i++) for(int i = 0; i < nrays; i++)
tx[i] = 0; tx[i] = 0;
if(DOUBLE_geq(*epsilon, GREEDY_BIG_E)) if(DOUBLE_geq(*epsilon, INFINITY_BIG_E))
{ {
*epsilon = INFINITY; *epsilon = INFINITY;
goto CLEANUP; goto CLEANUP;
@ -1245,7 +1245,7 @@ int INFINITY_ND_generate_lfree(const struct MultiRowModel *model,
abort_if(!x, "could not allocate x"); abort_if(!x, "could not allocate x");
for(int i = 0; i < nrays; i++) for(int i = 0; i < nrays; i++)
beta[i] = GREEDY_BIG_E; beta[i] = INFINITY_BIG_E;
int it = 0; int it = 0;

@ -200,7 +200,7 @@ static int filter_model(const struct MultiRowModel *original_model,
if(keep) LFREE_push_ray(filtered_rays, r); if(keep) LFREE_push_ray(filtered_rays, r);
} }
log_debug(" norm_cutoff=%8.2lf nrays=%8d\n", norm_cutoff, log_verbose(" norm_cutoff=%8.2lf nrays=%8d\n", norm_cutoff,
filtered_model->rays.nrays); filtered_model->rays.nrays);
if(filtered_rays->nrays < MAX_N_RAYS) break; if(filtered_rays->nrays < MAX_N_RAYS) break;

@ -80,7 +80,7 @@ TEST(Infinity2DTest, test_generate_cut_2)
EXPECT_NEAR(0.5, lfree.beta[0], BOUNDS_EPSILON); EXPECT_NEAR(0.5, lfree.beta[0], BOUNDS_EPSILON);
EXPECT_NEAR(0.5, lfree.beta[1], BOUNDS_EPSILON); EXPECT_NEAR(0.5, lfree.beta[1], BOUNDS_EPSILON);
EXPECT_NEAR(0.5, lfree.beta[2], BOUNDS_EPSILON); EXPECT_NEAR(0.5, lfree.beta[2], BOUNDS_EPSILON);
EXPECT_EQ(GREEDY_BIG_E, lfree.beta[3]); EXPECT_EQ(INFINITY_BIG_E, lfree.beta[3]);
EXPECT_NEAR(0.5, lfree.beta[4], BOUNDS_EPSILON); EXPECT_NEAR(0.5, lfree.beta[4], BOUNDS_EPSILON);
CLEANUP: CLEANUP:
@ -102,7 +102,7 @@ TEST(Infinity2DTest, test_generate_cut_3)
EXPECT_NEAR(5.0, lfree.beta[0], BOUNDS_EPSILON); EXPECT_NEAR(5.0, lfree.beta[0], BOUNDS_EPSILON);
EXPECT_NEAR(17.0, lfree.beta[2], BOUNDS_EPSILON); EXPECT_NEAR(17.0, lfree.beta[2], BOUNDS_EPSILON);
EXPECT_EQ(GREEDY_BIG_E, lfree.beta[1]); EXPECT_EQ(INFINITY_BIG_E, lfree.beta[1]);
CLEANUP: CLEANUP:
if (rval) FAIL(); if (rval) FAIL();
@ -288,8 +288,8 @@ TEST(Infinity2DTest, find_containing_cone_test_3)
// EXPECT_NEAR(20.0, bounds[1], BOUNDS_EPSILON); // EXPECT_NEAR(20.0, bounds[1], BOUNDS_EPSILON);
// EXPECT_NEAR(18.0, bounds[2], BOUNDS_EPSILON); // EXPECT_NEAR(18.0, bounds[2], BOUNDS_EPSILON);
// EXPECT_NEAR(18.0, bounds[5], BOUNDS_EPSILON); // EXPECT_NEAR(18.0, bounds[5], BOUNDS_EPSILON);
// EXPECT_EQ(GREEDY_BIG_E, bounds[3]); // EXPECT_EQ(INFINITY_BIG_E, bounds[3]);
// EXPECT_EQ(GREEDY_BIG_E, bounds[4]); // EXPECT_EQ(INFINITY_BIG_E, bounds[4]);
// //
// CLEANUP: // CLEANUP:
// if (rval) FAIL(); // if (rval) FAIL();
@ -314,8 +314,8 @@ TEST(Infinity2DTest, find_containing_cone_test_3)
// EXPECT_NEAR(20.0, bounds[1], BOUNDS_EPSILON); // EXPECT_NEAR(20.0, bounds[1], BOUNDS_EPSILON);
// EXPECT_NEAR(18.0, bounds[2], BOUNDS_EPSILON); // EXPECT_NEAR(18.0, bounds[2], BOUNDS_EPSILON);
// EXPECT_NEAR(18.0, bounds[5], BOUNDS_EPSILON); // EXPECT_NEAR(18.0, bounds[5], BOUNDS_EPSILON);
// EXPECT_EQ(GREEDY_BIG_E, bounds[3]); // EXPECT_EQ(INFINITY_BIG_E, bounds[3]);
// EXPECT_EQ(GREEDY_BIG_E, bounds[4]); // EXPECT_EQ(INFINITY_BIG_E, bounds[4]);
// //
// CLEANUP: // CLEANUP:
// if (rval) FAIL(); // if (rval) FAIL();

@ -20,7 +20,7 @@
/* /*
* Error margin for floating point comparisons. * Error margin for floating point comparisons.
*/ */
#define EPSILON 1e-5 #define EPSILON 1e-8
/* /*
* Available log levels, in decreasing level of verboseness, are: * Available log levels, in decreasing level of verboseness, are:
@ -66,11 +66,7 @@
#define MAX_SELECTED_ROWS 300 #define MAX_SELECTED_ROWS 300
#define MAX_LATTICE_POINTS 100000 #define MAX_LATTICE_POINTS 100000
/* #define INFINITY_BIG_E 1e3
* Greedy cut parameters
*/
#define GREEDY_BIG_E 1e3
#define GREEDY_MAX_GAP 1e-4
#define MAX_CUT_DYNAMISM 1e8 #define MAX_CUT_DYNAMISM 1e8
#define INTEGRALITY_THRESHOLD 0.49 #define INTEGRALITY_THRESHOLD 0.49

@ -801,7 +801,7 @@ int CG_add_multirow_cuts(struct CG *cg,
row_affinity, &total_count, cutoff); row_affinity, &total_count, cutoff);
abort_if(rval, "estimate_two_row_cuts_count failed"); abort_if(rval, "estimate_two_row_cuts_count failed");
log_debug(" %8d combinations [%.2lf]\n", total_count, cutoff); log_verbose(" %8d combinations [%.2lf]\n", total_count, cutoff);
if (total_count < MAX_SELECTED_COMBINATIONS) if (total_count < MAX_SELECTED_COMBINATIONS)
{ {
@ -884,7 +884,7 @@ int CG_add_multirow_cuts(struct CG *cg,
if_debug_level if (ONLY_CUT > 0 && count != ONLY_CUT) if_debug_level if (ONLY_CUT > 0 && count != ONLY_CUT)
goto NEXT_COMBINATION; goto NEXT_COMBINATION;
if_debug_level if_verbose_level
{ {
time_printf("Generating cut %d from [ ", count); time_printf("Generating cut %d from [ ", count);
for (int i = 0; i < nrows; i++) for (int i = 0; i < nrows; i++)
@ -906,7 +906,7 @@ int CG_add_multirow_cuts(struct CG *cg,
.column_types = cg->column_types .column_types = cg->column_types
}; };
if_debug_level if_verbose_level
{ {
char filename[100]; char filename[100];
sprintf(filename, "tableau-%03ld.c", count); sprintf(filename, "tableau-%03ld.c", count);
@ -933,7 +933,7 @@ int CG_add_multirow_cuts(struct CG *cg,
} }
else abort_iff(rval, "generate failed (cut %d)", count); else abort_iff(rval, "generate failed (cut %d)", count);
if_debug_level if_verbose_level
{ {
char filename[100]; char filename[100];
sprintf(filename, "cut-%03ld.c", count); sprintf(filename, "cut-%03ld.c", count);
@ -943,7 +943,7 @@ int CG_add_multirow_cuts(struct CG *cg,
} }
double elapsed_time = get_user_time() - initial_time; double elapsed_time = get_user_time() - initial_time;
log_debug(" generate: %.2lf ms\n", elapsed_time * 1000); log_verbose(" generate: %.2lf ms\n", elapsed_time * 1000);
double dynamism; double dynamism;
rval = cut_dynamism(&cut, &dynamism); rval = cut_dynamism(&cut, &dynamism);
@ -951,7 +951,7 @@ int CG_add_multirow_cuts(struct CG *cg,
if (dynamism > MAX_CUT_DYNAMISM) if (dynamism > MAX_CUT_DYNAMISM)
{ {
log_debug("Discarding cut (dynamism=%.2lf)\n", dynamism); log_verbose("Discarding cut (dynamism=%.2lf)\n", dynamism);
LP_free_row(&cut); LP_free_row(&cut);
goto NEXT_COMBINATION; goto NEXT_COMBINATION;
} }

@ -485,7 +485,7 @@ TEST(GeometryTest, chull_2d_test)
// //
// EXPECT_DOUBLE_EQ(0.5, bounds[0]); // EXPECT_DOUBLE_EQ(0.5, bounds[0]);
// EXPECT_DOUBLE_EQ(0.5, bounds[1]); // EXPECT_DOUBLE_EQ(0.5, bounds[1]);
// EXPECT_EQ(GREEDY_BIG_E, bounds[2]); // EXPECT_EQ(INFINITY_BIG_E, bounds[2]);
// EXPECT_DOUBLE_EQ(0.5, bounds[3]); // EXPECT_DOUBLE_EQ(0.5, bounds[3]);
// EXPECT_DOUBLE_EQ(0.5, bounds[4]); // EXPECT_DOUBLE_EQ(0.5, bounds[4]);
// //