help-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Adding if/then/else statement to GMPL


From: Domingo Alvarez Duarte
Subject: Adding if/then/else statement to GMPL
Date: Sun, 23 Aug 2020 13:38:36 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0

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.000000000e+00  infeas =  0.000e+00
OPTIMAL SOLUTION FOUND
Time used:   0.0 secs
Memory used: 0.1 Mb (67060 bytes)

====

Cheers !




reply via email to

[Prev in Thread] Current Thread [Next in Thread]