« Previous « Start » Next »
7 Problem Reference
The following sections contain detailed descriptions of all types of
TOMNETProblem present in TOMNET.
The final parts describe four interfaces that are central when
modeling any function or constraint that is not linear or quadratic:
-
IFunction:
interface to Function (see 7.8).
- IDFunction:
interface to Differentiable Function (see 7.9).
- IConstraints:
interface to Constraints (see 7.10).
- IDConstraints:
interface to Differentiable Constraints (see 7.11).
These Interfaces function as a sort of templates that help the
solver evaluate the objective function and constraints.
7.1 class LinearProblem
Description
One of the basic classes of TOMNET is
LinearProblem. It is
used for modeling
TOMNETProblem's with a linear objective
function and only linear constraints. See
linear
programming in
3.1.6.
Calling Syntax
LinearProblem Prob = new LinearProblem(c, A, b_L, b_U, x_L, x_U,
x_0, Name, double.NegativeInfinity, null, null);
| Constructor Inputs |
| |
|
double[] c |
The vector c in the objective function. |
| |
| object A |
The linear constraints (a double[] or a Sparse). |
| |
| double[] b_L |
The lower bounds for the linear constraints. |
| double[] b_U |
The upper bounds for the linear constraints. |
| |
| double[] x_L |
Lower bounds on x. |
| double[] x_U |
Upper bounds on x. |
| double[] x_0 |
Starting point x. |
| |
| String Name |
The name of the problem. |
| |
| double fLowBnd |
A lower bound on the function value at optimum if known.
If not known set to NegativeInfinity. |
| |
| double[] f_opt |
Optimal function value(s), if known (Stationary points). If not known set Null. |
| double[] x_opt |
The x-values corresponding to the given f_opt, if known. If not known set Null. |
7.2 class QuadraticProblem
Description
The class
QuadraticProblem is used for modeling a
TOMNETProblem with a quadratic objective function and only
linear constraints. See
quadratic programming in
3.1.2.
Calling Syntax
QuadraticProblem Prob = QuadraticProblem.qpAssign(F, c, A,
b_L, b_U, x_L, x_U, x_0, Name);
| Constructor Inputs |
| |
|
object F |
The matrix F in the objective function (a double[] or a Sparse). |
| |
| double[] c |
The vector c in the objective function. |
| |
| object A |
The linear constraints (a double[] or a Sparse). |
| |
| double[] b_L |
The lower bounds for the linear constraints. |
| double[] b_U |
The upper bounds for the linear constraints. |
| |
| double[] x_L |
Lower bounds on x. |
| double[] x_U |
Upper bounds on x. |
| double[] x_0 |
Starting point x. |
| |
| String Name |
The name of the problem. |
| |
7.3 class NonlinearProblem
Description
A
NonlinearProblem is used to model a problem with a general
objective function and linear constraints. The user needs to
implement a class that inherits from either the interface
IDFunction (see
7.9) or
IFunction (see
7.8) to model the objective function.
It is always better to use
IDFunction and describe the
derivatives analytically. If the derivatives are impossible or very
hard to model numerical differentiation can be used by implementing
an
IFunction, this may however result in loss of robustness.
For an example of how to use the
IFunction the reader is
encouraged to see
nlpQG.cs in
tomnet/quickguide and
compare
NonlinearProblem with
ConProblem in
7.4.
To create an unconstrained optimization problem (see
unconstrained optimization 3.1.1) call the
constructor with
Null-parameters instead of
A,
b_L and
b_U.
Calling Syntax
//
// User-defined objective function
//
public class myNLPFunc : IDFunction { /* ... */ }
//
// NonlinearProblem needs an instance of myNLPFunc
//
myNLPFunc F = new myNLPFunc();
NonlinearProblem Prob = new NonlinearProblem(F, A, b_L, b_U,
x_L, x_U, x_0, Name, double.NegativeInfinity, null, null);
| Constructor Inputs |
| |
|
IFunction F |
User-defined objective function (see 7.8 and 7.9). |
| |
| object A |
The linear constraints (a double[] or a Sparse). |
| |
| double[] b_L |
The lower bounds for the linear constraints. |
| double[] b_U |
The upper bounds for the linear constraints. |
| |
| double[] x_L |
Lower bounds on x. |
| double[] x_U |
Upper bounds on x. |
| double[] x_0 |
Starting point x. |
| |
| String Name |
The name of the problem. |
| |
| double fLowBnd |
A lower bound on the function value at optimum if known.
If not known set to NegativeInfinity. |
| |
| double[] f_opt |
Optimal function value(s), if known (Stationary points). If not known set Null. |
| double[] x_opt |
The x-values corresponding to the given f_opt, if known. If not known set Null. |
7.4 class ConProblem
Description
One of the more general classes for modeling a problem in TOMNET is
ConProblem. It requires coding of an objective function and
nonlinear constraints by the user.
For an extensive example the reader is encouraged to see
nlpQG.cs in
tomnet/quickguide . Also see
constrained nonlinear programming in
3.1.3.
The user needs to implement a class that inherits from either the
interface
IFunction (see
7.8) or
IDFunction
(see
7.9) to model the objective function. Also the
nonlinear constraints must be modeled in a class that inherits from
IConstraints (see
7.10) or
IDConstraints
(see
7.11).
Calling Syntax
//
// User-defined objective function class myConFunc
// and nonlinear constraints class myConCons.
//
public class myConFunc : IDFunction { /* ... */ }
public class myConCons : IDConstraints { /* ... */ }
//
// ConProblem needs an instance of IDFunction and IDConstraints
//
myConFunc myF = new myConFunc();
myConCons myC = new myConCons();
TOMNETProblem Prob = new ConProblem(myF, myC, c_L, c_U, x_L, x_U,
x_0, Name, double.NegativeInfinity, null, null);
| Constructor Inputs |
| |
|
IFunction F |
User-defined objective function (see 7.8 and 7.9). |
| |
| IConstraints C |
User-defined nonlinear constraints (see 7.10 and 7.11). |
| |
| double[] c_L |
The lower bounds for the nonlinear constraints. |
| double[] c_U |
The upper bounds for the nonlinear constraints. |
| |
| double[] x_L |
Lower bounds on x. |
| double[] x_U |
Upper bounds on x. |
| double[] x_0 |
Starting point x. |
| |
| String Name |
The name of the problem. |
| |
| double fLowBnd |
A lower bound on the function value at optimum if known.
If not known set to NegativeInfinity. |
| |
| double[] f_opt |
Optimal function value(s), if known (Stationary points). If not known set Null. |
| double[] x_opt |
The x-values corresponding to the given f_opt, if known. If not known set Null. |
7.5 class ConLinProblem
Description
One of the more general classes for modeling a problem in TOMNET is
ConLinProblem. It requires coding of the objective function
and nonlinear constraints by the user. See
3.1.1 for a
formal definition.
For a detailed example the reader is encouraged to see
A.2.
The user needs to implement a class that inherits from either the
interface
IFunction (see
7.8) or
IDFunction
(see
7.9) to model the objective function. Also the
nonlinear constraints must be modeled in a class that inherits from
IConstraints (see
7.10) or
IDConstraints
(see
7.11).
Calling Syntax
//
// User-defined objective function class myConFunc
// and nonlinear constraints class myConCons.
//
public class myConFunc : IDFunction { /* ... */ }
public class myConCons : IDConstraints { /* ... */ }
//
// ConLinProblem needs an myConFunc and a myConCons
//
myConFunc myF = new myConFunc();
myConCons myC = new myConCons();
ConLinProblem Prob = new ConLinProblem(myF, A, b_L, b_U,
myC, c_L, c_U, x_L, x_U, x_0, Name, double.NegativeInfinity,
null, null);
| Constructor Inputs |
| |
|
IFunction F |
User-defined objective function (see 7.8 and 7.9). |
| |
| IConstraints A |
Linear Constraints (a Sparse or a double[]). |
| |
| double[] b_L |
The lower bounds for the linear constraints. |
| double[] b_U |
The upper bounds for the linear constraints. |
| |
| IConstraints C |
User-defined nonlinear constraints (see 7.10 and 7.11). |
| |
| double[] c_L |
The lower bounds for the non linear constraints. |
| double[] c_U |
The upper bounds for the non linear constraints. |
| |
| double[] x_L |
Lower bounds on x. |
| double[] x_U |
Upper bounds on x. |
| double[] x_0 |
Starting point x. |
| |
| String Name |
The name of the problem. |
| |
| double fLowBnd |
A lower bound on the function value at optimum if known.
If not known set to NegativeInfinity. |
| |
| double[] f_opt |
Optimal function value(s), if known (Stationary points). If not known set Null. |
| double[] x_opt |
The x-values corresponding to the given f_opt, if known. If not known set Null. |
7.6 class LinearLeastSquaresProblem
Description
The
LinearLeastSquaresProblem efficiently models all
linear least squares problem (see
3.1.8 for
definitions).
Calling Syntax
LinearLeastSquaresProblem Prob = new LinearLeastSquaresProblem(
n, m, k, C, d, A, b_L, b_U, x_0, x_L, x_U);
| Constructor Inputs |
| |
|
int n |
Number of variables. |
| int m |
Number of linear constraints. |
| int k |
Number of residuals. |
| |
| double[] C |
C matrix of the objective function. |
| double[] y |
The observations. |
| |
| double[] A |
The linear constraints. |
| |
| double[] b_L |
The lower bounds for the linear constraints. |
| double[] b_U |
The upper bounds for the linear constraints. |
| |
| double[] x_L |
Lower bounds on x. |
| double[] x_U |
Upper bounds on x. |
| double[] x_0 |
Starting point x. |
7.7 class NonlinearLeastSquaresProblem
Description
In TOMNET
NonlinearLeastSquaresProblem can be used to model a
nonlinear least squares problem with nonlinear constraints. See
constrained nonlinear least squares problem in
3.1.9 for definitions. Also see
nllsQG.cs in
tomnet/quickguide for a comprehensive example.
Calling Syntax
NonlinearLeastSquaresProblem Prob = new
NonlinearLeastSquaresProblem(R, C, A, b_L, b_U, x_L, x_U, x_0,
c_L, c_U, y, t, "NllsProb", double.NegativeInfinity, null,
null);
| Constructor Inputs |
| |
|
IFunction F |
User-defined objective function (see 7.8 and 7.9). |
| IConstraints C |
User-defined nonlinear constraints (see 7.10 and 7.11). |
| |
| object A |
The linear constraints. |
| |
| double[] b_L |
The lower bounds for the linear constraints. |
| double[] b_U |
The upper bounds for the linear constraints. |
| |
| double[] x_L |
Lower bounds on x. |
| double[] x_U |
Upper bounds on x. |
| double[] x_0 |
Starting point x. |
| |
| double[] c_L |
The lower bounds for the nonlinear constraints. |
| double[] c_U |
The upper bounds for the nonlinear constraints. |
| |
| double[] y |
The observations. |
| double[] t |
Array of time points of observations. |
| |
| String Name |
The name of the problem. |
| |
| double fLowBnd |
A lower bound on the function value at optimum if known.
If not known set to NegativeInfinity. |
| |
| double[] f_opt |
Optimal function value(s), if known (Stationary points). If not known set Null. |
| double[] x_opt |
The x-values corresponding to the given f_opt, if known. If not known set Null. |
7.8 Interface IFunction
Description
An
IFunction is used to model a problem with any scalar
objective function. It is preferable to use
IDFunction (see
7.9) and define the gradient of the objective function
to gain robustness and speed.
Calling Syntax
To use an
IFunction the method
Evaluate must be
implemented.
public class myObjective : IFunction
{
public void Evaluate(double[] fx, double[] x)
{
// ...
}
}
| Methods to Implement |
| |
|
void Evaluate(double[] fx, double[] x) |
User-defined objective function. |
Examples
See
A.2 for an example of how
to use
IFunction,
IDFunction,
IConstraints and/or
IDConstraints.
7.9 Interface IDFunction
Description
An
IDFunction is used to model a any scalar objective function
where the gradients are known.
IDFunction inherits from
IFunction
so any
IDFunction is also an
IFunction.
Calling Syntax
To use an
IDFunction two methods needs to be
implemented:
Evaluate (for the function value)
and
Grad for the values of the gradient.
public class myObjective : IDFunction
{
public void Evaluate(double[] fx, double[] x)
{
// ...
}
public void Grad(double[] gx, double[] x)
{
// ...
}
}
| Methods to Implement |
| |
|
void Evaluate(double[] fx, double[] x) |
User-defined objective function. |
| void Grad(double[] gx, double[] x) |
User-defined gradient. |
Examples
See
A.2 for an example of how
to use
IFunction,
IDFunction,
IConstraints and/or
IDConstraints.
7.10 Interface IConstraints
Description
An
IConstraints
is used to model a problem with any nonlinear constraints.
It is preferable to use
IDConstraints (see
7.11)
and define the derivatives of the constraints
to gain robustness and speed.
Calling Syntax
To use an
IConstraints two
Evaluate methods
must be implemented.
public class myConstraints : IConstraints
{
public void Evaluate(double[] cx, double[] x)
{
// ...
}
public double[] Evaluate(double[] x)
{
// ...
}
}
| Methods to Implement |
| |
|
void Evaluate(double[] cx, double[] x) |
Evalate the constraints. |
| double[] Evaluate(double[] x) |
Evalate the constraints. |
Examples
See
A.2 for an example of how
to use
IFunction,
IDFunction,
IConstraints and/or
IDConstraints.
7.11 Interface IDConstraints
Description
An
IDConstraints is used to model a any
constraints function where the gradients
can be expressed analytically.
IDConstraints inherits from
IConstraints
so any
IDConstraints is also an
IConstraints.
Calling Syntax
To use an
IDConstraints the methods
Evaluate
and
dc
must be implemented.
public class myConstraints : IDConstraints
{
public void Evaluate(double[] cx, double[] x)
{
// ...
}
public double[] Evaluate(double[] x)
{
// ...
}
public void dc(Jacobian dcx, double[] x)
{
// ...
}
}
| Methods to Implement |
| |
|
void Evaluate(double[] cx, double[] x) |
Evaluate the constraints. |
| double[] Evaluate(double[] x) |
Evaluate the constraints. |
| void dc(Jacobian dcx, double[] x) |
Evaluate the derivatives of the constraints. |
Examples
See
A.2 for an example of how to use
IFunction,
IDFunction,
IConstraints and/or
IDConstraints.
« Previous « Start » Next »