Skip to content

Commit

Permalink
feat: removed automatically convert min incr max to valueset
Browse files Browse the repository at this point in the history
  • Loading branch information
Casper Bollen authored and Casper Bollen committed Oct 27, 2023
1 parent ba23f59 commit 6139862
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 91 deletions.
33 changes: 16 additions & 17 deletions src/Informedica.GenOrder.Lib/OrderVariable.fs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ module OrderVariable =

/// Create a `OrderVariable` with preset values
let create n min incr max vs cs =
ValueRange.create true min incr max vs
ValueRange.create min incr max vs
|> fun vlr ->
let var = Variable.create id n vlr
{
Expand Down Expand Up @@ -116,17 +116,16 @@ module OrderVariable =
let eqsName ovar1 ovar2 = (ovar1 |> getName) = (ovar2 |> getName)


let applyConstraints withVals (ovar : OrderVariable) =
let applyConstraints (ovar : OrderVariable) =
{ ovar with
Variable =
ovar.Variable.Values
|> ValueRange.setOptMin ovar.Constraints.Min
|> ValueRange.setOptMax ovar.Constraints.Max
|> ValueRange.setOptIncr ovar.Constraints.Incr
// only set a ValueSet if either no increment
// or withVals = true
// only set a ValueSet if there is no increment
|> fun vr ->
if not withVals && ovar.Constraints.Incr.IsSome then vr
if ovar.Constraints.Incr.IsSome then vr
else
vr
|> ValueRange.setOptVs ovar.Constraints.Values
Expand Down Expand Up @@ -411,7 +410,7 @@ module OrderVariable =
let toValueUnitMarkdown = toValueUnitMarkdown toOrdVar


let applyConstraints = toOrdVar >> applyConstraints false >> count
let applyConstraints = toOrdVar >> applyConstraints >> count



Expand Down Expand Up @@ -463,7 +462,7 @@ module OrderVariable =



let applyConstraints = toOrdVar >> applyConstraints false >> time
let applyConstraints = toOrdVar >> applyConstraints >> time



Expand Down Expand Up @@ -516,7 +515,7 @@ module OrderVariable =



let applyConstraints = toOrdVar >> applyConstraints false >> Frequency
let applyConstraints = toOrdVar >> applyConstraints >> Frequency



Expand Down Expand Up @@ -571,7 +570,7 @@ module OrderVariable =



let applyConstraints = toOrdVar >> applyConstraints false >> Concentration
let applyConstraints = toOrdVar >> applyConstraints >> Concentration



Expand Down Expand Up @@ -619,7 +618,7 @@ module OrderVariable =
let toValueUnitMarkdown = toValueUnitMarkdown toOrdVar


let applyConstraints = toOrdVar >> applyConstraints false >> Quantity
let applyConstraints = toOrdVar >> applyConstraints >> Quantity


let increaseIncrement lim incr = toOrdVar >> increaseIncrement lim incr >> Quantity
Expand Down Expand Up @@ -675,7 +674,7 @@ module OrderVariable =



let applyConstraints = toOrdVar >> applyConstraints false >> PerTime
let applyConstraints = toOrdVar >> applyConstraints >> PerTime



Expand Down Expand Up @@ -726,7 +725,7 @@ module OrderVariable =
let toValueUnitMarkdown = toValueUnitMarkdown toOrdVar


let applyConstraints = toOrdVar >> applyConstraints false >> Rate
let applyConstraints = toOrdVar >> applyConstraints >> Rate


let increaseIncrement lim incr = toOrdVar >> increaseIncrement lim incr >> Rate
Expand Down Expand Up @@ -777,7 +776,7 @@ module OrderVariable =
let toValueUnitMarkdown = toValueUnitMarkdown toOrdVar


let applyConstraints = toOrdVar >> applyConstraints false >> Total
let applyConstraints = toOrdVar >> applyConstraints >> Total



Expand Down Expand Up @@ -831,7 +830,7 @@ module OrderVariable =
let toValueUnitMarkdown = toValueUnitMarkdown toOrdVar


let applyConstraints = toOrdVar >> applyConstraints false >> QuantityAdjust
let applyConstraints = toOrdVar >> applyConstraints >> QuantityAdjust



Expand Down Expand Up @@ -888,7 +887,7 @@ module OrderVariable =



let applyConstraints = toOrdVar >> applyConstraints false >> PerTimeAdjust
let applyConstraints = toOrdVar >> applyConstraints >> PerTimeAdjust



Expand Down Expand Up @@ -945,7 +944,7 @@ module OrderVariable =



let applyConstraints = toOrdVar >> applyConstraints false >> RateAdjust
let applyConstraints = toOrdVar >> applyConstraints >> RateAdjust



Expand Down Expand Up @@ -998,6 +997,6 @@ module OrderVariable =
let toValueUnitMarkdown = toValueUnitMarkdown toOrdVar


let applyConstraints = toOrdVar >> applyConstraints false >> TotalAdjust
let applyConstraints = toOrdVar >> applyConstraints >> TotalAdjust


8 changes: 3 additions & 5 deletions src/Informedica.GenOrder.Lib/Variable.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ namespace Informedica.GenOrder.Lib

module Variable =

open Informedica.GenSolver.Lib.Types


module ValueRange =

Expand All @@ -14,9 +12,9 @@ module Variable =
let inline setOpt m set vr =
try
match m with
| Some m -> vr |> set true m
| Some m -> vr |> set m
| None -> vr
with | _ -> vr // TODO: ugly fix need to refactor
with | _ -> vr // TODO: ugly fix need to refactor


let setOptMin min vr = vr |> setOpt min setMin
Expand All @@ -34,4 +32,4 @@ module Variable =
| Some vs -> vr |> setValueSet vs
| None -> vr

with | _ -> vr // TODO: ugly fix need to refactor
with | _ -> vr // TODO: ugly fix need to refactor
Loading

0 comments on commit 6139862

Please sign in to comment.