Hello,

I am facing what seems to be like a strange issue with my use of
glp_write_mincost, and have been breaking my head over it for over a day
now.

I create a custom graph (i.e. i don't use glp_read_mincost but do
glp_create_graph and use glp_add_vertices and glp_add_arc).

I have initialized all the arc bounds to be [0,1] and costs to be 0.
When I print this data using the below code, all the bounds and the costs
are correct and as initialized.

  glp_arc* arcTmp;
  glp_vertex* w;
  //printf("Arc bounds: %d\n", arc(arcTmp)->a_uppBndCap);

  for (int i=1; i<=G->nv; i++)
    {
      printf("Supply of %d: %d\n", G->v[i]->i, vertex(G->v[i])->supply);
      arcTmp = G->v[i]->out;
      for (; arcTmp != NULL;  arcTmp = arcTmp->t_next)
{
  w = arcTmp->head;
  printf("Arc Details: %d -> %d, Low: %d, Upp: %d, Cost: %f\n",G->v[i]->i,
w->i, arc(arcTmp)->a_lowBndCap, arc(arcTmp)->a_uppBndCap,
arc(arcTmp)->a_cost);
}
    }

arc is the #define as given in the documentation:
#define arc(a) ((a_data *)((a)->data))

However, when I do glp_write_mincost immediately after the above
code-snippet:

glp_write_mincost(G, offsetof(v_data, supply), offsetof(a_data,
a_lowBndCap), offsetof(a_data, a_uppBndCap), offsetof(a_data, a_cost),
fileName);

the file `fileName' has all garbled up arc costs and node supplies.
Example:
c MinCostNetworkGraph
p min 12 15
n 1 9.88131291682493e-324 <- supply should have been 2 for the first node
n 2 2.12199579096527e-314 <- supply should have been 0 for the second node
.
.
.
a 1 3 2.12199579096527e-314 4.94065645841247e-324 0 <-- lower bound is
always 0 and upper bound is always 1
a 1 2 2.12199579096527e-314 4.94065645841247e-324 0
.
.
.
c eof


I tried writing down the LP by using glp_mincost_lp, but that gives the same
screwed up values.
Please advise.

I can send the code files if required.

Thanks,
Manish
University of Southern California
_______________________________________________
Help-glpk mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-glpk

Reply via email to