/// ------------------------------------------------------
/// SwarmOps - Numeric and heuristic optimization for C#
/// Copyright (C) 2003-2011 Magnus Erik Hvass Pedersen.
/// Please see the file license.txt for license details.
/// SwarmOps on the internet: http://www.Hvass-Labs.org/
/// ------------------------------------------------------
namespace SwarmOps.Problems
{
///
/// Helper-methods for Penalized benchmark problems.
///
public abstract class Penalized : Benchmark
{
#region Constructors.
///
/// Construct the object.
///
/// Dimensionality of the problem.
/// Lower boundary for entire search-space.
/// Upper boundary for entire search-space.
/// Lower boundary for initialization.
/// Upper boundary for initialization.
/// Max optimization iterations to perform.
public Penalized(
int dimensionality,
double lowerBound,
double upperBound,
double lowerInit,
double upperInit,
int maxIterations)
: base(dimensionality, lowerBound, upperBound, lowerInit, upperInit, maxIterations)
{
}
#endregion
#region Penalize helper methods.
///
/// Helper-method for Penalized benchmark problems.
///
protected double U(double x, double a, double k, double m)
{
double value;
if (x < -a)
{
value = k * System.Math.Pow(-x - a, m);
}
else if (x > a)
{
value = k * System.Math.Pow(x - a, m);
}
else
{
value = 0;
}
return value;
}
#endregion
}
}