|
|
#region Copyright © 2009, De Santiago-Castillo JA. All rights reserved.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Text;
|
|
|
|
|
|
namespace DotNumerics.Optimization
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
public class OptBoundVariable: OptVariable
|
|
|
{
|
|
|
|
|
|
#region Fields
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected double _LowerBound = double.NegativeInfinity;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected double _UpperBound = double.PositiveInfinity;
|
|
|
|
|
|
private bool _UseBounds = true;
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
#region Constructor
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public OptBoundVariable()
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public OptBoundVariable(double initialGuess)
|
|
|
{
|
|
|
this._InitialGuess = initialGuess;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public OptBoundVariable(string name, double initialGuess)
|
|
|
{
|
|
|
this._Name = name;
|
|
|
this._InitialGuess = initialGuess;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public OptBoundVariable(double initialGuess, bool isFixed)
|
|
|
{
|
|
|
this._InitialGuess = initialGuess;
|
|
|
this._Fixed = isFixed;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public OptBoundVariable(string name, double initialGuess, bool isFixed)
|
|
|
{
|
|
|
this._Name = name;
|
|
|
this._InitialGuess = initialGuess;
|
|
|
this._Fixed = isFixed;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public OptBoundVariable(double initialGuess, double lowerBound, double upperBound)
|
|
|
{
|
|
|
this._InitialGuess = initialGuess;
|
|
|
this._LowerBound = lowerBound;
|
|
|
this._UpperBound = upperBound;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public OptBoundVariable(string name, double initialGuess, double lowerBound, double upperBound)
|
|
|
{
|
|
|
this._Name = name;
|
|
|
this._InitialGuess = initialGuess;
|
|
|
this._LowerBound = lowerBound;
|
|
|
this._UpperBound = upperBound;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public OptBoundVariable(double initialGuess, bool isFixed, double lowerBound, double upperBound)
|
|
|
{
|
|
|
this._InitialGuess = initialGuess;
|
|
|
this._Fixed = isFixed;
|
|
|
this._LowerBound = lowerBound;
|
|
|
this._UpperBound = upperBound;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public OptBoundVariable(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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public double LowerBound
|
|
|
{
|
|
|
get { return _LowerBound; }
|
|
|
set { _LowerBound = value; }
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public double UpperBound
|
|
|
{
|
|
|
get { return _UpperBound; }
|
|
|
set { _UpperBound = value; }
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region Internal Properites
|
|
|
|
|
|
internal bool UseBounds
|
|
|
{
|
|
|
get { return _UseBounds; }
|
|
|
set { _UseBounds = value; }
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region Methods
|
|
|
|
|
|
internal static OptBoundVariable[] GetClon(OptBoundVariable[] variables)
|
|
|
{
|
|
|
OptBoundVariable[] cloned = new OptBoundVariable[variables.Length];
|
|
|
for (int i = 0; i < variables.Length; i++)
|
|
|
{
|
|
|
cloned[i] = variables[i].GetClon();
|
|
|
}
|
|
|
return cloned;
|
|
|
}
|
|
|
|
|
|
internal OptBoundVariable GetClon()
|
|
|
{
|
|
|
OptBoundVariable clon = new OptBoundVariable(this._Name, this._InitialGuess, this._Fixed, this._LowerBound, this._UpperBound);
|
|
|
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;
|
|
|
return s;
|
|
|
}
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
}
|
|
|
}
|
|
|
|