[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-glpk] [Fwd: GLPK packet]

From: Andrew Makhorin
Subject: [Help-glpk] [Fwd: GLPK packet]
Date: Thu, 29 Oct 2015 12:18:48 +0300

-------- Forwarded Message --------
From: Fernando Garcia <address@hidden>
To: address@hidden
Subject: GLPK packet
Date: Thu, 29 Oct 2015 09:48:34 +0100

Good morning,

My name is Fernando Garcia. First at all, congratulations for the
development of this solver.

I have one doubt with the use of the packet "glpk.h" in C++. I want to
solve a problem that is included in "2_Node_Example_Investment_MIP2.lp"
and then show in the screen the value of the variables obtained. My
variables are of the type
"z_init(G1.c1.ss1)","z_init(G2.c1.ss1)","z_init(G1.c1.ss3)", etc, so I
created this small c++ file:

#define _GNU_SOURCE
#include <string.h> 
#include <stdio.h>
#include <stdlib.h>
#include <omp.h> 
#include <glpk.h>
#include <math.h>

#define G 6 
#define c 1
#define ss 3
int main(int argc, char** argv)

int n,i,i1,i2,i3;
int j,j1,j2;
char buffer [50];
int state[G][c][ss];
int status3;
double z3;
int x;

int err;

glp_prob *lp3;

lp3 = glp_create_prob();

glp_iocp parm3;
//Solving the problem
parm3.presolve = GLP_ON;
err = glp_intopt(lp3, &parm3);

for (i1=0; i1 < G; i1++)
  for (i2=0; i2 < c; i2++)
     for (i3=0; i3 < ss; i3++){
      sprintf (buffer, "z_init(", i1+1,i2+1,i3+1);
      j1=glp_find_col(lp3, buffer);
      glp_set_col_bnds(lp3, j1, GLP_FX, state[i1][i2][i3], 0);


z3 = glp_mip_obj_val(lp3);
status3 = glp_mip_status(lp3);

printf("print:LinearNE3 status:%d\n",status3);





 return 0;

I want to save that variables "z_init(G1.c1.ss1)", etc in the parameter
"state[G][c][ss]". Could you tell me how to do it?

I was expecting some function in the packet "glpk.h" as "Fix the value
obtained in the solver into this new parameter", but I couldn't find
something similar in the manual.

Thanks for your help,


reply via email to

[Prev in Thread] Current Thread [Next in Thread]