예제 #1
0
            public static IVariable Add(ScalarVal x, MetaTimeSeries ats, GekkoTime t)
            {
                //no need to implement swap
                if (t.IsNull())
                {
                    throw new GekkoException();
                }
                TimeSeries ts   = ats.ts;
                double     val1 = x.val;
                double     val2 = ts.GetData(t.Add(ats.offset));

                return(new ScalarVal(val1 + val2));
            }
예제 #2
0
 public double GetVal(GekkoTime t)
 {
     if (this._isName)
     {
         MetaTimeSeries ats = O.IndirectionHelper(this._string2);
         double         x   = O.GetVal(ats, t);
         return(x);
     }
     else
     {
         //Conversion not allowed in for instance VAL x = %s, where s is a STRING pointing to a timeseries.
         G.Writeln2("*** ERROR: You are trying to extract a numerical value from STRING '" + this._string2 + "'");
         G.Writeln("           A STRING s ('" + this._string2 + "') can refer to a timeseries name (" + this._string2 + "), but in");
         G.Writeln("           that case you must use {s} or {%s} instead of %s.");
         throw new GekkoException();
     }
 }