GenSolver


GenSolver

Documentation

The GenSolver library can be installed from NuGet:
PM> Install-Package Informedica.GenSolver.Lib -Pre

Example

This example demonstrates using a function defined in this sample library.

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
15: 
16: 
module UT  = Informedica.GenUtils.Lib.BCL.String
module Api = Informedica.GenSolver.Api

// Format print output to use in markdown
let solve = Api.solve (fun s -> "> " + s + "</br>" |> UT.replace "*" "\*" |> printfn "%s")

// Initialize calculation model
Api.init [ 
    "y = x1 * x2"
    "x1 = x3 + x4"
]
// Stepwise solve the model
|> solve "y"  "vals" [4N]
|> solve "x4" "vals" [6N]
|> solve "x2" "vals" [5N]
|> ignore

Prints:

Setting variable y vals with 4
x1<..> = x3<..> + x4<..>
y[4] = x1<..> * x2<..>
-----
Setting variable x4 vals with 6
x1<..> = x3<..> + x4[6]
y[4] = x1<..> * x2<..>
-----
Setting variable x2 vals with 5
Loop solveEq Loop solveEq x1[4/5] = x3[-26/5] + x4[6]
y[4] = x1[4/5] * x2[5]
-----
Real: 00:00:00.001, CPU: 00:00:00.015, GC gen0: 0, gen1: 0, gen2: 0

Some more info

Samples & documentation

The library comes with comprehensible documentation. It can include tutorials automatically generated from *.fsx files in the content folder. The API reference is automatically generated from Markdown comments in the library implementation.

  • Tutorial contains a further explanation of this sample library.

  • API Reference contains automatically generated documentation for all types, modules and functions in the library. This includes additional brief samples on using most of the functions.

Contributing and copyright

The project is hosted on GitHub where you can report issues, fork the project and submit pull requests. If you're adding a new public API, please also consider adding samples that can be turned into a documentation. You might also want to read the library design notes to understand how it works.

The library is available under Public Domain license, which allows modification and redistribution for both commercial and non-commercial purposes. For more information see the License file in the GitHub repository.

namespace Informedica
namespace Informedica.GenUtils
namespace Informedica.GenUtils.Lib
namespace Informedica.GenUtils.Lib.BCL
module String

from Informedica.GenUtils.Lib.BCL
namespace Informedica.GenSolver
module Api

from Informedica.GenSolver


 Public funtions to use the library
val solve : (string -> string -> BigRational list -> Informedica.GenSolver.Lib.Equation.Equation list -> Informedica.GenSolver.Lib.Equation.Equation list)

Full name: Index.solve
val solve : f:(string -> unit) -> n:string -> p:string -> vs:BigRational list -> eqs:Informedica.GenSolver.Lib.Equation.Equation list -> Informedica.GenSolver.Lib.Equation.Equation list

Full name: Informedica.GenSolver.Api.solve


 Solve an `Equations` list with

 * f: function used to process string message
 * n: the name of the variable to be updated
 * p: the property of the variable to be updated
 * vs: the values to update the property of the variable
 * eqs: the list of equations to solve
val s : string
val replace : os:string -> ns:string -> s:System.String -> string

Full name: Informedica.GenUtils.Lib.BCL.String.replace
val printfn : format:Printf.TextWriterFormat<'T> -> 'T

Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.printfn
val init : eqs:System.String list -> Informedica.GenSolver.Lib.Equation.Equation list

Full name: Informedica.GenSolver.Api.init


 Initialize the solver returning a set of equations
val ignore : value:'T -> unit

Full name: Microsoft.FSharp.Core.Operators.ignore
Fork me on GitHub