#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 OptSimplexVariable : OptVariable { #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 OptSimplexVariable class. /// public OptSimplexVariable() { } /// /// Initializes a new instance of the OptSimplexVariable class. /// /// The initial guess. public OptSimplexVariable(double initialGuess) { this._InitialGuess = initialGuess; } /// /// Initializes a new instance of the OptSimplexVariable class. /// /// The variable name. /// The initial guess. public OptSimplexVariable(string name, double initialGuess) { this._Name = name; this._InitialGuess = initialGuess; } /// /// Initializes a new instance of the OptSimplexVariable class. /// /// The initial guess. /// A scale factor used to control the changes and accuracy of this variable. public OptSimplexVariable(double initialGuess, double scaleFactor) { this._InitialGuess = initialGuess; this.ScaleFactor = scaleFactor; } /// /// Initializes a new instance of the OptSimplexVariable class. /// /// The initial guess. /// Value that indicates if the variable is fixed. public OptSimplexVariable(double initialGuess, bool isFixed) { this._InitialGuess = initialGuess; this._Fixed = isFixed; } /// /// Initializes a new instance of the OptSimplexVariable class. /// /// The variable name. /// The initial guess. /// Value that indicates if the variable is fixed. public OptSimplexVariable(string name, double initialGuess, bool isFixed) { this._Name = name; this._InitialGuess = initialGuess; this._Fixed = isFixed; } /// /// Initializes a new instance of the OptSimplexVariable 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 OptSimplexVariable(double initialGuess, bool isFixed , double scaleFactor) { this._InitialGuess = initialGuess; this._Fixed = isFixed; this.ScaleFactor = scaleFactor; } /// /// Initializes a new instance of the OptSimplexVariable 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 OptSimplexVariable(string name, double initialGuess, bool isFixed, double scaleFactor) { this._Name = name; this._InitialGuess = initialGuess; this._Fixed = isFixed; this.ScaleFactor = scaleFactor; } #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 public override string ToString() { string s = "n: " + this._Name + ", ig: " + this.InitialGuess.ToString() + ", f: " + this.Fixed.ToString() + ", s: " + this._ScaleFactor.ToString(); return s; } } }