public class ParameterOptimizerIterationResults extends Object implements ICloneWithContext
ParameterOptimizer
. This includes
the unperturbed run of the Function
(get
/ set
) and all of the perturbed
runs of the Function
(get
/ set
) for one time through the
ParameterOptimizer
.Modifier | Constructor and Description |
---|---|
|
ParameterOptimizerIterationResults(OptimizerMultivariableFunctionResults functionResult,
OptimizerMultivariableFunctionDerivativeResults derivativeResults,
int iteration,
SolverVariableSettings[] variableSettings,
CostFunctionSettings costFunctionSettings,
SolverConstraintSettings[] equalitySettings,
InequalityConstraintSettings[] inequalitySettings)
Initializes a new instance.
|
protected |
ParameterOptimizerIterationResults(ParameterOptimizerIterationResults existingInstance,
CopyContext context)
Initializes a new instance as a copy of an existing instance.
|
public ParameterOptimizerIterationResults(OptimizerMultivariableFunctionResults functionResult, OptimizerMultivariableFunctionDerivativeResults derivativeResults, int iteration, @Nonnull SolverVariableSettings[] variableSettings, @Nullable CostFunctionSettings costFunctionSettings, @Nullable SolverConstraintSettings[] equalitySettings, @Nullable InequalityConstraintSettings[] inequalitySettings)
functionResult
- The results of the computed OptimizerMultivariableFunction
.derivativeResults
- The OptimizerMultivariableFunctionDerivativeResults
that were computed
when the derivative of the function
was evaluated. This can be optional if
the derivative of the function was not evaluated in the iteration that made these results (as can happen on the final iteration).iteration
- The count of the iteration that produced these results. This should be zero based.variableSettings
- The settings of the variables that were used to compute all of the function evaluations.costFunctionSettings
- The settings of the cost function that was computed in all of the function evaluations.equalitySettings
- The settings of the equality constraints that were computed in all of the function evaluations.inequalitySettings
- The settings of the inequality constraints that were computed in all of the function evaluations.protected ParameterOptimizerIterationResults(@Nonnull ParameterOptimizerIterationResults existingInstance, @Nonnull CopyContext context)
See ICloneWithContext.clone(CopyContext)
for more information about how to implement this constructor
in a derived class.
existingInstance
- The existing instance to copy.context
- A CopyContext
that controls the depth of the copy.ArgumentNullException
- Thrown when existingInstance
or context
is null
.public Object clone(CopyContext context)
This method should be implemented to call a copy constructor on the class of the
object being cloned. The copy constructor should take the CopyContext
as a parameter
in addition to the existing instance to copy. The copy constructor should first call
CopyContext.addObjectMapping(T, T)
to identify the newly constructed instance
as a copy of the existing instance. It should then copy all fields, using
CopyContext.updateReference(T)
to copy any reference fields.
A typical implementation of ICloneWithContext
:
public static class MyClass implements ICloneWithContext {
public MyClass(MyClass existingInstance, CopyContext context) {
context.addObjectMapping(existingInstance, this);
someReference = context.updateReference(existingInstance.someReference);
}
@Override
public final Object clone(CopyContext context) {
return new MyClass(this, context);
}
private Object someReference;
}
In general, all fields that are reference types should be copied with a call to
CopyContext.updateReference(T)
. There are a couple of exceptions:
If one of these exceptions applies, the CopyContext
should be given an opportunity
to update the reference before the reference is copied explicitly. Use
CopyContext.updateReference(T)
to update the reference. If CopyContext.updateReference(T)
returns
the original object, indicating that the context does not have a replacement registered,
then copy the object manually by invoking a Clone method, a copy constructor, or by manually
constructing a new instance and copying the values.
alwaysCopy = context.updateReference(existingInstance.alwaysCopy);
if (existingInstance.alwaysCopy != null && alwaysCopy == existingInstance.alwaysCopy) {
alwaysCopy = (AlwaysCopy) existingInstance.alwaysCopy.clone(context);
}
If you are implementing an evaluator (a class that implements IEvaluator
), the
IEvaluator.updateEvaluatorReferences(agi.foundation.infrastructure.CopyContext)
method shares some responsibilities with the
copy context constructor. Code duplication can be avoided by doing the following:
CopyContext.updateReference(T)
. You should still call CopyContext.updateReference(T)
on any references to
non-evaluators.
IEvaluator.updateEvaluatorReferences(agi.foundation.infrastructure.CopyContext)
as the last line in the constructor and pass it the
same CopyContext
passed to the constructor.
IEvaluator.updateEvaluatorReferences(agi.foundation.infrastructure.CopyContext)
as normal. See the reference documentation for
IEvaluator.updateEvaluatorReferences(agi.foundation.infrastructure.CopyContext)
for more information on implementing that method.
public MyClass(MyClass existingInstance, CopyContext context) {
super(existingInstance, context);
someReference = context.updateReference(existingInstance.someReference);
evaluatorReference = existingInstance.evaluatorReference;
updateEvaluatorReferences(context);
}
@Override
public void updateEvaluatorReferences(CopyContext context) {
evaluatorReference = context.updateReference(evaluatorReference);
}
@Override
public Object clone(CopyContext context) {
return new MyClass(this, context);
}
private Object someReference;
private IEvaluator evaluatorReference;
clone
in interface ICloneWithContext
context
- The context to use to perform the copy.public final OptimizerMultivariableFunctionDerivativeResults getDerivativeResults()
function's
derivative.public final OptimizerMultivariableFunctionResults getFunctionResult()
public final int getIteration()
public final CostFunctionSettings getCostFunctionSettings()
public final OptimizerMultivariableFunctionResults getPerturbedResults(int index)
results
of the
Function
(get
/ set
) when the variable
with the same index
in the ParameterOptimizer
was perturbed for this iteration.
Note that this may return null
if the Jacobian of the function that made these results was computed
analytically or if index
is higher than the number of variables in the function.index
- The index of the results to get.Function
(get
/ set
) when the variable
with the same index
in the ParameterOptimizer
was perturbed for this iteration.public final SolverConstraintSettings[] getEqualityConstraintSettings()
SolverConstraintSettings
that correspond to the
equality constraints computed by the function
.
The order of the SolverConstraintSettings
in this array matches the order of the computed values.SolverConstraintSettings
that correspond to the values computed by all the
function evaluations in this set of results.public final InequalityConstraintSettings[] getInequalityConstraintSettings()
SolverConstraintSettings
that correspond to the
inequality constraints computed by the function
.
The order of the SolverConstraintSettings
in this array matches the order of the computed values.SolverConstraintSettings
that correspond to the values computed by all the
function evaluations in this set of results.public final SolverVariableSettings[] getVariableSettings()
SolverVariableSettings
that correspond to the variable values used to compute
all of the function evaluations. The order of the SolverVariableSettings
in this array matches
the order of the variable values.SolverVariableSettings
that correspond to the values used to compute all the
function evaluations in this set of results.public final int indexOfEqualityConstraint(SolverConstraintSettings constraint)
SolverConstraintSettings
in the array that is returned by the
ParameterOptimizerIterationResults.getEqualityConstraintSettings()
method. This index also corresponds to the evaluated value
in the array returned by the OptimizerMultivariableFunctionResults.getEqualityConstraintValues()
of
every OptimizerMultivariableFunctionResults
stored in this set of results.constraint
- The SolverConstraintSettings
whose index is desired.SolverConstraintSettings
matching the constraint
and constraint value in all of the OptimizerMultivariableFunctionResults
stored in this, or -1 if the
SolverConstraintSettings
is not stored in this set of results.public final int indexOfEqualityConstraint(@Nullable String constraintName)
SolverConstraintSettings
with the matching
constraintName
in the array that is returned by the
ParameterOptimizerIterationResults.getEqualityConstraintSettings()
method. This index also corresponds to the evaluated value
in the array returned by the OptimizerMultivariableFunctionResults.getEqualityConstraintValues()
of
every OptimizerMultivariableFunctionResults
stored in this set of results.constraintName
- The name of the SolverConstraintSettings
whose index is desired.SolverConstraintSettings
with the matching constraintName
and constraint value in all of the OptimizerMultivariableFunctionResults
stored in this, or -1 if the
SolverConstraintSettings
is not stored in this set of results.public final int indexOfInequalityConstraint(InequalityConstraintSettings constraint)
InequalityConstraintSettings
in the array that is returned by the
ParameterOptimizerIterationResults.getInequalityConstraintSettings()
method. This index also corresponds to the evaluated value
in the array returned by the OptimizerMultivariableFunctionResults.getInequalityConstraintValues()
of
every OptimizerMultivariableFunctionResults
stored in this set of results.constraint
- The InequalityConstraintSettings
whose index is desired.InequalityConstraintSettings
matching the constraint
and constraint value in all of the OptimizerMultivariableFunctionResults
stored in this, or -1 if the
InequalityConstraintSettings
is not stored in this set of results.public final int indexOfInequalityConstraint(@Nullable String constraintName)
InequalityConstraintSettings
with the matching
constraintName
in the array that is returned by the
ParameterOptimizerIterationResults.getInequalityConstraintSettings()
method. This index also corresponds to the evaluated value
in the array returned by the OptimizerMultivariableFunctionResults.getInequalityConstraintValues()
of
every OptimizerMultivariableFunctionResults
stored in this set of results.constraintName
- The name of the InequalityConstraintSettings
whose index is desired.InequalityConstraintSettings
with the matching constraintName
and constraint value in all of the OptimizerMultivariableFunctionResults
stored in this, or -1 if the
InequalityConstraintSettings
is not stored in this set of results.public final int indexOfVariable(SolverVariableSettings variable)
SolverVariableSettings
in the array that is returned by the
ParameterOptimizerIterationResults.getVariableSettings()
method. This index also corresponds to the variable values
in the array returned by the OptimizerMultivariableFunctionResults.getVariablesUsed()
of
every OptimizerMultivariableFunctionResults
stored in this set of results.variable
- The SolverVariableSettings
whose index is desired.SolverVariableSettings
matching the variable
and variable value in all of the OptimizerMultivariableFunctionResults
stored in this, or -1 if the
SolverVariableSettings
is not stored in this set of results.public final int indexOfVariable(@Nullable String variableName)
SolverVariableSettings
with the matching
variableName
in the array that is returned by the
ParameterOptimizerIterationResults.getVariableSettings()
method. This index also corresponds to the variable value
in the array returned by the OptimizerMultivariableFunctionResults.getVariablesUsed()
of
every OptimizerMultivariableFunctionResults
stored in this set of results.variableName
- The name of the SolverVariableSettings
whose index is desired.SolverVariableSettings
with the matching variableName
and variable value in all of the OptimizerMultivariableFunctionResults
stored in this, or -1 if the
SolverVariableSettings
is not stored in this set of results.