[Top][All Lists]

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

Re: Adding if/then/else statement to GMPL

From: Domingo Alvarez Duarte
Subject: Re: Adding if/then/else statement to GMPL
Date: Mon, 24 Aug 2020 17:14:25 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0

Hello Heinrich !

That example was a silly one only to do a minimal check that the add if/then/else was working (properly?).

My implementation doesn't seem to need much code and allow a bit better expressiveness to GMPL.

Another example from examples/pentomino.mod:



for {i in 1..m}
{ for {j in 1..n}
{ for {0..0: (i,j) in R}
{ for {(c,ii,jj) in S: (i-ii,j-jj) in D[c] and x[c,ii,jj]}
printf " %s", substr(c,1,1);
for {0..0: (i,j) not in R}
printf " .";
printf "\n";




for {i in M}
{ for {j in N}
{ if (i,j) in R then
{ for {(c,ii,jj) in S: (i-ii,j-jj) in D[c] and x[c,ii,jj]}
printf " %s", substr(c,1,1);
printf " .";
printf "\n";


Cheers !

On 24/8/20 16:59, Heinrich Schuchardt wrote:
On 24.08.20 16:33, Domingo Alvarez Duarte wrote:
Hello Meketon !

Could you share your view of how it would be expressed (an ideal model
sample) ?

If you want to talk about it, maybe I'll be interested in implement it !

Can you share a collection of models data to be used as base for the
test/implementation ?
Dear Domingo,

I do not yet understand what was you weren't able to express with the
current syntax.

Instead of

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

you can write:

param p,symbolic := "dad";
display if length(p) == 3 then "true 3" else "false 3";
display if length(p) == 5 then "true 5" else "false 5";

Best regards


reply via email to

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