ajout de l'utilisation des y1, y2... mais du coup faut corriger les erreurs parce que je suis un sgueg mdr

This commit is contained in:
MathieuPietri 2019-10-23 15:12:43 +02:00
parent b56464f954
commit aae7a4d58b
3 changed files with 13 additions and 13 deletions

View File

@ -47,7 +47,7 @@ int perfect_rolls() {
}
int nb_coeffs = 4;
double y1, y2, y3, y4;
double y[4] = {0};
int a[5] = {0};
glp_smcp params = {0};
glp_init_smcp(&params);
@ -64,13 +64,13 @@ int perfect_rolls() {
/* solve problem */
glp_simplex(lp, &params);
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);
y[0] = glp_get_row_dual(lp, 1);
y[1] = glp_get_row_dual(lp, 2);
y[2] = glp_get_row_dual(lp, 3);
y[3] = glp_get_row_dual(lp, 4);
puts("Résolution du sous-problème.");
column_generator(y1, y2, y3, y4, a);
column_generator(y, a);
if (a[0] > 1) {
printf(" Valeur de lobjectif : %d\n", a[0]);
fputs(" On ajoute : ", stdout);

View File

@ -4,18 +4,18 @@
#include <glpk.h>
static void add_column_sp(glp_prob *lp, int *num_col_sp) {
static void add_column_sp(glp_prob *lp, int *num_col_sp, int coeff) {
glp_add_cols(lp, 1);
char name[10] = "";
snprintf(name, sizeof name, "rouleau%d", *num_col_sp);
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);
glp_set_obj_coef(lp, *num_col_sp, coeff);
(*num_col_sp)++;
}
void column_generator(int y1, int y2, int y3, int y4, int a[static 5]) {
void column_generator(double y[static 4], int a[static 5]) {
glp_prob *sous_prob;
int ia[1 + 1000];
int ja[1 + 1000];
@ -28,15 +28,15 @@ void column_generator(int y1, int y2, int y3, int y4, int a[static 5]) {
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_add_rows(sous_prob, 1);
glp_set_row_name(sous_prob, 1, "somme<=100");
glp_set_row_bnds(sous_prob, 1, GLP_UP, 0.0, 100.0);
int 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, &num_col_sp);
add_column_sp(sous_prob, &num_col_sp, y[i-1]); //on prend y1, y2, y3 puis y4 (stockés dans y[0], y[1]...)
glp_set_col_kind(sous_prob, i, GLP_IV);
ia[i] = 1;
ja[i] = i;

View File

@ -2,7 +2,7 @@
#define SUB_H
void column_generator(int y1, int y2, int y3, int y4, int a[static 5]);
void column_generator(double y[static 4], int a[static 5]);
#endif