infinity: Disallow very small coefficients

master
Alinson S. Xavier 8 years ago
parent 0f4480a16d
commit 00298630da

@ -155,6 +155,7 @@ static int create_cut_from_lfree(const struct Tableau *tableau,
}
value *= 1.001;
value = fmax(value, 0.001);
log_verbose(" psi[%4d] = %20.12lf %d\n", map->indices[i], value);
cut->indices[i] = map->indices[i];

@ -264,16 +264,66 @@ TEST(InfinityTest, generate_cut_test_5)
int rval = 0;
// Extracted from instance bell5.pre.mps (MIPLIB 3)
char column_types[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, };
double pi0[] = { 1.0000000000, 0.0416666667, -0.0416666667, -0.0416666667, };
double pi1[] = { 1.0000000000, 0.0416666667, -0.0416666667, -0.0416666667, -0.0416666667, };
int indices0[] = { 50, 64, 143, 156, };
int indices1[] = { 49, 63, 64, 142, 155, };
struct Row row0 = {.nz = 4, .head = 50, .pi_zero = 41.6666666667, .pi = pi0, .indices = indices0 };
struct Row row1 = {.nz = 5, .head = 49, .pi_zero = 16.6666666667, .pi = pi1, .indices = indices1 };
struct Row* rows[] = {&row0, &row1, };
struct Tableau tableau = {.ncols = 169, .nrows = 2, .rows = rows, .column_types = column_types };
double x[169] = {1.0000000000, 1.0000000000, 1.0000000000, 1.0000000000, 1.0000000000, 0.0000000000, 1.0000000000, 0.0000000000, 0.0000000000, 1.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 1.0000000000, 1.0000000000, 0.0000000000, 11.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 2.0000000000, 38.0000000000, 2.0000000000, 498.0000000000, 125.0000000000, 10.0000000000, 17.0000000000, 41.0000000000, 0.0000000000, 19.0000000000, 0.0000000000, 8318.0000000000, 7494.0000000000, 60.0000000000, 10.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 18.0000000000, 8.0000000000, 16.0000000000, 334.0000000000, 24.0000000000, 792.0000000000, 792.0000000000, 336.0000000000, 336.0000000000, 0.0000000000, 40.0000000000, 166.0000000000, 3000.0000000000, 1632.0000000000, 1392.0000000000, 984.0000000000, 456.0000000000, 456.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 48.0000000000, 900.0000000000, 40.0000000000, 11950.0000000000, 240.0000000000, 408.0000000000, 984.0000000000, 0.0000000000, 456.0000000000, 0.0000000000, -0.0000000000, -0.0000000000, -0.0000000000, -0.0000000000, 1.0000000000, 0.0000000000, 1.0000000000, 1.0000000000, 0.0000000000, 1.0000000000, 1.0000000000, 20.0000000000, 20.0000000000, 20.0000000000, 19.0000000000, 19.0000000000, 0.0000000000, 9.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 20.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 238.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 12.0000000000, 8.0000000000, 2.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0053700000, 0.6917620000, 6.9221320000, 0.0000000000, 0.9966800000, 11.9862220000, 0.7510000000, 0.8495500000, 3.3519300000, 266583.5900000000, };
char column_types[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,};
double pi0[] = {1.0000000000, 0.0416666667, -0.0416666667, -0.0416666667,};
double pi1[] = {1.0000000000, 0.0416666667, -0.0416666667, -0.0416666667,
-0.0416666667,};
int indices0[] = {50, 64, 143, 156,};
int indices1[] = {49, 63, 64, 142, 155,};
struct Row row0 = {.nz = 4, .head = 50, .pi_zero = 41.6666666667, .pi = pi0, .indices = indices0};
struct Row row1 = {.nz = 5, .head = 49, .pi_zero = 16.6666666667, .pi = pi1, .indices = indices1};
struct Row *rows[] = {&row0, &row1,};
struct Tableau tableau = {.ncols = 169, .nrows = 2, .rows = rows, .column_types = column_types};
double x[169] = {1.0000000000, 1.0000000000, 1.0000000000, 1.0000000000,
1.0000000000, 0.0000000000, 1.0000000000, 0.0000000000,
0.0000000000, 1.0000000000, 0.0000000000, 0.0000000000,
0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000,
0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000,
0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000,
0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000,
0.0000000000, 1.0000000000, 1.0000000000, 0.0000000000,
11.0000000000, 0.0000000000, 0.0000000000, 0.0000000000,
0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000,
0.0000000000, 0.0000000000, 0.0000000000, 2.0000000000,
38.0000000000, 2.0000000000, 498.0000000000, 125.0000000000,
10.0000000000, 17.0000000000, 41.0000000000, 0.0000000000,
19.0000000000, 0.0000000000, 8318.0000000000, 7494.0000000000,
60.0000000000, 10.0000000000, 0.0000000000, 0.0000000000,
0.0000000000, 0.0000000000, 18.0000000000, 8.0000000000,
16.0000000000, 334.0000000000, 24.0000000000, 792.0000000000,
792.0000000000, 336.0000000000, 336.0000000000, 0.0000000000,
40.0000000000, 166.0000000000, 3000.0000000000, 1632.0000000000,
1392.0000000000, 984.0000000000, 456.0000000000, 456.0000000000,
0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000,
48.0000000000, 900.0000000000, 40.0000000000, 11950.0000000000,
240.0000000000, 408.0000000000, 984.0000000000, 0.0000000000,
456.0000000000, 0.0000000000, -0.0000000000, -0.0000000000,
-0.0000000000, -0.0000000000, 1.0000000000, 0.0000000000,
1.0000000000, 1.0000000000, 0.0000000000, 1.0000000000,
1.0000000000, 20.0000000000, 20.0000000000, 20.0000000000,
19.0000000000, 19.0000000000, 0.0000000000, 9.0000000000,
0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000,
20.0000000000, 0.0000000000, 0.0000000000, 0.0000000000,
0.0000000000, 0.0000000000, 0.0000000000, 238.0000000000,
0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000,
0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000,
0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000,
0.0000000000, 12.0000000000, 8.0000000000, 2.0000000000,
0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000,
0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000,
0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000,
0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000,
0.0000000000, 0.0000000000, 0.0000000000, 0.0053700000,
0.6917620000, 6.9221320000, 0.0000000000, 0.9966800000,
11.9862220000, 0.7510000000, 0.8495500000, 3.3519300000,
266583.5900000000,};
double lhs, s[2];
struct Row cut;
@ -285,7 +335,7 @@ TEST(InfinityTest, generate_cut_test_5)
rval = get_lattice_point(&tableau, x, s);
abort_if(rval, "get_lattice_point failed");
for(int i = 0; i < tableau.nrows; i++)
for (int i = 0; i < tableau.nrows; i++)
log_debug("s[%d] = %20.12lf\n", i, s[i]);
lhs = CG_replace_x(&cut, x);
@ -478,6 +528,45 @@ TEST(InfinityTest, generate_cut_test_12)
rval = INFINITY_generate_cut(&tableau, &cut);
abort_if(rval, "INFINITY_generate_cut failed");
CLEANUP:
if (rval) FAIL();
}
TEST(InfinityTest, generate_cut_test_13)
{
int rval = 0;
// Extracted from instance bell3a.pre.mps (MIPLIB 3)
double pi0[] = { 1.0000000000, -0.0250000000, 0.0000372024, -0.0000372024, 0.0000372024, -0.0000372024, 1.0000000000, -1.0000000000, -1.0000000000, -0.0500000000, -0.0000372024, -0.0000372024, };
double pi1[] = { 1.0000000000, 0.0416666667, -0.0416666667, -0.0416666667, };
double pi2[] = { -0.5000000000, 1.0000000000, 1.0000000000, 0.0007440476, -0.0007440476, 0.0007440476, -0.0007440476, 20.0000000000, -20.0000000000, -20.0000000000, 20.0000000000, -1.0000000000, 1.0000000000, -0.0007440476, -0.0007440476, };
int indices0[] = { 7, 22, 67, 68, 82, 83, 106, 107, 108, 121, 134, 166, };
int indices1[] = { 52, 68, 151, 167, };
int indices2[] = { 22, 24, 37, 67, 68, 82, 83, 104, 107, 108, 110, 121, 123, 134, 166, };
struct Row row0 = {.nz = 12, .head = 106, .pi_zero = 0.0055803571, .pi = pi0, .indices = indices0 };
struct Row row1 = {.nz = 4, .head = 52, .pi_zero = 1.2500000000, .pi = pi1, .indices = indices1 };
struct Row row2 = {.nz = 15, .head = 37, .pi_zero = 0.1116071429, .pi = pi2, .indices = indices2 };
struct Row* rows[] = {&row0, &row1, &row2, };
char column_types[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, };
struct Tableau tableau = {.ncols = 183, .nrows = 3, .rows = rows, .column_types = column_types };
double x[183] = {-0.0000000000, -0.0000000000, -0.0000000000, -0.0000000000, -0.0000000000, -0.0000000000, -0.0000000000, 0.0000000000, -0.0000000000, -0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, -0.0000000000, -0.0000000000, -0.0000000000, -0.0000000000, -0.0000000000, -0.0000000000, -0.0000000000, -0.0000000000, -0.0000000000, -0.0000000000, -0.0000000000, -0.0000000000, -0.0000000000, -0.0000000000, -0.0000000000, -0.0000000000, -0.0000000000, -0.0000000000, -0.0000000000, -0.0000000000, -0.0000000000, -0.0000000000, -0.0000000000, -0.0000000000, -0.0000000000, -0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 4.0000000000, 21.0000000000, 0.0000000000, 0.0000000000, 4.0000000000, 4.0000000000, 6.0000000000, 1.0000000000, 25.0000000000, 8.0000000000, 1112.0000000000, 1012.0000000000, 962.0000000000, 762.0000000000, 752.0000000000, 222.0000000000, 72.0000000000, 10.0000000000, 514.0000000000, 214.0000000000, 4.0000000000, 16.0000000000, 12.0000000000, 6.0000000000, 0.0000000000, 8.0000000000, 1748.0000000000, 1748.0000000000, 1748.0000000000, 1748.0000000000, 1748.0000000000, 1388.0000000000, 788.0000000000, 500.0000000000, 96.0000000000, 96.0000000000, 264.0000000000, 168.0000000000, 24.0000000000, 600.0000000000, 192.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 96.0000000000, 0.0000000000, 0.0000000000, 96.0000000000, 144.0000000000, 24.0000000000, 600.0000000000, 192.0000000000, 0.0000000000, -0.0000000000, -0.0000000000, -0.0000000000, -0.0000000000, -0.0000000000, -0.0000000000, -0.0000000000, -0.0000000000, -0.0000000000, -0.0000000000, -0.0000000000, 0.0000000000, -0.0000000000, -0.0000000000, -0.0000000000, -0.0000000000, -0.0000000000, -0.0000000000, -0.0000000000, -0.0000000000, -0.0000000000, -0.0000000000, -0.0000000000, -0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 4.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000, 0.9286200000, 0.0119200000, 1.0535700000, 0.2201700000, 0.2285000000, 1.8746200000, 0.8137700000, 1.9647600000, 1.9760600000, 1.9930100000, 0.9502000000, 1.9774000000, 4055.1500000000, };
double lhs, s[2];
struct Row cut;
LP_init_row(&cut, CG_total_nz(&tableau));
rval = INFINITY_generate_cut(&tableau, &cut);
abort_if(rval, "INFINITY_generate_cut failed");
rval = get_lattice_point(&tableau, x, s);
abort_if(rval, "get_lattice_point failed");
for(int i = 0; i < tableau.nrows; i++)
log_debug("s[%d] = %20.12lf\n", i, s[i]);
lhs = CG_replace_x(&cut, x);
EXPECT_LE(lhs, cut.pi_zero);
CLEANUP:
if (rval) FAIL();
}