From 9cb04f58bdd3b23a7d76bba8a5f5f1bcf4ada505 Mon Sep 17 00:00:00 2001 From: papush! Date: Tue, 22 Oct 2019 20:05:01 +0200 Subject: [PATCH] TA GUEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEUUUUUUULE --- src/master.c | 25 +++++++++++++++---------- src/sub.c | 11 +++++++++-- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/master.c b/src/master.c index 7c49bd4..b092da8 100644 --- a/src/master.c +++ b/src/master.c @@ -50,6 +50,9 @@ int perfect_rolls() { int nb_coeffs = 4; double y1, y2, y3, y4; int a[4] = {0}; + glp_smcp params = {0}; + glp_init_smcp(¶ms); + params.msg_lev = GLP_MSG_OFF; while (1) { /* printf("nb_coeffs=%d\n", nb_coeffs); */ /* for (int i = 0; i < nb_coeffs + 4; i++) { */ @@ -61,19 +64,21 @@ int perfect_rolls() { printf("col_num=%d\n", col_num); /* solve problem */ - glp_prob *tmp_prob = glp_create_prob(); - glp_copy_prob(tmp_prob, lp, GLP_ON); - glp_simplex(tmp_prob, NULL); - y1 = glp_get_row_dual(tmp_prob, 1); - y2 = glp_get_row_dual(tmp_prob, 2); - y3 = glp_get_row_dual(tmp_prob, 3); - y4 = glp_get_row_dual(tmp_prob, 4); + glp_simplex(lp, ¶ms); + y1 = glp_get_row_dual(lp, 1); + y2 = glp_get_row_dual(lp, 2); + y3 = glp_get_row_dual(lp, 3); + y4 = glp_get_row_dual(lp, 4); column_generator(y1, y2, y3, y4, a, num_col_sp); if (a[0] > 1) { - /* for (int i = 1; i <= 4; i++) { */ - /* printf("a[%d]=%d\n", i, a[i]); */ - /* } */ + fputs("Après résolution du sous-problème, on ajoute : ", stdout); + int i = 1; + for (i = 1; i < 4; i++) { + printf("%d, ", a[i]); + } + printf("%d\n", a[i]); + add_column(lp, 1.0); for (int i = 1; i < 5; i++) { /* a[col_num, i] = a[i] */ diff --git a/src/sub.c b/src/sub.c index fef9d22..e172da0 100644 --- a/src/sub.c +++ b/src/sub.c @@ -45,8 +45,15 @@ void column_generator(int y1, int y2, int y3, int y4, int a[static 4], int num_c glp_load_matrix(sous_prob, 4, ia, ja, ar); /* solve problem */ - glp_simplex(sous_prob, NULL); - glp_intopt(sous_prob, NULL); + glp_smcp params = {0}; + glp_init_smcp(¶ms); + params.msg_lev = GLP_MSG_OFF; + glp_iocp iocp = {0}; + glp_init_iocp(&iocp); + iocp.msg_lev = GLP_MSG_OFF; + + glp_simplex(sous_prob, ¶ms); + glp_intopt(sous_prob, &iocp); a[0] = glp_get_obj_val(sous_prob); a[1] = glp_mip_col_val(sous_prob, 1);