GithubHelp home page GithubHelp logo

Comments (2)

mabdullahsoyturk avatar mabdullahsoyturk commented on July 30, 2024 1

x.lo is not a declaration but an execution statement (similar to Python interpreter running line by line). Hence, when you execute in the following order:

x.lo = 0
s.setRecords(["a"])

you are basically indicating that you want to set the lower bound of elements in the set so far (since set s is empty at the moment, you do not set the lower bound of anything). But when you change the order:

s.setRecords(["a"])
x.lo = 0

Set s is not empty anymore. Therefore, you assign the lower bound for a.

Because of this, static variable bounds should be declared after the instantiation of the model to achieve the desired result.

from gamspy.

grecht avatar grecht commented on July 30, 2024

Okay, that makes sense, thanks for the explanation. My first thought was that if the statement has no effect, it should not be possible to execute it or this should at least be communicated to the user. However, if a set is left empty on purpose, e.g. due to flexibility in the model definition, this makes no sense. So FYI, my current workaround is to define a function for each variable which adds its bounds to the Container and execute it after the data has been added to the Container (if the respective variable is contained in it).

I can see this is due to GAMS' underlying set philosophy and not specific to GAMSPy. However, it sort of goes against the "Model Instances vs. Mathematical Models" proposition of GAMSPy's landing page, which is IMO not implemented consistently (or at least it is not clear where the "model world" ends and the "instance world" begins): I am able to define equations using variables and parameters defined over empty sets, as this only creates "symbolic" relationships. This is really nice and appealing. But then it is confusing that it does not work for static variable bounds, as they are also equations from a mathematical perspective. Also, defining the complementary set of an empty subset of an empty set does not work. Moreover, from a modeling perspective a mathematical model is not totally devoid of data: In many cases, variable bounds are known beforehand as they are dictated by the problem at hand (e.g. the voltage angle limits in the optimal power flow problem). And from a software development perspective, I want to make the model building flexible using functions which add sets, parameters, variables and equations to the Container. If during definition of a variable I already know its static bounds, it makes sense to put them right after its definition.

from gamspy.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.