#region Copyright © 2009, De Santiago-Castillo JA. All rights reserved.
//Copyright © 2009 Jose Antonio De Santiago-Castillo
//E-mail:JAntonioDeSantiago@gmail.com
//Web: www.DotNumerics.com
//
#endregion
using System;
using System.Collections.Generic;
using System.Text;
namespace DotNumerics.Optimization
{
///
/// Represents a varaible that can be used in a simplex optimization classe.
///
public class OptSimplexBoundVariable : OptBoundVariable
{
#region Fields
///
/// The scale factor controls the internal variable size. Variable=IntVar*ScaleFactor where IntVar is the internal variable.
/// Try to set the ScaleFactor of the same order that the variable, with this value the internal size will be near to 1 .
/// The default value is 1. This value modifies the changes and accuracy of this variable.
///
private double _ScaleFactor = 1;
#endregion
#region Constructor
///
/// Initializes a new instance of the OptSimplexBoundVariable class.
///
public OptSimplexBoundVariable()
{
}
///
/// Initializes a new instance of the OptSimplexBoundVariable class.
///
/// The initial guess.
public OptSimplexBoundVariable(double initialGuess)
{
this._InitialGuess = initialGuess;
}
///
/// Initializes a new instance of the OptSimplexBoundVariable class.
///
/// The initial guess.
/// Value that indicates if the variable is fixed.
public OptSimplexBoundVariable(double initialGuess, bool isFixed)
{
this._InitialGuess = initialGuess;
this._Fixed = isFixed;
}
///
/// Initializes a new instance of the OptSimplexBoundVariable class.
///
/// The variable name.
/// The initial guess.
public OptSimplexBoundVariable(string name, double initialGuess)
{
this._Name = name;
this._InitialGuess = initialGuess;
}
///
/// Initializes a new instance of the OptSimplexBoundVariable class.
///
/// The initial guess.
/// A scale factor used to control the changes and accuracy of this variable.
public OptSimplexBoundVariable(double initialGuess, double scaleFactor)
{
this._InitialGuess = initialGuess;
this.ScaleFactor = scaleFactor;
}
///
/// Initializes a new instance of the OptSimplexBoundVariable class.
///
/// The variable name.
/// The initial guess.
/// A scale factor used to control the changes and accuracy of this variable.
public OptSimplexBoundVariable(string name, double initialGuess, double scaleFactor)
{
this._Name = name;
this._InitialGuess = initialGuess;
this.ScaleFactor = scaleFactor;
}
///
/// Initializes a new instance of the OptSimplexBoundVariable class.
///
/// The initial guess.
/// Value that indicates if the variable is fixed.
/// A scale factor used to control the changes and accuracy of this variable.
public OptSimplexBoundVariable(double initialGuess, bool isFixed, double scaleFactor)
{
this._InitialGuess = initialGuess;
this._Fixed = isFixed;
this.ScaleFactor = scaleFactor;
}
///
/// Initializes a new instance of the OptSimplexBoundVariable class.
///
/// The variable name.
/// The initial guess.
/// Value that indicates if the variable is fixed.
/// A scale factor used to control the changes and accuracy of this variable.
public OptSimplexBoundVariable(string name, double initialGuess, bool isFixed, double scaleFactor)
{
this._Name = name;
this._InitialGuess = initialGuess;
this._Fixed = isFixed;
this.ScaleFactor = scaleFactor;
}
///
/// Initializes a new instance of the OptSimplexBoundVariable class.
///
/// The initial guess.
/// The lower bound.
/// The upper bound.
public OptSimplexBoundVariable(double initialGuess, double lowerBound, double upperBound)
{
this._InitialGuess = initialGuess;
this._LowerBound = lowerBound;
this._UpperBound = upperBound;
}
///
/// Initializes a new instance of the OptSimplexBoundVariable class.
///
/// The variable name.
/// The initial guess.
/// The lower bound.
/// The upper bound.
public OptSimplexBoundVariable(string name, double initialGuess, double lowerBound, double upperBound)
{
this._Name = name;
this._InitialGuess = initialGuess;
this._LowerBound = lowerBound;
this._UpperBound = upperBound;
}
///
/// Initializes a new instance of the OptSimplexBoundVariable class.
///
/// The initial guess.
/// The lower bound.
/// The upper bound.
/// A scale factor used to control the changes and accuracy of this variable.
public OptSimplexBoundVariable(double initialGuess, double lowerBound, double upperBound, double scaleFactor)
{
this._InitialGuess = initialGuess;
this._LowerBound = lowerBound;
this._UpperBound = upperBound;
this.ScaleFactor = scaleFactor;
}
///
/// Initializes a new instance of the OptSimplexBoundVariable class.
///
/// The variable name.
/// The initial guess.
/// The lower bound.
/// The upper bound.
/// A scale factor used to control the changes and accuracy of this variable.
public OptSimplexBoundVariable(string name, double initialGuess, double lowerBound, double upperBound, double scaleFactor)
{
this._Name = name;
this._InitialGuess = initialGuess;
this._LowerBound = lowerBound;
this._UpperBound = upperBound;
this.ScaleFactor = scaleFactor;
}
///
/// Initializes a new instance of the OptSimplexBoundVariable class.
///
/// The initial guess.
/// Value that indicates if the variable is fixed.
/// The lower bound.
/// The upper bound.
public OptSimplexBoundVariable(double initialGuess, bool isFixed, double lowerBound, double upperBound)
{
this._InitialGuess = initialGuess;
this._Fixed = isFixed;
this._LowerBound = lowerBound;
this._UpperBound = upperBound;
}
///
/// Initializes a new instance of the OptSimplexBoundVariable class.
///
/// The variable name.
/// The initial guess.
/// Value that indicates if the variable is fixed.
/// The lower bound.
/// The upper bound.
public OptSimplexBoundVariable(string name, double initialGuess, bool isFixed, double lowerBound, double upperBound)
{
this._Name = name;
this._InitialGuess = initialGuess;
this._Fixed = isFixed;
this._LowerBound = lowerBound;
this._UpperBound = upperBound;
}
#endregion
#region Properties
///
/// The scale factor controls the internal variable size. Variable=IntVar*ScaleFactor where IntVar is the internal variable.
/// Try to set the ScaleFactor of the same order that the variable, with this value the internal size will be near to 1 .
/// The default value is 1. This value modifies the changes and accuracy of this variable.
///
public double ScaleFactor
{
get { return _ScaleFactor; }
set
{
if (value <= 0)
{
value = 1;
}
_ScaleFactor = value;
}
}
#endregion
#region Methods
internal static OptSimplexBoundVariable[] GetClon(OptSimplexBoundVariable[] variables)
{
OptSimplexBoundVariable[] cloned = new OptSimplexBoundVariable[variables.Length];
for (int i = 0; i < variables.Length; i++)
{
cloned[i] = variables[i].GetClon();
}
return cloned;
}
internal OptSimplexBoundVariable GetClon()
{
OptSimplexBoundVariable clon = new OptSimplexBoundVariable(this._Name, this._InitialGuess, this._LowerBound, this._UpperBound, this._ScaleFactor);
clon.Fixed = this._Fixed;
return clon;
}
public override string ToString()
{
string s = "n: " + this._Name + ", ig: " + this.InitialGuess.ToString() + ", f: " + this.Fixed.ToString() + ", l: " + this._LowerBound + ", u:" + this._UpperBound + ", s: " + this._ScaleFactor.ToString();
return s;
}
#endregion
}
}