Re: Adding if/then/else statement to GMPL

2020-08-23 Thread Andrew Makhorin
On Sun, 2020-08-23 at 15:36 +0200, Domingo Alvarez Duarte wrote:
> Hello !
> 
> Also I've added the break/continue statements here 
> https://github.com/mingodad/GLPK/commit/9d70a37b16bd377722eeb3880fcf86
> bb3b812118 
> 
> 
> Again any comment/suggestion is welcome !
> 
> Cheers !
> 
> 
> 

Please note that GNU MathProg is a *modeling* language; it is not 
a general-purpose programming language. If you need to produce a
non-trivial solution report (since all such-like statements are 
allowed only on the post-solving stage), it would be more practical 
to write the solution to a temporary file and then process it with 
a separate program.





Re: Adding if/then/else statement to GMPL

2020-08-23 Thread Domingo Alvarez Duarte

Hello !

Also I've added the break/continue statements here 
https://github.com/mingodad/GLPK/commit/9d70a37b16bd377722eeb3880fcf86bb3b812118 



Again any comment/suggestion is welcome !

Cheers !




Adding if/then/else statement to GMPL

2020-08-23 Thread Domingo Alvarez Duarte

Hello !

I just added the if/then/else statement to GMPL here 
https://github.com/mingodad/GLPK/commit/8984d5db70ce0cc91189911164f5448390026a4a 
and hope it could be added to a future release of GLPK/GMPL.


Any comment/suggestion is welcome !



param p symbolic := "dad";
check length(p) == 3;

if length(p) == 3 then display "true";
if length(p) == 5 then display "true";
if length(p) == 3 then display "true"; else display "false";
if length(p) == 5 then display "true"; else display "false";

if length(p) == 3 then
    display "true";

if length(p) == 5 then
    display "true";

if length(p) == 3 then
    display "true";
else
    display "false";

if length(p) == 5 then
    display "true";
else
    display "false";

if length(p) == 3 then {display "true";}
if length(p) == 5 then {display "true";}
if length(p) == 3 then {}
if length(p) == 5 then {}
if length(p) == 3 then {display "true";} else {display "false";}
if length(p) == 5 then {display "true";} else {display "false";}

if length(p) == 3 then
{
    display "true";
}

if length(p) == 5 then
{
    display "true";
}

if length(p) == 3 then
{
    display "true";
}
else
{
    display "false";
}

if length(p) == 5 then
{
    display "true";
}
else
{
    display "false";
}



Output:



./glpsol -m test-if.mod
GLPSOL: GLPK LP/MIP Solver, v4.65
Parameter(s) specified in the command line:
 -m test-if.mod
Reading model section from test-if.mod...
test-if.mod:58: warning: unexpected end of file; missing end statement 
inserted

58 lines were read
Checking (line 2)...
Display statement at line 4
true
Display statement at line 6
true
Display statement at line 7
false
Display statement at line 10
true
Display statement at line 16
true
Display statement at line 23
false
Display statement at line 25
true
Display statement at line 29
true
Display statement at line 30
false
Display statement at line 34
true
Display statement at line 44
true
Display statement at line 57
false
Model has been successfully generated
GLPK Simplex Optimizer, v4.65
0 rows, 0 columns, 0 non-zeros
~ 0: obj =   0.0e+00  infeas =  0.000e+00
OPTIMAL SOLUTION FOUND
Time used:   0.0 secs
Memory used: 0.1 Mb (67060 bytes)



Cheers !