# for farmer, this script is necessary to set upper bounds when using piece-wise linear
# approximations of the quadratic penalty term - which can otherwise become unbounded
# for sufficiently large rho values. ultimately, the TOTAL_ACREAGE parameter should be
# correctly taken as the upper bounds in the variable definition, but currently Pyomo
# can only handle constants in this role (and silently ignores parameters).
model_instance = self._model_instance
# formula taken from Fernando's AMPL model. Not sure why the time period is restricted to the first year.
#umax = sum([model_instance.A[h] * model_instance.a[h,"Ano1"] for h in model_instance.HarvestCells])
#self.setVariableBoundsAllIndicesAllScenarios("f", 0.0, umax())
# can be eliminated once Pyomo supports parameters in variable bounds declarations.
for instance_name, instance in self._instances.items():
for t in instance.Times:
lb = instance.Zlb[t]()
ub = instance.Zub[t]()
for e in instance.ExitNodes:
instance.z[e, t].setlb(lb)
instance.z[e, t].setub(ub)
for instance_name, instance in self._instances.items():
for t in instance.Times:
lb = 0
ub = instance.Zub[t]()
for (i,j) in instance.AllRoads:
instance.f[i,j,t].setub(ub)
instance.f[i,j,t].setlb(lb)