fslaborg / flips

Fsharp LInear Programming System
https://flipslibrary.com/#/
MIT License
251 stars 32 forks source link

Is it possible to match LinearExpressions conditionally? #203

Closed Jonathan-Schaefer-git closed 2 months ago

Jonathan-Schaefer-git commented 4 months ago

I want to have my target function to be dependent on the amount of true decisions made by the model and instead of applying a certain factor (i.e. * 3) to it, want to assign certain values for differing amount of true decisions.

For example instead of

for week in tf do
       (sum booleanDecision.[All,week,All]) * 3.0

to something like this

for week in tf do
    match sum booleanDecision.[All,week,All] with
    | 1.0<'u> -> 1.0
    | 2.0<'u> -> 2.5
    ...
    | _ -> 100.0

Or is there a principality of LP I'm missing that doesn't allow something akin to this

matthewcrews commented 2 months ago

I think you would have to match on the count of decisions which were 1.0 to do that.