From 9a49c64ee5b5d7d249904b46f2e86abb1c8aeff5 Mon Sep 17 00:00:00 2001 From: DylanVsn <43576618+DylanVsn@users.noreply.github.com> Date: Tue, 22 Oct 2019 12:34:33 +0200 Subject: [PATCH] travail courant --- Readme.md | 1 + a.out | Bin 0 -> 13424 bytes makefile | 8 +++ test | Bin 0 -> 21344 bytes test.c | 168 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ test.h | 8 +++ 6 files changed, 185 insertions(+) create mode 100644 Readme.md create mode 100755 a.out create mode 100644 makefile create mode 100755 test create mode 100755 test.c create mode 100644 test.h diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/Readme.md @@ -0,0 +1 @@ + diff --git a/a.out b/a.out new file mode 100755 index 0000000000000000000000000000000000000000..174560b8105bdd986e4c1b7b8f11b6e87dd339d3 GIT binary patch literal 13424 zcmeHNeQ;dWb-&U|vTWqlTK+&WCf*u56~ zt{lljV^JZ-8%4yWG2?V#>dU%)9IhNnz!ek-}$)T_q}^{_BFS*6c-f{A?9f;%UGL4Ms{TSzZXdOco;HQ&(#5|QMm$Pkn<~$#Up%TmnDRK>90|9tTXS`QkI3tLk5g@B6`} zcp1q)kB7%?f7)9lN*ZPo=EbuFPh;~hFZ}q;#~(WL;EqNAH2S{#x4(GL4Y*(`hNG$i zl1gCS0(cBqA^n#e@bwPYFC6eT2Yk1K|9c&9)4|V|9Q1F4z86n^ay#h%18|yi`DqY9q5gcx!OsB){p%d` ze*@ejt`+mVURY++hZ3(A)p_`D6`rsE2Jk9zjW~Qw)(7RzNW4;%ROjLX>$@w`yPH<@ znp$CQYTIlEL-9~oIFSs++cs~E#G;|LKzk%4OtY&e7Bv&eKs;%hmTEyo_%p-NWUMzS zD4Pf+%~<;bW-uJL`Hon`j0So_66lDB0?Cls8;`Y1z6%EN*w@TpUm#)wWYHTB_edZT z3k1!cKr$Zgmpm0g3cJJ6pag=UNJw`X2nIRYL5mjXXF_g7Sj{%mG#)8Do)y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j#)_WFtsFHbKa5C^8q%X>WN3}59BM7=S|Gs54(f3X`{58MJx<6p5oN{m zibmNnrpk^?$_)dW-mXFcRUBkQ?Vc83#TAxePQsTM=t&0JL6dQdc5@D`4#j(gFB(gR zeE!BwE0cjP#dSsdeC>TfL^u}BVNA&4p-6xX zRIWFY6h1kEK4g7eF|f%{KYnF&lP?~Vflar_I%!Ax|9_a&9`p?j_dOnm(S-iruE8>?=jRd-uAi$IXVilJ>P3EHSj*5ME4%l zPi)V}n|pwf3fuEN2~)lofr?DzLr?dEp*sh*=kp*_`p&1s^=Cb%yCI`H4CeXV$dvEL z^Xo62;%6@&>QlDo^Ci_l zWvV{QEFpfWEIp;b==OZBWh(ESH3Pb*rNs2x$m{le{$eskR|3+wk# ejYa<=Psru6E**RFRHW!8Dh%nWMeN^v`~L-wVC>HT literal 0 HcmV?d00001 diff --git a/makefile b/makefile new file mode 100644 index 0000000..5a05d84 --- /dev/null +++ b/makefile @@ -0,0 +1,8 @@ +CC=gcc +OPT=-Wall -std=c11 -g +LIB=-lglpk + +all: test + +test: test.c test.h + $(CC) $< $(OPT) $(LIB) -o $@ \ No newline at end of file diff --git a/test b/test new file mode 100755 index 0000000000000000000000000000000000000000..1bbbf92c6c6354e5a082b0b6d333ec99128440d2 GIT binary patch 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$)#7xlITW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o3n#adXQ`?s0`6V;7S+{WAdE~Mt`7sNuV`A= z5@@+}6<-#RZHX1es%tN8TGzTVTO!{r00@`9ffm2=;9qrx2wbxEvgW3>fy-8}zOrRQ zU_(Nqf+yLL$sCTz>Py1hbw}F070be38X|KQeRsnObzqy${ zdz*fyyn4%m2$#reSAIs$`dG`9F9?{loj+S2J&YavdhdSr%NQoDx#-+{=>aSgu|QWa z8scjlc%je5SAf^=W-YQ`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 literal 0 HcmV?d00001 diff --git a/test.c b/test.c new file mode 100755 index 0000000..48c3132 --- /dev/null +++ b/test.c @@ -0,0 +1,168 @@ +/* short.c */ + +#include /* C input/output */ +#include /* C standard library */ +#include /* GNU GLPK linear/mixed integer solver */ +#include "test.h" + +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); + + add_column2(sous_prob, y1); + add_column2(sous_prob, y2); + add_column2(sous_prob, y3); + add_column2(sous_prob, y4); + 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 k = 4; + int nb_coeffs = 4; + double y1, y2, y3, y4; + int *a, z_cost; + do { + + glp_load_matrix(lp, 4, ia, ja, ar); + printf("k=%d\n", k); + /* 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) { + k = add_column(lp, 1.0); + ia[++nb_coeffs] = 1, ja[nb_coeffs] = k, ar[nb_coeffs] = a[1]; /* a[k,1] = a[1] */ + ia[++nb_coeffs] = 2, ja[nb_coeffs] = k, ar[nb_coeffs] = a[2]; /* a[k,2] = a[2] */ + ia[++nb_coeffs] = 3, ja[nb_coeffs] = k, ar[nb_coeffs] = a[3]; /* a[k,3] = a[3] */ + ia[++nb_coeffs] = 4, ja[nb_coeffs] = k, ar[nb_coeffs] = a[4]; /* a[k,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; +} + + +int add_column(glp_prob *lp, float coef) { + static int num = 1; + glp_add_cols(lp, 1); + char name[10] = ""; + snprintf(name, sizeof name, "rouleau%d", num); + glp_set_col_name(lp, num, name); + glp_set_col_bnds(lp, num, GLP_LO, 0.0, 0.0); + glp_set_obj_coef(lp, num, coef); + + num++; + return num; +} + +int add_column2(glp_prob *lp, float coef) { + static int num = 1; + glp_add_cols(lp, 1); + char name[10] = ""; + snprintf(name, sizeof name, "rouleau%d", num); + glp_set_col_name(lp, num, name); + glp_set_col_bnds(lp, num, GLP_LO, 0.0, 0.0); + glp_set_obj_coef(lp, num, coef); + + num++; + return num; +} + +int main(void) { + perfect_rolls(); + return 0; +} diff --git a/test.h b/test.h new file mode 100644 index 0000000..fdcc787 --- /dev/null +++ b/test.h @@ -0,0 +1,8 @@ +#ifndef GLPK +#define GLPK +#include /* GNU GLPK linear/mixed integer solver */ +#endif + +int *column_generator(); +int add_column(glp_prob *lp, float coef); +int add_column2(glp_prob *lp, float coef); \ No newline at end of file