help-glpk
[Top][All Lists]
Advanced

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

Re: Help: Switch constraints on or off


From: Heinrich Schuchardt
Subject: Re: Help: Switch constraints on or off
Date: Tue, 24 Nov 2020 21:30:07 +0100
User-agent: Mozilla/5.0 (X11; Linux aarch64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0

On 11/24/20 8:42 PM, Andrew Makhorin wrote:
On Tue, 2020-11-24 at 18:59 +0000, Manuel Castro wrote:
Hi there,

I am wondering how I can use an if statement to turn a constraint on
or off.
For example in my problem I have the following constraint:

subject to linctr14 {i in PeriodsCount: i == 1}: StorageEnergy[i] =
(StorageStateCharge * StorageEnergyRating + ((StorageEfficiencyCharge
* (StoragePowerCharge[i])) - ((StoragePowerDischarge[i]) /
StorageEfficiencyDischarge)));

Now, I only want to consider storage in my problem if an object
storage actually exists.
For that, I would have a StorageStatusFlag which if equal to "1" then
I would consider the constraint in my problem.
For example:

If (StorageStatusFlag == 1) then
     subject to linctr14 {i in PeriodsCount: i == 1}: StorageEnergy[i]
= (StorageStateCharge * StorageEnergyRating +
((StorageEfficiencyCharge * (StoragePowerCharge[i])) -
((StoragePowerDischarge[i]) / StorageEfficiencyDischarge)));
end if

Just add the condition to the constraint iterator:

subject to
linctr14{i in PeriodsCount: i == 1 && StorageStatusFlag == 1}: ....

Best regards

Heinrich


This is what I used to do in "mosel" language from FICO Xpress (I
don't have a license anymore so I am discovering GLPK ). How can I do
this in GLPK language? What's the workaround that we can use for this?


You could use the C preprocessor.



Many thanks in advance for your help. It's really appreciated.

Kind regards,
Manuel.






reply via email to

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