NonlinearProgram Class

Represents a nonlinear programming problem.

Definition

Namespace: Extreme.Mathematics.Optimization
Assembly: Extreme.Numerics (in Extreme.Numerics.dll) Version: 8.1.23
C#
public class NonlinearProgram : OptimizationModel
Inheritance
Object  →  OptimizationModel  →  NonlinearProgram

Remarks

Use the NonlinearProgram class to represent an optimization problem with a nonlinear objective function that may have both linear and nonlinear constraints.

A nonlinear 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 two ways to define a nonlinear program. You can supply the linear constraints of the nonlinear program in matrix form. You can also build the nonlinear program entirely 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.

The Solve() method solves the nonlinear program using a sequential quadratic programming algorithm. Note that this operation can take a long time for large problems or difficult problems. Small problems are usually 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 OptimalValue property returns the optimal value.

Constructors

NonlinearProgram() Constructs a new nonlinear program.
NonlinearProgram(IEnumerable<String>) Constructs a new nonlinear program with variables of the specified names.
NonlinearProgram(Int32) Constructs a new nonlinear program with the specified number of variables.
NonlinearProgram(Func<Vector<Double>, Double>, Func<Vector<Double>, Vector<Double>, Vector<Double>>, Int32) Constructs a new nonlinear program without defining any linear or nonlinear constraints.
NonlinearProgram(Func<Vector<Double>, Double>, Func<Vector<Double>, Vector<Double>, Vector<Double>>, Matrix<Double>, Vector<Double>, Int32) Constructs a new nonlinear program with linear constraints in standard form.
NonlinearProgram(Func<Vector<Double>, Double>, Func<Vector<Double>, Vector<Double>, Vector<Double>>, Matrix<Double>, Vector<Double>, Vector<Double>, Vector<Double>, Vector<Double>) Constructs a new nonlinear program with linear constraints.

Properties

Constraints Gets the collection of constraints for this OptimizationModel.
(Inherited from OptimizationModel)
ExtremumType Gets or sets whether a minimum or a maximum should be computed.
(Inherited from OptimizationModel)
InitialGuess Gets or sets an initial guess for the solution of the nonlinear program.
Name Gets or sets the name of the model.
(Inherited from OptimizationModel)
ObjectiveAndGradient Gets or sets the gradient of the objective function of the nonlinear program.
ObjectiveFunction Gets or sets the objective function of the nonlinear program.
ObjectiveGradient Gets or sets the gradient of the objective function of the nonlinear program.
OptimalValue Gets the extreme value of the cost function.
(Inherited from OptimizationModel)
SolutionReport Gets an object that contains information about the solution of the model.
(Inherited from OptimizationModel)
Solver Gets the object used to solve the nonlinear program.
Status Gets the status of the optimization model's solution.
(Inherited from OptimizationModel)
SymbolicObjectiveFunction Gets or sets the expression that evaluates the objective function.
Variables Gets the collection of variables for this OptimizationModel.
(Inherited from OptimizationModel)

Methods

