Skip to content

acco32/Operations-Research

Repository files navigation

F#OR (Operations Research with F#)

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.

Solver Types

  • Linear Programming (Google MIP/LP)

  • Constraint Programming (Google CP-SAT)

  • Routing (Google Route API)

Example

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" e

Installation

Download the latest release for your platform from the Releases page. Each release includes an INSTALL.adoc file with detailed installation instructions.

Development

Prerequisites

  • .NET 8.0 SDK

  • Tusk task runner

Setup

Install the task runner:

dotnet fsi tools/install-task-runner.fsx

Or use the tusk task (once tusk is installed):

./tools/tusk install-tools

View available tasks:

./tools/tusk

Building

Build the project:

./tools/tusk build

Run tests:

./tools/tusk test

Creating Releases

Build a release for a specific platform:

./tools/tusk release -version=1.0.0 -runtime=linux-x64

Releases are automatically built and published to GitHub when you push a version tag:

git tag v1.0.0
git push origin v1.0.0

This creates platform-specific archives for download.

About

Operations Research in F#

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages