I have a continuous-time Pyomo model of the form:
from pyomo.environ import *
from pyomo.dae import *
m = ConcreteModel()
m.t = ContinuousSet(bounds=(0,150))
m.T = Param(default=150)
m.S = Var(m.t, bounds=(0,None))
m.Sdot = DerivativeVar(m.S)
discretizer = TransformationFactory('dae.collocation')
discretizer.apply_to(m,nfe=100,ncp=3,scheme='LAGRANGE-RADAU')
m.obj = Objective(expr=m.S[122],sense=maximize)
But, when I run the above code, I get the following error:
KeyError: "Error accessing indexed component: Index '120' is not valid for array component 'S'"
Looking at list(m.t)
, I see that, sure enough, 122 is not included as a discretization point:
..., 121.73257700000001, 122.467423, ...
How can I specify points to be included in the discretization?
Aucun commentaire:
Enregistrer un commentaire