help-glpk
[Top][All Lists]
Advanced

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

Re: [Help-glpk] forall constraint in MathProg


From: Noli Sicad
Subject: Re: [Help-glpk] forall constraint in MathProg
Date: Tue, 6 Nov 2012 06:55:56 +1100

Hello Xypron,

Yes, this is what I wanted. All the constraints are there.

Nice tip as well with the param and set combo (below).

> param nperiod := 3;
> param nnature := 20;
> param nstand := 20;

> set PERIOD := {1..nperiod};
> set NATURE := {1..nnature};
> set STAND := {1..nperiod};

Now, MathProg has easy way of implementing 'forall' constraints.

Danke Schoen Xypron.

It might be good to be added in the GLPK Wikibook.

Robbie, would you like to add this in Wikibook?

Thanks again.

Regards,

Noli

On 11/6/12, Xypron <address@hidden> wrote:
> Hello Noli,
>
> could you provide the condition you want to formulate in mathematical
> notation?
>
> "forall" is used for logical expression. Did you mean "sum"?
> Instead of "p in 1..PERIOD" you may want to write "p in {1..PERIOD}".
> If p is a number {pp in p} does not make sense.
>
> Please, save the gmpl text below as test.mod, and run command.
> glpsol -m test.mod --check --wlp test.lp
>
> Check if test.lp contains the constraints you meant to write.
>
> Best regards
>
> Xypron
>
> # file test.lp
> param nperiod := 3;
> param nnature := 20;
> param nstand := 20;

> set PERIOD := {1..nperiod};
> set NATURE := {1..nnature};
> set STAND := {1..nperiod};

> param standarea {STAND} := 5 + 5 * Uniform01();
> var forest{STAND, PERIOD};
> var nh{NATURE, PERIOD};
> s.t. habitat{p in PERIOD, n in NATURE, s in STAND} :
>   sum{pp in PERIOD:pp <= p} forest[s, pp] + nh[n, p] = standarea[s];
> end;
>
>
> On 05.11.2012 19:29, Noli Sicad wrote:
>> Hi,
>>
>> I am trying to translate this set of LINDO constraint (below) into
>> MathProg. But I don't have any success.
>>
>> ######
>>
>> 37) S1P1 + N1P1 = 12.3
>> 38) S1P1 + S1P2 + N1P2 = 12.3
>> 39) S1P1 + S1P2 + S1P3 + N1P3 = 12.3
>>
>> 40) S2P1 + N2P1 = 35.6
>> 41) S2P1 + S2P2 + N2P2 = 35.6
>> 42) S2P1 + S2P2 + S2P3 + N2P3 = 34.6
>>
>> 43) S3P1 + N3P1 = 34.6
>> 44) S3P1 + S3P2 + N3P2 = 34.6
>> 45) S3P1 + S3P2 + S3P3 + N3P3 = 34.6
>>
>> .
>> .
>> .
>>
>> 94) S20P1 + N20P1 = 46.0
>> 95) S20P1 + S20P2 + N20P2 = 46.0
>> 96) S20P1 + S20P2 + S20P3 + N20P3 = 46.0
>>
>> ###########
>>
>> I tried to implement like this:
>>
>> subject to Habitat_Constraint{ p in 1..PERIOD, n in 1..NATURE, s in
>> STAND}:
>>    forall {pp in p} Forest[s,pp] + NH[n,p] = StandArea[s];
>>
>> However, I got this error below.
>>
>> #######
>> Running tool: GLPK/MathProg
>>
>> GLPSOL: GLPK LP/MIP Solver, v4.47
>> Parameter(s) specified in the command line:
>>  --math Model_I_1_original_5-evenflow_even-acres_OF_alter3.mod
>> Reading model section from
>> Model_I_1_original_5-evenflow_even-acres_OF_alter3.mod...
>> Model_I_1_original_5-evenflow_even-acres_OF_alter3.mod:77: domain
>> expression has invalid type
>> Context: ...ERIOD , n in 1 .. NATURE , s in STAND } : forall { pp in p }
>> MathProg model processing error
>>
>> ########
>>
>> Anybody knows how to do this set of constraint properly in MathProg
>> properly?
>>
>> Any suggestions?
>>
>> Thanks.
>>
>> Regards,
>>
>> Noli
>>
>> _______________________________________________
>> Help-glpk mailing list
>> address@hidden
>> https://lists.gnu.org/mailman/listinfo/help-glpk
>>
>
>



reply via email to

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