Trying to run the following lines of code will raise an error.
from gamspy import Container, Set, Parameter
m = Container()
p = Set(m, name="p", description="products")
price = Parameter(m, name="p", domain=p, description="price for product p")
The problem with the above code is that the Set
statement creates a symbol in the GAMSPy database with name “p”. Consequently, the namespace “p” is now exclusively reserved for a Set
. The following Parameter
statement attempts to create a GAMSPy Parameter
within the same namespace “p”, which is already reserved for the Set
p
. Thus, you want to keep in mind that the type for a GAMSPy symbol is fixed once it was declared.