From 347da4f10da3f374c483ca4ca848442bd72f20d9 Mon Sep 17 00:00:00 2001 From: COLIN Cyril Date: Tue, 22 Oct 2019 13:58:46 +0200 Subject: [PATCH] nettoyage --- makefile | 2 +- test | Bin 21344 -> 0 bytes test.c | 267 +++++++++++++++++++++++++++---------------------------- test.h | 8 -- 4 files changed, 131 insertions(+), 146 deletions(-) delete mode 100755 test delete mode 100644 test.h diff --git a/makefile b/makefile index 5a05d84..c322fb5 100644 --- a/makefile +++ b/makefile @@ -5,4 +5,4 @@ LIB=-lglpk all: test test: test.c test.h - $(CC) $< $(OPT) $(LIB) -o $@ \ No newline at end of file + $(CC) $< $(OPT) $(LIB) -o $@ diff --git a/test b/test deleted file mode 100755 index 1bbbf92c6c6354e5a082b0b6d333ec99128440d2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 21344 zcmeHPeRx#WnLqQ9Fhjy5kOYDs>!@H+VUj?A_yHt=;DmyrqE#vmlguO;NoLadz+l}4 z4WUe9Ec6k}s(noDuIu{r!@67R)@q}6MYp>y)>>(6pT!T_gj!8OE%ht=`<;8voja46 zR-dPTa*~<%yubJ3ob#S@&%Ni)J$HM{+SPWOP3Yth%LTdNX$I1$1c%qC3`nDB5N>>* zCC(JZ;GGgPXjKyYgr+r21T_Ut4F&N%I<`+(^RPXYpUDFw(+w;$#dx{$e1*xF4OuW$q@6y zs^PixI;kaurrPdu*s-3UG?gpGD^z)f;!>^Rp{eeNn(j#3lKPtN(1PwrG}X7DuVKl8 zCH1~U%(qasoBpYL$)#7xlITWs_y&&pK>zXP9q@w~Z!pFIWi zPc5K72E1I%64kX{SZ30P60a8C9DH2ix%#h5|0Uv3NyZ0rzma&E2%VaZ3mo^I-Mw3Q zq}SJqKiy8te&6pgkTACc}Z=c&ttGoiK>UZVZG{!EO_vMQ=RP zBZ2N%FcjzsCgYJl$+HM5Y>7le5(tI6!&aBUP>2c%Q=5flYLJNZ^md00UmfvqI1r9* zHC0&^v#z?NwrI$3M$gb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`h``qpFc$KS3zpEzR|yy|Bgn2?_L_>N=f0!C`bq}tTL|Pr zA+w&96~aO=_w5np8xsn?Q$fF9!uk@1Kmf0>&|{GAwkY_*3iGuO+3#4$ZYA55?`;+O z4Gxq~dV7VgupC#ym)O>WWgloVZqP2BL#xB_Ug3*k;pS^VNCTDY?M@1x>`x!EzRnofBv*(& z`PK+uJSJZl;R|=E8K5f!Cz>-%jj6z}(0P;)?1{9aPJG{l53idLK1@Tr#Q`kbmg6okdD83g;cvy-UazZ7 zs+4v8wVtM1Am?w-n%C=ZO>32XZv7Q3ZbF7J)%JRwZc?SF%g=59PG#S$^z`rRnqH$E z)1EI0$hE&67~{(NG3n4e*QvJw^md%xBdUB>~;U?`xlzl=CoheTe~&Zo0b|a?9uXlSSzA&HEwhmH_voSW|BK{LPk2Z*`cN_f7Qs+H&>! zp=Px=*K@Uoy`EnNak0V20x_o_|U#;wQIa)ubI^tajh$(fghV_Dx)$1lL(Ds^s z41vyT9nzJ`KG$!q?lb_o80{0vut*1;m?EOALKJEnrPKtoTd;`*Ge#LgM@0 ztSN^Ti;R%#wQmVzF**kEea1mFd`5Fg#2dR$PPQv?vqqb-t% ZXLE$QTtmvWe17}kRzqWXjzJD9{vTM6wM_s3 diff --git a/test.c b/test.c index 4e5f466..eec76a3 100755 --- a/test.c +++ b/test.c @@ -3,145 +3,12 @@ #include /* C input/output */ #include /* C standard library */ #include /* GNU GLPK linear/mixed integer solver */ +#include #include "test.h" + + int col_num = 1; int num_col_sp = 1; -int *column_generator(int y1, int y2, int y3, int y4) { - - glp_prob *sous_prob; - int ia[1 + 1000], ja[1 + 1000]; - double ar[1 + 1000], z, x1, x2, x3, x4; - /* create problem */ - sous_prob = glp_create_prob(); - glp_set_prob_name(sous_prob, "rouleaux-parfaits"); - glp_set_obj_dir(sous_prob, GLP_MAX); - /* fill problem */ - glp_add_rows(sous_prob, 4); - glp_set_row_name(sous_prob, 1, "taille0"); - glp_set_row_bnds(sous_prob, 1, GLP_UP, 0.0, 100.0); - - num_col_sp = 1; - add_column_sp(sous_prob); - add_column_sp(sous_prob); - add_column_sp(sous_prob); - add_column_sp(sous_prob); - glp_set_col_kind(sous_prob, 1, GLP_IV); - glp_set_col_kind(sous_prob, 2, GLP_IV); - glp_set_col_kind(sous_prob, 3, GLP_IV); - glp_set_col_kind(sous_prob, 4, GLP_IV); - - ia[1] = 1, ja[1] = 1, ar[1] = 45.0; /* a[1,1] = a1 * 45 */ - ia[2] = 1, ja[2] = 2, ar[2] = 36.0; /* a[1,2] = a2 * 36 */ - ia[3] = 1, ja[3] = 3, ar[3] = 31.0; /* a[1,3] = a3 * 31 */ - ia[4] = 1, ja[4] = 4, ar[4] = 14.0; /* a[1,4] = a4 * 14 */ - glp_load_matrix(sous_prob, 4, ia, ja, ar); - - /* solve problem */ - - glp_simplex(sous_prob, NULL); - glp_intopt(sous_prob, NULL); - - int *a = malloc(sizeof (int) * 5); - - a[0] = glp_get_obj_val(sous_prob); - a[1] = glp_mip_col_val(sous_prob, 1); - a[2] = glp_mip_col_val(sous_prob, 2); - a[3] = glp_mip_col_val(sous_prob, 3); - a[4] = glp_mip_col_val(sous_prob, 4); - - printf("a1 = %d; a2 = %d; a3 = %d; a4 = %d\n", a[1], a[2], a[3], a[4]); - /* housekeeping */ - glp_delete_prob(sous_prob); - glp_free_env(); - - return a; - //glp_intopt(glp_prob *mip, const glp_iocp *parm); - -} - -int perfect_rolls() { - /* declare variables */ - glp_prob *lp; - int ia[1 + 1000], ja[1 + 1000]; - double ar[1 + 1000], z, x1, x2, x3, x4; - /* create problem */ - lp = glp_create_prob(); - glp_set_prob_name(lp, "rouleaux-parfaits"); - glp_set_obj_dir(lp, GLP_MIN); - /* fill problem */ - glp_add_rows(lp, 4); - glp_set_row_name(lp, 1, "taille0"); - glp_set_row_bnds(lp, 1, GLP_LO, 97.0, 0.0); - glp_set_row_name(lp, 2, "taille1"); - glp_set_row_bnds(lp, 2, GLP_LO, 610.0, 0.0); - glp_set_row_name(lp, 3, "taille2"); - glp_set_row_bnds(lp, 3, GLP_LO, 395.0, 0.0); - glp_set_row_name(lp, 4, "taille3"); - glp_set_row_bnds(lp, 4, GLP_LO, 211.0, 0.0); - - add_column(lp, 1.0); - add_column(lp, 1.0); - add_column(lp, 1.0); - add_column(lp, 1.0); - - ia[1] = 1, ja[1] = 1, ar[1] = 1.0; /* a[1,1] = 1 */ - ia[2] = 2, ja[2] = 2, ar[2] = 1.0; /* a[2,2] = 1 */ - ia[3] = 3, ja[3] = 3, ar[3] = 1.0; /* a[3,3] = 1 */ - ia[4] = 4, ja[4] = 4, ar[4] = 1.0; /* a[4,4] = 1 */ - - - - int nb_coeffs = 4; - double y1, y2, y3, y4; - int *a, z_cost; - do { - printf("nb_coeffs=%d\n", nb_coeffs); - for (int i = 0; i < nb_coeffs + 4; i++) { - printf("ar[%d]=%g\n", i, ar[i]); - } - printf("\n"); - - glp_load_matrix(lp, nb_coeffs, ia, ja, ar); - printf("col_num=%d\n", col_num); - /* solve problem */ - glp_simplex(lp, NULL); - 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); - printf("z = %g; y1 = %g; y2 = %g; y3 = %g; y4 = %g\n", z, y1, y2, y3, - y4); - a = column_generator(y1, y2, y3, y4); - z_cost = a[0]; - if (z_cost > 1) { - for (int i = 1; i <= 4; i++) - printf("a[%d]=%d\n", i, a[i]); - add_column(lp, 1.0); - ia[++nb_coeffs] = 1, ja[nb_coeffs] = col_num-1, ar[nb_coeffs] = (double) a[1]; /* a[col_num,1] = a[1] */ - ia[++nb_coeffs] = 2, ja[nb_coeffs] = col_num-1, ar[nb_coeffs] = (double) a[2]; /* a[col_num,2] = a[2] */ - ia[++nb_coeffs] = 3, ja[nb_coeffs] = col_num-1, ar[nb_coeffs] = (double) a[3]; /* a[col_num,3] = a[3] */ - ia[++nb_coeffs] = 4, ja[nb_coeffs] = col_num-1, ar[nb_coeffs] = (double) a[4]; /* a[col_num,4] = a[4] */ - } - free(a); - } while (z_cost > 1); - - - /* recover and display results */ - z = glp_get_obj_val(lp); - x1 = glp_get_col_prim(lp, 1); - x2 = glp_get_col_prim(lp, 2); - x3 = glp_get_col_prim(lp, 3); - x4 = glp_get_col_prim(lp, 4); - printf("z = %g; x1 = %g; x2 = %g; x3 = %g; x4 = %g\n", z, x1, x2, x3, - x4); - - - /* housekeeping */ - glp_delete_prob(lp); - glp_free_env(); - - return z; -} void add_column(glp_prob *lp, float coef) { @@ -162,10 +29,136 @@ void add_column_sp(glp_prob *lp) { glp_set_col_name(lp, num_col_sp, name); glp_set_col_bnds(lp, num_col_sp, GLP_LO, 0.0, 0.0); glp_set_obj_coef(lp, num_col_sp, 1.0); - num_col_sp++; } +void column_generator(int y1, int y2, int y3, int y4, int a[static 4]) { + glp_prob *sous_prob; + int ia[1 + 1000]; + int ja[1 + 1000]; + double ar[1 + 1000]; + /* double z, x1, x2, x3, x4; */ + + /* create problem */ + sous_prob = glp_create_prob(); + glp_set_prob_name(sous_prob, "rouleaux-parfaits"); + glp_set_obj_dir(sous_prob, GLP_MAX); + + /* fill problem */ + glp_add_rows(sous_prob, 4); + glp_set_row_name(sous_prob, 1, "taille0"); + glp_set_row_bnds(sous_prob, 1, GLP_UP, 0.0, 100.0); + + num_col_sp = 1; + + const double coeffs[] = {45.0, 36.0, 31.0, 14.0}; + for (int i = 1; i < 5; i++) { + add_column_sp(sous_prob); + glp_set_col_kind(sous_prob, i, GLP_IV); + ia[i] = 1; + ja[i] = i; + ar[i] = coeffs[i]; + } + glp_load_matrix(sous_prob, 4, ia, ja, ar); + + /* solve problem */ + glp_simplex(sous_prob, NULL); + glp_intopt(sous_prob, NULL); + + a[0] = glp_get_obj_val(sous_prob); + a[1] = glp_mip_col_val(sous_prob, 1); + a[2] = glp_mip_col_val(sous_prob, 2); + a[3] = glp_mip_col_val(sous_prob, 3); + a[4] = glp_mip_col_val(sous_prob, 4); + + printf("a1 = %d; a2 = %d; a3 = %d; a4 = %d\n", a[1], a[2], a[3], a[4]); + /* housekeeping */ + glp_delete_prob(sous_prob); + glp_free_env(); + //glp_intopt(glp_prob *mip, const glp_iocp *parm); + +} + +int perfect_rolls() { + /* declare variables */ + glp_prob *lp; + int ia[1 + 1000] = {0}, ja[1 + 1000] = {0}; + double ar[1 + 1000] = {0}, z, x1, x2, x3, x4; + /* create problem */ + lp = glp_create_prob(); + glp_set_prob_name(lp, "rouleaux-parfaits"); + glp_set_obj_dir(lp, GLP_MIN); + /* fill problem */ + glp_add_rows(lp, 4); + + char name[8] = ""; + const double bounds[4] = {97, 610, 395, 211}; + for (int i = 1; i < 5; i++) { + snprintf(name, sizeof name, "taille%d", i); + glp_set_row_name(lp, 1, name); + glp_set_row_bnds(lp, 1, GLP_LO, bounds[i-1], 0.0); + add_column(lp, 1.0); + ia[i] = i; + ja[i] = i; + ar[i] = 1; + } + + int nb_coeffs = 4; + double y1, y2, y3, y4; + int a[4] = {0}; + while (1) { + printf("nb_coeffs=%d\n", nb_coeffs); + for (int i = 0; i < nb_coeffs + 4; i++) { + printf("ar[%d]=%g\n", i, ar[i]); + } + printf("\n"); + + glp_load_matrix(lp, nb_coeffs, ia, ja, ar); + 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); + + column_generator(y1, y2, y3, y4, a); + if (a[0] > 1) { + for (int i = 1; i <= 4; i++) { + printf("a[%d]=%d\n", i, a[i]); + } + add_column(lp, 1.0); + for (int i = 1; i < 5; i++) { + /* a[col_num, i] = a[i] */ + nb_coeffs++; + ia[nb_coeffs] = i; + ja[nb_coeffs] = col_num-1; + ar[nb_coeffs] = a[i]; + } + } + else { + break; + } + } + + /* recover and display results */ + z = glp_get_obj_val(lp); + x1 = glp_get_col_prim(lp, 1); + x2 = glp_get_col_prim(lp, 2); + x3 = glp_get_col_prim(lp, 3); + x4 = glp_get_col_prim(lp, 4); + printf("z = %g; x1 = %g; x2 = %g; x3 = %g; x4 = %g\n", z, x1, x2, x3, x4); + + /* housekeeping */ + glp_delete_prob(lp); + glp_free_env(); + + return z; +} + int main(void) { perfect_rolls(); return 0; diff --git a/test.h b/test.h deleted file mode 100644 index 02a980b..0000000 --- a/test.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef GLPK -#define GLPK -#include /* GNU GLPK linear/mixed integer solver */ -#endif - -int *column_generator(); -void add_column(glp_prob *lp, float coef); -void add_column_sp(glp_prob *lp); \ No newline at end of file