Created
May 20, 2013 14:15
-
-
Save josejuan/5612521 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module test | |
(* | |
#r "Microsoft.Solver.Foundation.dll";; | |
#load "test.fs";; | |
test.computeProblem;; | |
*) | |
open Microsoft.SolverFoundation.Common | |
open Microsoft.SolverFoundation.Services | |
let k (x : float) = Term.op_Implicit(x) | |
let (>=) (t : Term) (x : float) = Model.LessEqual([|k x; t|]) | |
let (<=) (t : Term) (x : float) = Model.LessEqual([|t; k x|]) | |
let (.*) (x: float) (t : Term) = k x * t | |
let computeProblem = | |
let context = SolverContext.GetContext() | |
let model = context.CreateModel() | |
let vz = new Decision(Domain.RealNonnegative, "barrels_venezuela") | |
let sa = new Decision(Domain.RealNonnegative, "barrels_saudiarabia") | |
do model.AddDecisions(vz, sa) | |
let limits = model.AddConstraints("limits", vz >= 0.0 | |
, vz <= 9000.0 | |
, sa >= 0.0 | |
, sa <= 6000.0) | |
let production = model.AddConstraints("production", 0.3 .* sa + 0.4 .* vz >= 2000.0 | |
, 0.4 .* sa + 0.2 .* vz >= 1500.0 | |
, 0.2 .* sa + 0.3 .* vz >= 500.0) | |
let goal = model.AddGoal("cost", GoalKind.Minimize, 20.0 .* sa + 15.0 .* vz) | |
let solution = context.Solve(new SimplexDirective()) | |
let report = solution.GetReport() | |
report |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment