GAMS-dev / gamspy

Python-based algebraic modeling interface to GAMS
Other
35 stars 2 forks source link

Space in Model name leads to compilation error #3

Closed grecht closed 3 months ago

grecht commented 5 months ago

Hi, just a small bug I encountered: Trying to solve a model whose name contains a space leads to a compilation error, but there is no clear indication that the name is invalid. Also, it should not be possible to assign an invalid name in the first place.

A small example:

from gamspy import Container, Model, Sum, Sense

c = Container()
a = c.addSet("a", records=["a"])
var = c.addVariable("v", domain=a)
eq = c.addEquation("eq", domain=a)
eq[a] = var[a] >= 1

m = Model(container=c,
          name="with space",
          problem="LP",
          equations=c.getEquations(),
          sense=Sense.MIN,
          objective=Sum(a, var[a]))

m.solve()

This leads to the following error:

GamspyException: 

================================================================================
Error Summary
================================================================================
  58  solve with space using LP MIN autogenerated_8ef7b1ba_475c_4475_b4c7_a1462bf49f70_variable;
****                 $812
**** LINE      4 INPUT       [C:\Users\<user name redacted>\AppData\Local\Temp\tmp48vx2ty7\_job_35566420-2f8b-4031-ab1b-a3f87a5830fb.gms](file:///C:/Users/<user name redacted>/AppData/Local/Temp/tmp48vx2ty7/_job_35566420-2f8b-4031-ab1b-a3f87a5830fb.gms)
**** 812  Solve keys expected - USING MAX/MIN SCENARIO

Meaning of return code 2: There was a compilation error
mabdullahsoyturk commented 4 months ago

@grecht Thanks for reporting it. Will fix it in the next release.

Edit: https://github.com/GAMS-dev/gamspy/commit/b1b0f49c11217dc6449e7594b5549422e7a9e546 fixes it.