类 MultivariateFunctionPenaltyAdapter
- 所有已实现的接口:
-
MultivariateFunction
Adapter extending bounded MultivariateFunction
to an unbouded domain using a penalty function.
This adapter can be used to wrap functions subject to simple bounds on parameters so they can be used by optimizers that do not directly support simple bounds.
The principle is that the user function that will be wrapped will see its parameters bounded as required, i.e when its value
method is called with argument array point
, the elements array will fulfill requirement lower[i] <= point[i] <= upper[i]
for all i. Some of the components may be unbounded or bounded only on one side if the corresponding bound is set to an infinite value. The optimizer will not manage the user function by itself, but it will handle this adapter and it is this adapter that will take care the bounds are fulfilled. The adapter value(double[])
method will be called by the optimizer with unbound parameters, and the adapter will check if the parameters is within range or not. If it is in range, then the underlying user function will be called, and if it is not the value of a penalty function will be returned instead.
This adapter is only a poor-man's solution to simple bounds optimization constraints that can be used with simple optimizers like SimplexOptimizer
. A better solution is to use an optimizer that directly supports simple bounds like CMAESOptimizer
or BOBYQAOptimizer
. One caveat of this poor-man's solution is that if start point or start simplex is completely outside of the allowed range, only the penalty function is used, and the optimizer may converge without ever entering the range.
- 另请参阅:
-
构造器概要
构造器说明MultivariateFunctionPenaltyAdapter
(MultivariateFunction bounded, double[] lower, double[] upper, double offset, double[] scale) 简单构造函数。 -
方法概要
-
构造器详细资料
-
MultivariateFunctionPenaltyAdapter
public MultivariateFunctionPenaltyAdapter(MultivariateFunction bounded, double[] lower, double[] upper, double offset, double[] scale) 简单构造函数。当优化器提供的点超出范围时,将使用惩罚函数的值代替基础函数的值。为了使此惩罚在优化过程中有效地拒绝此点,应谨慎定义惩罚函数值。该值计算如下:
penalty(point) = offset + ∑i[scale[i] * √|point[i]-boundary[i]|]
其中索引i对应于所有违反其边界的分量。
因此,在尝试函数最小化时,offset应大于基础函数的最大预期值,scale分量应全部为正。在尝试函数最大化时,offset应小于基础函数的最小预期值,scale分量应全部为负。这种惩罚函数的选择具有两个特性。首先,所有超出范围的点将返回比任何范围内点返回的函数值更差的值。其次,对于大边界违规,惩罚比小违规的惩罚更严重,因此优化器可以得知应搜索可接受点的方向。
- 参数:
-
bounded
- 有界函数 -
lower
- 输入参数数组的每个元素的下界(某些元素可能设置为Double.NEGATIVE_INFINITY
表示无界值) -
upper
- 输入参数数组的每个元素的上界(某些元素可能设置为Double.POSITIVE_INFINITY
表示无界值) -
offset
- 惩罚函数的基本偏移量 -
scale
- 惩罚函数的比例 - 抛出:
-
MathIllegalArgumentException
- 如果下界、上界和比例不一致,无论是按维度还是按边界值
-
-
方法详细资料
-
value
public double value(double[] point) 从无界点计算基础函数值。如果无界点已满足边界,则此方法简单地返回基础函数的值,如果违反了边界,则计算替代值使用偏移和比例,而根本不调用函数。
- 指定者:
-
value
在接口中MultivariateFunction
- 参数:
-
point
- 无界点 - 返回:
- 基础函数值或惩罚函数值
-