On 8/15/21 4:06 PM, Domingo Alvarez Duarte wrote:
Comparing how AMPL and GMPL calculate random expressions I found
some of
then where they differ or GMPL can't manage see bellow, also one of
then
that references itself makes glpsol segfault but ampl gives an error
I can't see a segfault with GLPK 5.0.
Please, use gdb to identify in which line of code it occurs:
gdb --args glpk -m test.od
message explaining the problem:
====
param a0 := (((((((788)*(8.46))))+8342*1.803-1))*4186.4*(15));
printf "%f\n", a0;
param a1 := (((22 mod 284/((7530/((2)*(((((25))-421))))))*597 mod
2663)+7283.8-9.60+167 mod ((3))))+(8871);
printf "%f\n", a1;
#param a2 := a1 * a2; #glpsol segfault
param a2 := a0 * a1;
printf "%f\n", a2;
param a = (((((((788)*(8.46))))+8342*1.803-1))*4186.4*(15))*(((22 mod
Your syntax is wrong. This should be:
param a :=
With correct syntax:
glpsol -m /tmp/test.mod
GLPSOL: GLPK LP/MIP Solver, v4.65
Parameter(s) specified in the command line:
-m /tmp/test.mod
Reading model section from /tmp/test.mod...
28 lines were read
1363056632.376000
17428.775299
23756407765226.851562
11664732388290.359375
11665910614443.386719
8259816920615.111328
8259816920615.111328
Model has been successfully generated
Best regards
Heinrich
284/((7530/((2)*(((((25))-421))))))*597 mod 2663)+7283.8-9.60+167 mod
((3))))+(8871);
#param a := 3+2;
printf "%f\n", a;
param b = (((((((788)*(8.46))))+8342*1.803-1))*4186.4*(15))*(((22 mod
284/((7530/((2)*(((((25))-421))))))*597 mod 2663)+7283.8-9.60+167.8644
mod ((3))))+(8871);
#param a := 3+2;
printf "%f\n", b;
param c =
(((((((788)*(8.46))))+8342*1.803-1))*4186.4*(15))*(((22/((7530/((2)*(((((25))-421))))))*597)+7283.8-9.60+167))+(8871);
#param a := 3+2;
printf "%f\n", c;
param d =
(((((((788.0)*(8.46))))+8342.0*1.803-1.0))*4186.4*(15.0))*(((22.0/((7530.0/((2.0)*(((((25.0))-421))))))*597.0)+7283.8-9.60+167.0))+(8871.0);
#param a := 3+2;
printf "%f\n", d;
====
AMPL output:
====
ampl test.ampl
1363056632.376000
14765.775299
20126587953209.562500
8034912576273.071289
8036090802426.097656
8259816920615.111328
8259816920615.111328
====
GLPSOL output:
====
glpsol -m test.ampl
GLPSOL: GLPK LP/MIP Solver, v4.65
Parameter(s) specified in the command line:
-m test.ampl
Reading model section from test.ampl...
test.ampl:25: warning: unexpected end of file; missing end statement
inserted
25 lines were read
1363056632.376000
17428.775299
23756407765226.851562
test.ampl:13: no value for a
MathProg model processing error
====
With a incorrect expression:
====
param a2 := a1 * a2; #glpsol segfault
#param a2 := a0 * a1;
====
AMPL output:
====
ampl test.ampl
1363056632.376000
14765.775299
test.ampl, line 7 (offset 228):
a2 is not defined
context: param a2 := a1 * >>> a2; <<< #glpsol segfault
====
GLPSOL output:
====
glpsol -m test.ampl
GLPSOL: GLPK LP/MIP Solver, v4.65
Parameter(s) specified in the command line:
-m test.ampl
Reading model section from test.ampl...
test.ampl:25: warning: unexpected end of file; missing end statement
inserted
25 lines were read
1363056632.376000
17428.775299
Segmentation fault (core dumped)
====
Cheers !