Hi Manuel,
try setting StorageFlag to 1 or 0 as a parameter (based on your data), and
then doing this:
subject to linctr14-1 {i in PeriodsCount: i == 1}:
StorageEnergy[i] >= StorageFlag*( existing constraint ) ;
subject to linctr14-0 {i in PeriodsCount: i == 1}:
StorageEnergy[i] <= StorageFlag*( existing constraint ) +
(1-StorageFlag) * M ;
When StorageFlag = 1, these two constraints equate to your equality
constraint.
When StorageFlag = 0, the constraints just become bounds (0 and M). If you
want to allow StorageEnergy[i] to be negative, you could add " -
(1-StorageFlag)*M" to the first constraint.
I *think* this will work -- good luck!
Best regards,
Greg
> ---------------------------------------------------------------------
>
> Message: 1
> Date: Tue, 24 Nov 2020 18:59:09 +0000
> From: Manuel Castro <[email protected]>
> To: "help-glpk" <[email protected]>
> Subject: Help: Switch constraints on or off
> Message-ID: <[email protected]>
> Content-Type: text/plain; charset="utf-8"
>
> 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
>
>
> 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?
>
>
>
> Many thanks in advance for your help. It's really appreciated.
>
>
>
> Kind regards,
>
> Manuel.
>
>