Download data/DWSIM.Math.DotNumerics/Optimization/OptBoundVariable.cs from introvoyz041/Dwsim: direct link, hf CLI and curl.
- Browser
- Download file 7.22 kB
-
https://huggingface.co/datasets/introvoyz041/Dwsim/resolve/main/data/DWSIM.Math.DotNumerics/Optimization/OptBoundVariable.cs
- Command line
-
hf download hf://datasets/introvoyz041/Dwsim/data/DWSIM.Math.DotNumerics/Optimization/OptBoundVariable.cs
-
curl -L -o OptBoundVariable.cs https://huggingface.co/datasets/introvoyz041/Dwsim/resolve/main/data/DWSIM.Math.DotNumerics/Optimization/OptBoundVariable.cs
7.22 kB
| | |
| //Copyright © 2009 Jose Antonio De Santiago-Castillo | |
| //E-mail:JAntonioDeSantiago@gmail.com | |
| //Web: www.DotNumerics.com | |
| // | |
| using System; | |
| using System.Collections.Generic; | |
| using System.Text; | |
| namespace DotNumerics.Optimization | |
| { | |
| /// <summary> | |
| /// Represents a varaible that can be used in optimization classes with bounded constrains. | |
| /// </summary> | |
| public class OptBoundVariable: OptVariable | |
| { | |
| /// <summary> | |
| /// The lower bound. | |
| /// </summary> | |
| protected double _LowerBound = double.NegativeInfinity; | |
| /// <summary> | |
| /// The upper bound. | |
| /// </summary> | |
| protected double _UpperBound = double.PositiveInfinity; | |
| private bool _UseBounds = true; | |
| /// <summary> | |
| /// Initializes a new instance of the OptBoundVariable class. | |
| /// </summary> | |
| public OptBoundVariable() | |
| { | |
| } | |
| /// <summary> | |
| /// Initializes a new instance of the OptBoundVariable class. | |
| /// </summary> | |
| /// <param name="initialGuess">The initial guess.</param> | |
| public OptBoundVariable(double initialGuess) | |
| { | |
| this._InitialGuess = initialGuess; | |
| } | |
| /// <summary> | |
| /// Initializes a new instance of the OptBoundVariable class. | |
| /// </summary> | |
| /// <param name="name">The variable name.</param> | |
| /// <param name="initialGuess">The initial guess.</param> | |
| public OptBoundVariable(string name, double initialGuess) | |
| { | |
| this._Name = name; | |
| this._InitialGuess = initialGuess; | |
| } | |
| /// <summary> | |
| /// Initializes a new instance of the OptBoundVariable class. | |
| /// </summary> | |
| /// <param name="initialGuess">The initial guess.</param> | |
| /// <param name="isFixed">Value that indicates if the variable is fixed.</param> | |
| public OptBoundVariable(double initialGuess, bool isFixed) | |
| { | |
| this._InitialGuess = initialGuess; | |
| this._Fixed = isFixed; | |
| } | |
| /// <summary> | |
| /// Initializes a new instance of the OptBoundVariable class. | |
| /// </summary> | |
| /// <param name="name">The variable name.</param> | |
| /// <param name="initialGuess">The initial guess.</param> | |
| /// <param name="isFixed">Value that indicates if the variable is fixed.</param> | |
| public OptBoundVariable(string name, double initialGuess, bool isFixed) | |
| { | |
| this._Name = name; | |
| this._InitialGuess = initialGuess; | |
| this._Fixed = isFixed; | |
| } | |
| /// <summary> | |
| /// Initializes a new instance of the OptBoundVariable class. | |
| /// </summary> | |
| /// <param name="initialGuess">The initial guess.</param> | |
| /// <param name="lowerBound">The lower bound.</param> | |
| /// <param name="upperBound">The upper bound.</param> | |
| public OptBoundVariable(double initialGuess, double lowerBound, double upperBound) | |
| { | |
| this._InitialGuess = initialGuess; | |
| this._LowerBound = lowerBound; | |
| this._UpperBound = upperBound; | |
| } | |
| /// <summary> | |
| /// Initializes a new instance of the OptBoundVariable class. | |
| /// </summary> | |
| /// <param name="name">The variable name.</param> | |
| /// <param name="initialGuess">The initial guess.</param> | |
| /// <param name="lowerBound">The lower bound.</param> | |
| /// <param name="upperBound">The upper bound.</param> | |
| public OptBoundVariable(string name, double initialGuess, double lowerBound, double upperBound) | |
| { | |
| this._Name = name; | |
| this._InitialGuess = initialGuess; | |
| this._LowerBound = lowerBound; | |
| this._UpperBound = upperBound; | |
| } | |
| /// <summary> | |
| /// Initializes a new instance of the OptBoundVariable class. | |
| /// </summary> | |
| /// <param name="initialGuess">The initial guess.</param> | |
| /// <param name="isFixed">Value that indicates if the variable is fixed.</param> | |
| /// <param name="lowerBound">The lower bound.</param> | |
| /// <param name="upperBound">The upper bound.</param> | |
| public OptBoundVariable(double initialGuess, bool isFixed, double lowerBound, double upperBound) | |
| { | |
| this._InitialGuess = initialGuess; | |
| this._Fixed = isFixed; | |
| this._LowerBound = lowerBound; | |
| this._UpperBound = upperBound; | |
| } | |
| /// <summary> | |
| /// Initializes a new instance of the OptBoundVariable class. | |
| /// </summary> | |
| /// <param name="name">The variable name.</param> | |
| /// <param name="initialGuess">The initial guess.</param> | |
| /// <param name="isFixed">Value that indicates if the variable is fixed.</param> | |
| /// <param name="lowerBound">The lower bound.</param> | |
| /// <param name="upperBound">The upper bound.</param> | |
| 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; | |
| } | |
| /// <summary> | |
| /// The lower bound. | |
| /// </summary> | |
| public double LowerBound | |
| { | |
| get { return _LowerBound; } | |
| set { _LowerBound = value; } | |
| } | |
| /// <summary> | |
| /// The upper bound. | |
| /// </summary> | |
| public double UpperBound | |
| { | |
| get { return _UpperBound; } | |
| set { _UpperBound = value; } | |
| } | |
| internal bool UseBounds | |
| { | |
| get { return _UseBounds; } | |
| set { _UseBounds = value; } | |
| } | |
| 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; | |
| } | |
| } | |
| } | |