using System;
using System.Collections.Generic;
using System.Text;
namespace DotNumerics.Optimization
{
///
/// Represents a varaible that can be used in optimization classes.
///
public class OptVariable
{
#region Fields
///
/// The variable name.
///
protected string _Name = "P";
///
/// The initial guess for this variable.
///
protected double _InitialGuess = 1;
///
/// Value that indicates if the variable is fixed.
///
protected bool _Fixed = false;
#endregion
#region Constructor
///
/// Initializes a new instance of the OptVariable class.
///
public OptVariable()
{
}
///
/// Initializes a new instance of the OptVariable class.
///
/// The initial guess.
public OptVariable(double initialGuess)
{
this._InitialGuess = initialGuess;
}
///
/// Initializes a new instance of the OptVariable class.
///
/// The variable name.
/// The initial guess.
public OptVariable(string name, double initialGuess)
{
this._Name = name;
this._InitialGuess = initialGuess;
}
///
/// Initializes a new instance of the OptVariable class.
///
/// The initial guess.
/// Value that indicates if the variable is fixed.
public OptVariable(double initialGuess, bool isFixed)
{
this._InitialGuess = initialGuess;
this._Fixed = isFixed;
}
///
/// Initializes a new instance of the OptVariable class.
///
/// The variable name.
/// The initial guess.
/// Value that indicates if the variable is fixed.
public OptVariable(string name, double initialGuess, bool isFixed)
{
this._Name = name;
this._InitialGuess = initialGuess;
this._Fixed = isFixed;
}
#endregion
#region Properties
///
/// The variable name.
///
public string Name
{
get { return _Name; }
set { _Name = value; }
}
///
/// The initial guess for this variable.
///
public double InitialGuess
{
get { return _InitialGuess; }
set { _InitialGuess = value; }
}
///
/// Value that indicates if the variable is fixed.
///
public bool Fixed
{
get { return _Fixed; }
set { _Fixed = value; }
}
#endregion
public override string ToString()
{
string s = "n: " + this._Name + ", ig: " + this.InitialGuess.ToString() + ", f: " + this.Fixed.ToString();
return s;
}
}
}