関数のパラメータ変数のテーブル。
상속: ICloneable
예제 #1
0
 /// <summary>
 /// 値の計算。
 /// </summary>
 public virtual ValueType this[VariableTable t]
 {
     get
     {
         return(this.GetValue(t.GetParameterList()));
     }
 }
예제 #2
0
		/// <summary>
		/// 値の計算。
		/// </summary>
		public virtual ValueType this[VariableTable t]
		{
			get
			{
				return this.GetValue(t.GetParameterList());
			}
		}
예제 #3
0
        /// <summary>
        /// 指定した範囲内/刻み幅で、関数 f の値が最小になるような引数を探す。
        /// (総当り)
        /// </summary>
        /// <param name="f">関数 f</param>
        /// <param name="rangeList">探索範囲/刻み幅</param>
        /// <returns>argmin f</returns>
        public static VariableTable Argmin(Function f, params Range[] rangeList)
        {
            VariableTable vars = new VariableTable();

            foreach (Range range in rangeList)
            {
                vars[range.variable] = range.min;
            }

            ValueType     min    = ValueType.MaxValue;
            VariableTable argmin = null;

            for (;;)
            {
                ValueType val = f[vars];
                if (val < min)
                {
                    min    = val;
                    argmin = vars.Clone();
                }

                int i = 0;
                for (; i < rangeList.Length; ++i)
                {
                    ValueType x = vars[rangeList[i].variable];
                    x += rangeList[i].step;

                    if (x > rangeList[i].max)
                    {
                        vars[rangeList[i].variable] = rangeList[i].min;
                    }
                    else
                    {
                        vars[rangeList[i].variable] = x;
                        break;
                    }
                }
                if (i >= rangeList.Length)
                {
                    break;
                }
            }

            return(argmin);
        }
예제 #4
0
		/// <summary>
		/// 指定した範囲内/刻み幅で、関数 f の値が最小になるような引数を探す。
		/// (総当り)
		/// </summary>
		/// <param name="f">関数 f</param>
		/// <param name="rangeList">探索範囲/刻み幅</param>
		/// <returns>argmin f</returns>
		public static VariableTable Argmin(Function f, params Range[] rangeList)
		{
			VariableTable vars = new VariableTable();
			foreach(Range range in rangeList)
			{
				vars[range.variable] = range.min;
			}

			ValueType min = ValueType.MaxValue;
			VariableTable argmin = null;

			for(;;)
			{
				ValueType val = f[vars];
				if(val < min)
				{
					min = val;
					argmin = vars.Clone();
				}

				int i=0;
				for(; i<rangeList.Length; ++i)
				{
					ValueType x = vars[rangeList[i].variable];
					x += rangeList[i].step;

					if(x > rangeList[i].max)
					{
						vars[rangeList[i].variable] = rangeList[i].min;
					}
					else
					{
						vars[rangeList[i].variable] = x;
						break;
					}
				}
				if(i >= rangeList.Length) break;
			}

			return argmin;
		}