[Python] How can I add elements to an existing Set in GAMSPy?

Discussão em 'Python' iniciado por Stack, Julho 28, 2025.

  1. Stack

    Stack Membro Participativo

    I'm working with the GAMSPy Python API and using Set objects to define sets in a GAMS model. I can define a set like this:

    from gamspy import Container, Set

    m = Container()
    regions = Set(m, name="regions", records=["east", "west", "north", "south"])



    Now I want to add another element to this existing set after it's been defined. I tried:

    regions.add_record("central")



    But this results in: Set object has no attribute 'add_record'

    What is the correct way to add a new element to an already existing Set in GAMSPy?

    I couldn't find a clear example in the documentation. Is there an official method for modifying a set after its initial creation?

    Thanks in advance!

    Continue reading...

Compartilhe esta Página