Table of Contents

Class ProblemState

Namespace
NanoQL.Numerics
Assembly
NanoQL.dll

The working state of a minimization: QuantLib's Problem, with its cost function and constraint, its current value, and the function value, gradient norm and evaluation counts a method leaves in it.

[WorkingType]
public sealed class ProblemState
Inheritance
ProblemState
Inherited Members

Remarks

A working type: mutable, owned by one computation and not thread-safe. An optimization method works through it, and a line search or a hybrid method passes it on, as QuantLib's pass their Problem&: Minimize(ProblemState, EndCriteria) continues from CurrentValue.

Value(Vector), Values(Vector), Gradient(Vector, Vector) and ValueAndGradient(Vector, Vector) call the cost function and count the evaluations, as QuantLib's do. A new state starts from the problem's initial value with no evaluations and no function value, as after Reset(), where QuantLib leaves the counts and values uninitialized until its methods reset them.

Constructors

ProblemState(Problem)

Initializes a new instance of the ProblemState class, at the problem's initial value.

public ProblemState(Problem problem)

Parameters

problem Problem

The problem.

Properties

Constraint

Gets the constraint.

public Constraint Constraint { get; }

Property Value

Constraint

CostFunction

Gets the cost function.

public CostFunction CostFunction { get; }

Property Value

CostFunction

CurrentValue

Gets or sets the current value of the local minimum. The getter returns the state's own vector; the setter copies its argument, as QuantLib's setCurrentValue takes its Array by value.

public Vector CurrentValue { get; set; }

Property Value

Vector

Remarks

state.CurrentValue += v calls the binary operator and the setter, so the state gets a new vector and a vector read from the getter before it keeps the old value.

FunctionEvaluation

Gets the number of evaluations of the cost function since the last Reset().

public int FunctionEvaluation { get; }

Property Value

int

FunctionValue

Gets or sets the value of the cost function at the current value, the last step's; null (QuantLib's Null<Real>()) after Reset().

public double? FunctionValue { get; set; }

Property Value

double?

GradientEvaluation

Gets the number of evaluations of the cost function's gradient since the last Reset().

public int GradientEvaluation { get; }

Property Value

int

GradientNormValue

Gets or sets the value of the cost function's gradient norm at the current value, the last step's; null (QuantLib's Null<Real>()) after Reset().

public double? GradientNormValue { get; set; }

Property Value

double?

Methods

Gradient(Vector, Vector)

The cost function's gradient written into gradient, counting a gradient evaluation.

public void Gradient(Vector gradient, Vector x)

Parameters

gradient Vector

The gradient, at least of x's size.

x Vector

The point.

Reset()

Sets the evaluation counts to 0 and the function value and gradient norm to null. It doesn't reset the current value.

public void Reset()

Value(Vector)

The cost function's value, counting a function evaluation.

public double Value(Vector x)

Parameters

x Vector

The point.

Returns

double

The cost.

ValueAndGradient(Vector, Vector)

The cost function's gradient written into gradient, and its value, counting a function and a gradient evaluation.

public double ValueAndGradient(Vector gradient, Vector x)

Parameters

gradient Vector

The gradient, at least of x's size.

x Vector

The point.

Returns

double

The cost.

Values(Vector)

The cost function's values, counting a function evaluation.

public Vector Values(Vector x)

Parameters

x Vector

The point.

Returns

Vector

A new vector of the values.