Summary
I would like to validate my indexed sets using the 'validate' keyword. The problem is that the index is not passed as an argument, only the model and the prospective member of the set. It would arguably be good for sets to have the same validation options as parameters (the component).
Rationale
There should be a way to validate tentative members of indexed sets using the respective index. As I understand it, this is currently not possible. As far as I know, only the potential member is passed as an argument, not the index:
import pyomo.environ as pyo
model = pyo.ConcreteModel()
model.A = pyo.Set()
def validate_B(m, member):
return True
model.B_indexed = pyo.Set(model.A, validate=validate_B)
Description
The 'validate' option works well with parameter components, since the index is passed as an argument too. The same behaviour should be replicated with the set component:
import pyomo.environ as pyo
model = pyo.ConcreteModel()
model.A = pyo.Set()
def validate_B(m, member, index):
return member > index
model.B_indexed = pyo.Set(model.A, validate=validate_B)
Additional information
My current solution relies on validating the data outside of pyomo. Alternatively, I could validate every member of the set every time the validation rule was called but that would be very inefficient.
My setup:
Python 3.8.10
Pyomo 6.4.2
Summary
I would like to validate my indexed sets using the 'validate' keyword. The problem is that the index is not passed as an argument, only the model and the prospective member of the set. It would arguably be good for sets to have the same validation options as parameters (the component).
Rationale
There should be a way to validate tentative members of indexed sets using the respective index. As I understand it, this is currently not possible. As far as I know, only the potential member is passed as an argument, not the index:
Description
The 'validate' option works well with parameter components, since the index is passed as an argument too. The same behaviour should be replicated with the set component:
Additional information
My current solution relies on validating the data outside of pyomo. Alternatively, I could validate every member of the set every time the validation rule was called but that would be very inefficient.
My setup:
Python 3.8.10
Pyomo 6.4.2