Fable.YALPS 0.6.0

dotnet add package Fable.YALPS --version 0.6.0                
NuGet\Install-Package Fable.YALPS -Version 0.6.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Fable.YALPS" Version="0.6.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Fable.YALPS --version 0.6.0                
#r "nuget: Fable.YALPS, 0.6.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Fable.YALPS as a Cake Addin
#addin nuget:?package=Fable.YALPS&version=0.6.0

// Install Fable.YALPS as a Cake Tool
#tool nuget:?package=Fable.YALPS&version=0.6.0                

Fable.YALPS alternate text is missing from this package README image alternate text is missing from this package README image

This provides F# / Fable bindings for Yet Another Linear Programming Solver (YALPS). Check it out for more information. The corresponding F# API translates naturally, but you may ignore anything regarding objects for fields on the model (see Differences for more information). One thing to note is that equality between constraint and variable keys is tested using JS strict equality and not structural equality.

Examples

open YALPS
open YALPS.Operators

let constraints = [
  "wood", Constraint.lessEq 300.0
  "labor" <== 110.0 // you can use the convenience operators instead
  "storage" <== 400.0
]

let variables = [
  "table", [ "wood", 30.0; "labor", 5.0; "profit", 1200.0; "storage", 30.0 ]
  "dresser", [ "wood", 20.0; "labor", 10; "profit", 1600.0; "storage", 50.0 ]
]

let model = Model.createAllInteger Maximize "profit" constraints variables
let solution = Solver.solve model
// { status = Optimal
//   result = 14400.0
//   variables: [| "table", 8; "dresser", 3 |] }

With custom options:

let model = Model.createAllInteger Maximize "profit" constraints variables
let solution = model |> Solver.solveWith { Solver.defaultOptions with timeout = 100.0 }

Differences

To fit better with F# code, the ability for sequences to be substituted with objects (serving as a key-value map) was dropped. The underlying JS code still supports this, so dynamic casting will work:

let constraints = {|
  wood = Constraint.lessEq 300.0
  labor = {| max = 110.0 |}
  storage = {| max = 400.0 |}
|}

let variables = {|
  table = {| wood = 30.0; labor = 5.0; profit = 1200.0; storage = 30.0 |}
  dresser = {| wood = 20.0; labor = 10.0; profit = 1600.0; storage = 50.0 |}
|}

open Fable.Core.JsInterop
let model = Model.createAllInteger Maximize "profit" !!constraints !!variables

Here is the simplified model type used in Fable.YALPS (only sequences and no objects).

type Model<'VariableKey, 'ConstraintKey> =
  abstract direction: OptimizationDirection
  abstract objective: 'ConstraintKey
  abstract constraints: ('ConstraintKey * Constraint) seq
  abstract variables: ('VariableKey * ('ConstraintKey * float) seq) seq
  abstract integers: U2<bool, 'VariableKey seq>
  abstract binaries: U2<bool, 'VariableKey seq>
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.6.0 137 3/22/2024
0.5.0 267 4/3/2023
0.4.0 248 3/11/2023
0.3.0 509 8/19/2022
0.2.0 437 5/29/2022
0.1.6 429 5/12/2022
0.1.5 408 5/10/2022
0.1.4 413 4/30/2022
0.1.3 408 4/30/2022
0.1.2 422 4/30/2022
0.1.1 414 4/30/2022
0.1.0 404 4/30/2022