SimplexSolver.Solve Method (ISolverParameters)
[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]
Runs a solver using the specified solver parameters.
Namespace: Microsoft.SolverFoundation.Solvers
Assembly: Microsoft.Solver.Foundation (in Microsoft.Solver.Foundation.dll)
Syntax
'Declaration
Public Overridable Function Solve ( _
parameter As ISolverParameters _
) As ILinearSolution
public virtual ILinearSolution Solve(
ISolverParameters parameter
)
public:
virtual ILinearSolution^ Solve(
ISolverParameters^ parameter
)
abstract Solve :
parameter:ISolverParameters -> ILinearSolution
override Solve :
parameter:ISolverParameters -> ILinearSolution
public function Solve(
parameter : ISolverParameters
) : ILinearSolution
Parameters
- parameter
Type: Microsoft.SolverFoundation.Services.ISolverParameters
The parameters for the solver.
Return Value
Type: Microsoft.SolverFoundation.Services.ILinearSolution
The solution from the solver.
Implements
ILinearSolver.Solve(ISolverParameters)
Examples
The following code example shows how to create a model, add constraints and goals, solve the model, and generate a short report. For more information, see How to: Use Linear Programming using the Solver Foundation Solver APIs.
Imports Microsoft.SolverFoundation.Common
Imports Microsoft.SolverFoundation.Solvers
using Microsoft.SolverFoundation.Common;
using Microsoft.SolverFoundation.Solvers;
Dim solver As New SimplexSolver()
Dim savid As Integer, vzvid As Integer
solver.AddVariable("Saudi Arabia", savid)
solver.SetBounds(savid, 0, 9000)
solver.AddVariable("Venezuela", vzvid)
solver.SetBounds(vzvid, 0, 6000)
Dim gasoline As Integer, jetfuel As Integer, machinelubricant As Integer, cost As Integer
solver.AddRow("gasoline", gasoline)
solver.AddRow("jetfuel", jetfuel)
solver.AddRow("machinelubricant", machinelubricant)
solver.AddRow("cost", cost)
solver.SetCoefficient(gasoline, savid, 0.3)
solver.SetCoefficient(gasoline, vzvid, 0.4)
solver.SetBounds(gasoline, 2000, Rational.PositiveInfinity)
solver.SetCoefficient(jetfuel, savid, 0.4)
solver.SetCoefficient(jetfuel, vzvid, 0.2)
solver.SetBounds(jetfuel, 1500, Rational.PositiveInfinity)
solver.SetCoefficient(machinelubricant, savid, 0.2)
solver.SetCoefficient(machinelubricant, vzvid, 0.3)
solver.SetBounds(machinelubricant, 500, Rational.PositiveInfinity)
solver.SetCoefficient(cost, savid, 20)
solver.SetCoefficient(cost, vzvid, 15)
solver.AddGoal(cost, 1, True)
solver.Solve(New SimplexSolverParams())
Console.WriteLine("SA {0}, VZ {1}, Gasoline {2}, Jet Fuel {3}, Machine Lubricant {4}, Cost {5}",
solver.GetValue(savid).ToDouble(),
solver.GetValue(vzvid).ToDouble(),
solver.GetValue(gasoline).ToDouble(),
solver.GetValue(jetfuel).ToDouble(),
solver.GetValue(machinelubricant).ToDouble(),
solver.GetValue(cost).ToDouble())
Console.ReadLine()
SimplexSolver solver = new SimplexSolver();
int savid, vzvid;
solver.AddVariable("Saudi Arabia", out savid);
solver.SetBounds(savid, 0, 9000);
solver.AddVariable("Venezuela", out vzvid);
solver.SetBounds(vzvid, 0, 6000);
int gasoline, jetfuel, machinelubricant, cost;
solver.AddRow("gasoline", out gasoline);
solver.AddRow("jetfuel", out jetfuel);
solver.AddRow("machinelubricant", out machinelubricant);
solver.AddRow("cost", out cost);
solver.SetCoefficient(gasoline, savid, 0.3);
solver.SetCoefficient(gasoline, vzvid, 0.4);
solver.SetBounds(gasoline, 2000, Rational.PositiveInfinity);
solver.SetCoefficient(jetfuel, savid, 0.4);
solver.SetCoefficient(jetfuel, vzvid, 0.2);
solver.SetBounds(jetfuel, 1500, Rational.PositiveInfinity);
solver.SetCoefficient(machinelubricant, savid, 0.2);
solver.SetCoefficient(machinelubricant, vzvid, 0.3);
solver.SetBounds(machinelubricant, 500, Rational.PositiveInfinity);
solver.SetCoefficient(cost, savid, 20);
solver.SetCoefficient(cost, vzvid, 15);
solver.AddGoal(cost, 1, true);
solver.Solve(new SimplexSolverParams());
Console.WriteLine("SA {0}, VZ {1}, Gasoline {2}, Jet Fuel {3}, Machine Lubricant {4}, Cost {5}",
solver.GetValue(savid).ToDouble(),
solver.GetValue(vzvid).ToDouble(),
solver.GetValue(gasoline).ToDouble(),
solver.GetValue(jetfuel).ToDouble(),
solver.GetValue(machinelubricant).ToDouble(),
solver.GetValue(cost).ToDouble());
Console.ReadLine();
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.