public double GetVal(GekkoTime t)
 {
     //Asking a general timeless GetVal() from a timeseries (and not getting a val with a particular GekkoTime) is used in GENR, PRT etc. in an internal GekkoTime loop. Hence the use of Globals.globalGekkoTimeIterator_DO_NOT_ALTER.
     if (t.IsNull())
     {
         G.Writeln2("*** ERROR: You are trying to extract a single value from timeseries: " + this.ts.variableName + ".");
         G.Writeln("           Did you forget []-brackets to pick out an observation, for instance x[2020]?");
         throw new GekkoException();
     }
     return(this.ts.GetData(t.Add(this.offset)));
 }
Exemple #2
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));
            }
        public double GetVal(GekkoTime t)
        {
            //Asking a general timeless GetVal() from a timeseries (and not getting a val with a particular GekkoTime) is used in GENR, PRT etc. in an internal GekkoTime loop. Hence the use of Globals.globalGekkoTimeIterator_DO_NOT_ALTER.
            if (t.IsNull())
            {
                G.Writeln2("*** ERROR: You are trying to extract a single value from timeseries: " + this.ts.variableName + ".");
                G.Writeln("           Did you forget []-brackets to pick out an observation, for instance x[2020]?");
                throw new GekkoException();
            }
            double d = this.ts.GetData(t.Add(this.offset));

            if (Program.options.series_array_ignoremissing && !this.ts.IsTimeless() && this.ts.variableName != null && this.ts.variableName.Contains(Globals.symbolTurtle))
            {
                if (double.IsNaN(d))
                {
                    d = 0d;
                }
            }
            return(d);
        }