Hello Francesco,
a bus error is created when a program tries to access a memory
address that is not assigned to the program and this error
is detected by the hardware. If the error is detected by software
it is called a segmentation fault.
The function
void glp_analyze_bound(glp_prob *P, int k, double *limit1,
int *var1, double *limit2, int *var2);
does not return pointers limit1, var1, ... but writes to the
memory locations to which the pointers your program provides
point.
Hence you either have to use malloc to allocate the memory, e.g.
limit1 = (double *) malloc(sizeof(double));
or you pass the address of variable like in the example below:
#include "glpk.h"
#include <stdio.h>
int main(int argc, const char *argv[]) {
double limit1;
double limit2;
int var1, var2;
printf("%s\n", argv[1]);
glp_prob *GLV;
GLV = glp_create_prob();
glp_read_mps(GLV, GLP_MPS_FILE, NULL,argv[1]);
glp_adv_basis(GLV, 0);
glp_simplex(GLV, NULL);
glp_print_sol(GLV, "GLV_SOL.dat");
glp_analyze_bound(GLV, 3, &limit1, &var1, &limit2, &var2);
printf("limit1 %f, var1 %i, limit2 %f, var2 %i\n",
limit1, var1, limit2, var2);
glp_delete_prob(GLV);
}
to compile use
gcc example.c -lglpk -o example
Then call the program with a valid MPS file name. I used
example glpk-4.44/examples/samp1.mps
Best regards
Xypron
-------- Original-Nachricht --------
Datum: Tue, 29 Jun 2010 17:03:47 +0400
Von: frnz65 <address@hidden>
An: address@hidden
Betreff: Re: [Help-glpk] glp_analyze_bound
Andrew Makhorin wrote:
I'm trying to use glp_analyze_bound:
double *limit1;
double *limit2;
int *var1, *var2;
glp_prob *GLV;
GLV = glp_create_prob();
glp_read_mps(GLV, GLP_MPS_FILE, NULL, mpscardfile);
glp_adv_basis(GLV, 0);
glp_simplex(GLV, NULL);
glp_print_sol(GLV, "../out/GLV_SOL.dat"); // write the
results in
this
file
glp_analyze_bound(GLV, 473, limit1, var1, limit2, var2);
but I do get a bus error when I use glp_analyze_bound.
...
--
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01