/// <summary> /// Obtain the Taylor Model for the non-linear ODE after substituting the controller response at the current state. /// </summary> private TaylorModelVec GetODEExpanded(State current) { // extract current values Dictionary <string, DoubleInterval> x0 = current.ToDictionary(); x0.Add("time", new DoubleInterval(current.step * period)); // add controlled variables var controlled = Hold(current); foreach (var kvp in controlled) { x0.Add(kvp.Key, kvp.Value); } // update ODEs with the controlled variables TaylorModel[] taylorModels = new TaylorModel[ode.Count]; for (int i = 0; i < expandedOde.Count; ++i) { // calculate ODE Polynomial p = TaylorExpansion.Expansion(expandedOde[i], tmVarNamesWithout0, x0, order); // Should calculate the error bounds... taylorModels[i] = new TaylorModel(p, new DoubleInterval(0)); Console.Write("Polynomial: {0} ->", ode[i]); p.Dump(tmVarNames, true); } return(new TaylorModelVec(taylorModels)); }
/// <summary> /// Obtain the Taylor Model for the non-linear ODE after substituting the controller response at the current state. /// </summary> private TaylorModelVec GetODE(State current) { var controlled = Hold(current); string[] varNames = new string[current.continuousNames.Length + 1]; varNames[0] = "time"; current.continuousNames.CopyTo(varNames, 1); // update ODEs with the controlled variables TaylorModel[] taylorModels = new TaylorModel[ode.Count]; for (int i = 0; i < ode.Count; ++i) { var odeC = ode[i]; foreach (var kvp in controlled) { //Log.WriteLine("Controlled {0} = {1}", kvp.Key, kvp.Value); odeC = odeC.Substitute(kvp.Key, new REAL(kvp.Value)); } // calculate ODE Polynomial p = TaylorExpansion.ConvertPolynomial(odeC, current.continuousNames); taylorModels[i] = new TaylorModel(p, new DoubleInterval(0)); } return(new TaylorModelVec(taylorModels)); }