Hello Fernando, the API of GLPK is described in doc/glpk.pdf of the GLPK source which is available at http://ftp.gnu.org/gnu/glpk/glpk-4.56.tar.gz
The function to retrieve column values (i.e. the values of the variables) of a mixed integer model (after solving the problem with glp_intopt) is glp_mip_col_val. Best regards Heinrich Schuchardt On 29.10.2015 10:18, Andrew Makhorin wrote: > -------- Forwarded Message -------- > From: Fernando Garcia <[email protected]> > To: [email protected] > 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_read_lp(lp3,0,"2_Node_Example_Investment_MIP2.lp"); > glp_create_index(lp3); > > > glp_iocp parm3; > > > //Solving the problem > glp_init_iocp(&parm3); > 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(G%d.c%d.ss%d)", 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); > > printf("print:obj:%g\n",z3); > > > printf("print:status:%i\n",state); > > > printf("print:status:%s\n",buffer); > > > printf("print:status:%i\n",j1); > > > > > > > > > > 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, > > > Fernando _______________________________________________ Help-glpk mailing list [email protected] https://lists.gnu.org/mailman/listinfo/help-glpk
