You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by lu...@apache.org on 2011/11/29 20:35:41 UTC
svn commit: r1208041 -
/commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/direct/MultivariateFunctionPenaltyAdapter.java
Author: luc
Date: Tue Nov 29 19:35:40 2011
New Revision: 1208041
URL: http://svn.apache.org/viewvc?rev=1208041&view=rev
Log:
Fixed ignored scale in penalty function adapter for direct optimizers.
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/direct/MultivariateFunctionPenaltyAdapter.java
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/direct/MultivariateFunctionPenaltyAdapter.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/direct/MultivariateFunctionPenaltyAdapter.java?rev=1208041&r1=1208040&r2=1208041&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/direct/MultivariateFunctionPenaltyAdapter.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/direct/MultivariateFunctionPenaltyAdapter.java Tue Nov 29 19:35:40 2011
@@ -152,11 +152,12 @@ public class MultivariateFunctionPenalty
/** Compute the underlying function value from an unbounded point.
* <p>
- * This method simply bounds the unbounded point using the mappings
- * set up at construction and calls the underlying function using
- * the bounded point.
+ * This method simply returns the value of the underlying function
+ * if the unbounded point already fulfills the bounds, and compute
+ * a replacement value using the offset and scale if bounds are
+ * violated, without calling the function at all.
* </p>
- * @see #unboundedToBounded(double[])
+ * @return either underlying function value or penalty function value
*/
public double value(double[] point) {
@@ -167,9 +168,9 @@ public class MultivariateFunctionPenalty
for (int j = i; j < scale.length; ++j) {
final double overshoot;
if (point[j] < lower[j]) {
- overshoot = lower[j] - point[j];
+ overshoot = scale[j] * (lower[j] - point[j]);
} else if (point[j] > upper[j]) {
- overshoot = point[j] - upper[j];
+ overshoot = scale[j] * (point[j] - upper[j]);
} else {
overshoot = 0;
}