Library to solve operations research problems in F#. You can specify your objective and constraints and then use one of the underlying solvers to get an answer. Currently the only solver used is Google’s OrTools.
-
Linear Programming (Google MIP/LP)
-
Constraint Programming (Google CP-SAT)
-
Routing (Google Route API)
open System
open Operations.Research.Types
open Operations.Research.Models
open Operations.Research.Solvers.Google.Linear
let x = Variable.real "x" 0.0 Double.PositiveInfinity |> toExpression
let y = Variable.real "y" 0.0 Double.PositiveInfinity |> toExpression
let mdl =
Model.Default
|> DecisionVars [x; y]
|> Goal Maximize
|> Objective (6*x + 2*y + 77)
|> Constraints [
3*x + 1*y <== 48
3*x + 4*y <== 120
3*x + 1*y >== 36
]
let result = SolveWithCustomOptions mdl SolverOptions.Default
match result with
| Solution sol ->
printfn "Objective: %i" (sol.Objective.toInt)
printfn "%s: %i" "x" (sol.Variables.["x"])
printfn "%s: %i" "y" (sol.Variables.["y"])
| Error e ->
printfn "%A" eDownload the latest release for your platform from the Releases page. Each release includes an INSTALL.adoc file with detailed installation instructions.
-
.NET 8.0 SDK
-
Tusk task runner
Install the task runner:
dotnet fsi tools/install-task-runner.fsxOr use the tusk task (once tusk is installed):
./tools/tusk install-toolsView available tasks:
./tools/tusk