AddBinaryVariable Adds a binary variable to the collection.
(Inherited from OptimizationModel)
AddIntegerVariable(String) Adds an integer variable to the collection.
(Inherited from OptimizationModel)
AddIntegerVariable(String, Int32, Int32) Adds a binary variable to the collection.
(Inherited from OptimizationModel)
AddLinearConstraint(String, ConstraintType, Double) Adds a linear constraint to the optimization model.
(Inherited from OptimizationModel)
AddLinearConstraint(String, Double, Double) Adds a linear constraint to the optimization model.
(Inherited from OptimizationModel)
AddLinearConstraint(IList<DecisionVariable>, IList<Double>, ConstraintType, Double) Adds a linear constraint to the optimization model.
(Inherited from OptimizationModel)
AddLinearConstraint(String, IList<Double>, ConstraintType, Double) Adds a linear constraint to the optimization model.
(Inherited from OptimizationModel)
AddLinearConstraint(String, IList<Double>, Double, Double) Adds a linear constraint to the optimization model.
(Inherited from OptimizationModel)
AddLinearConstraint(String, IList<DecisionVariable>, IList<Double>, ConstraintType, Double) Adds a linear constraint to the optimization model.
(Inherited from OptimizationModel)
AddNonlinearConstraint(Func<Vector<Double>, Double>, ConstraintType, Double) Adds a nonlinear constraint to the nonlinear program.
AddNonlinearConstraint(Func<Vector<Double>, Double>, Double, Double) Adds a nonlinear constraint to the nonlinear program.
AddNonlinearConstraint(Func<Vector<Double>, Double>, ConstraintType, Double, Func<Vector<Double>, Vector<Double>, Vector<Double>>) Adds a nonlinear constraint to the nonlinear program.
AddNonlinearConstraint(Func<Vector<Double>, Double>, Double, Double, Func<Vector<Double>, Vector<Double>, Vector<Double>>) Adds a nonlinear constraint to the nonlinear program.
AddNonlinearConstraint(String, Func<Vector<Double>, Double>, ConstraintType, Double) Adds a nonlinear constraint to the nonlinear program.
AddNonlinearConstraint(String, Func<Vector<Double>, Double>, Double, Double) Adds a nonlinear constraint to the nonlinear program.
AddNonlinearConstraint(String, Func<Vector<Double>, Double>, ConstraintType, Double, Func<Vector<Double>, Vector<Double>, Vector<Double>>) Adds a nonlinear constraint to the nonlinear program.
AddNonlinearConstraint(String, Func<Vector<Double>, Double>, Double, Double, Func<Vector<Double>, Vector<Double>, Vector<Double>>) Adds a nonlinear constraint to the nonlinear program.
AddSymbolicConstraint(Expression<Func<Vector<Double>, Double>>, ConstraintType, Double) Adds a constraint that is defined by an expression to the nonlinear program.
AddSymbolicConstraint(Expression<Func<Vector<Double>, Double>>, Double, Double) Adds a constraint that is defined by an expression to the nonlinear program.
AddSymbolicConstraint(String, Expression<Func<Vector<Double>, Double>>, ConstraintType, Double) Adds a constraint that is defined by an expression to the nonlinear program.
AddSymbolicConstraint(String, Expression<Func<Vector<Double>, Double>>, Double, Double) Adds a constraint that is defined by an expression to the nonlinear program.
AddVariable(String) Adds a variable to the collection.
(Inherited from OptimizationModel)
AddVariable(String, Double, Double) Adds a variable to the collection.
(Inherited from OptimizationModel)
CreateLinearConstraints(Matrix<Double>, Vector<Double>, Int32) Creates linear constraints based on the specified coefficients.
(Inherited from OptimizationModel)
CreateLinearConstraints(Vector<Double>, Matrix<Double>, Vector<Double>) Creates linear constraints based on the specified coefficients and bounds.
(Inherited from OptimizationModel)
EqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
FinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object)
GetHashCodeServes as the default hash function.
(Inherited from Object)
GetSolution Gets the solution to the optimization model.
(Inherited from OptimizationModel)
GetTypeGets the Type of the current instance.
(Inherited from Object)
MemberwiseCloneCreates a shallow copy of the current Object.
(Inherited from Object)
OnAddConstraint Notifies the optimization model that a constraint has been added.
(Inherited from OptimizationModel)
OnAddVariable Notifies the optimization model that a variable has been added.
(Inherited from OptimizationModel)
OnRemoveAllConstraints Notifies the optimization model that all constraints has been removed.
(Inherited from OptimizationModel)
OnRemoveAllVariables Notifies the optimization model that all variables has been removed.
(Inherited from OptimizationModel)
OnRemoveConstraint Notifies the optimization model that a constraint has been removed.
(Inherited from OptimizationModel)
OnRemoveVariable Notifies the optimization model that a variable has been removed.
(Inherited from OptimizationModel)
Solve Solves the model and returns the solution.
(Inherited from OptimizationModel)
SolveModel Solves the nonlinear program and returns the primal solution.
(Overrides OptimizationModel.SolveModel())
ToStringReturns a string that represents the current object.
(Inherited from Object)

See Also