Linear Program Class
Definition
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 9.0.3
public class LinearProgram : OptimizationModel
- Inheritance
- Object → OptimizationModel → LinearProgram
- Derived
Remarks
Use the LinearProgram class to represent a linear optimization problem with linear constraints.
A linear program has variables and constraints. They are made available through the Variables and Constraints properties. These collections are indexed by name and by position.
There are three ways to define a linear program. You can supply the linear program in matrix form. You can build the linear program from scratch using the AddVariable(String, Double) and AddLinearConstraint(String, Double, Double) methods. The ExtremumType property determines whether a maximum or a minimum is requested.
You can also load a linear program from an MPS file using the MpsReader class.
The Solve() method solves the linear program using a dual Revised Simplex Method. Note that this operation can take a long time for large problems or difficult problems. Most problems up to several hundred variables are solved within a fraction of a second. The Status property returns a OptimizationModelStatus value that indicates the result of the calculation. A value of Optimal indicates an optimal solution was found.
The Solve() method returns a Vector containing the optimal values for the variables. The values of the variables are also avaialble through the Value property of the variables.
Once a solution has been computed, the GetDualSolution() returns a Vector containing the dual solution (the solution in terms of the shadow variables.) The OptimalValue property returns the optimal value.
Constructors
Linear | Constructs a new LinearProgram object. |
Linear | Constructs a new linear program in standard form. |
Linear | Constructs a new linear program in standard form. |
Linear | Constructs a new linear program. |
Properties
Constant | |
Constraints |
Gets the collection of constraints for this OptimizationModel.
(Inherited from OptimizationModel) |
Extremum |
Gets or sets whether a minimum or a maximum should be computed.
(Inherited from OptimizationModel) |
Name |
Gets or sets the name of the model.
(Inherited from OptimizationModel) |
Optimal |
Gets the extreme value of the cost function.
(Inherited from OptimizationModel) |
Solution |
Gets an object that contains information about the solution of the model.
(Inherited from OptimizationModel) |
Status |
Gets the status of the optimization model's solution.
(Inherited from OptimizationModel) |
Tolerance | Gets or sets the tolerance used to determine if a solution has been found. |
Variables |
Gets the collection of variables for this OptimizationModel.
(Inherited from OptimizationModel) |
Methods
Add |
Adds a binary variable to the collection.
(Inherited from OptimizationModel) |
Add | Adds a binary variable to the collection. |
Add |
Adds an integer variable to the collection.
(Inherited from OptimizationModel) |
Add | Adds a binary variable to the collection. |
Add |
Adds a binary variable to the collection.
(Inherited from OptimizationModel) |
Add | Adds a binary variable to the collection. |
Add |
Adds a linear constraint to the optimization model.
(Inherited from OptimizationModel) |
Add |
Adds a linear constraint to the optimization model.
(Inherited from OptimizationModel) |
Add |
Adds a linear constraint to the optimization model.
(Inherited from OptimizationModel) |
Add |
Adds a linear constraint to the optimization model.
(Inherited from OptimizationModel) |
Add |
Adds a linear constraint to the optimization model.
(Inherited from OptimizationModel) |
Add |
Adds a linear constraint to the optimization model.
(Inherited from OptimizationModel) |
Add |
Adds a variable to the collection.
(Inherited from OptimizationModel) |
Add | Adds a variable to the collection. |
Add |
Adds a variable to the collection.
(Inherited from OptimizationModel) |
Add | Adds a variable to the collection. |
Create |
Creates linear constraints based on the specified coefficients.
(Inherited from OptimizationModel) |
Create |
Creates linear constraints based on the specified coefficients and bounds.
(Inherited from OptimizationModel) |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object) |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object) |
Get | Returns a matrix containing the coefficients of the constraints. |
Get | Gets the solution to the dual problem of the linear program. |
Get | Serves as the default hash function. (Inherited from Object) |
Get | Gets a vector that contains the coefficients of the linear objective function. |
Get |
Gets the solution to the optimization model.
(Inherited from OptimizationModel) |
Get | Gets the Type of the current instance. (Inherited from Object) |
Memberwise | Creates a shallow copy of the current Object. (Inherited from Object) |
OnAdd |
Notifies the optimization model that a constraint has been added.
(Inherited from OptimizationModel) |
OnAdd |
Notifies the optimization model that a variable has been added.
(Inherited from OptimizationModel) |
OnRemove |
Notifies the optimization model that all constraints has been removed.
(Inherited from OptimizationModel) |
OnRemove |
Notifies the optimization model that all variables has been removed.
(Inherited from OptimizationModel) |
OnRemove |
Notifies the optimization model that a constraint has been removed.
(Inherited from OptimizationModel) |
OnRemove |
Notifies the optimization model that a variable has been removed.
(Inherited from OptimizationModel) |
Solve() |
Solves the model and returns the solution.
(Inherited from OptimizationModel) |
Solve( | Solves a linear program with the specified options. |
Solve( | Solves a linear program with the specified options. |
Solve |
Solves the model and returns a report detailing the solution.
(Overrides OptimizationModel.SolveModel()) |
ToString | Returns a string that represents the current object. (Inherited from Object) |