Coder Social home page Coder Social logo

Comments (6)

Antti-L avatar Antti-L commented on June 8, 2024 1

Thanks for the proposed method.
I see it works only with GAMS v23.6 or above, and so an additional test for the GAMS version must also be added, and another method be used when v23.5 or below is used. I guess that can be implemented so, even if losing a bit in compactness. 😊

from times_model.

mbussieck avatar mbussieck commented on June 8, 2024 1

I can confirm that this works also on Linux.

from times_model.

Antti-L avatar Antti-L commented on June 8, 2024

Thanks. The saving of this file is already done at compile time. Only the renaming is done at execution phase, and that is because of the rename with a timestamp.

There is no standard use case for a restart file being created from TIMES, and so the compile and execution phases would occur at the same time under all normal use cases. However, if you can show how to conveniently create the timestamp at compile time (such that works both under latest and older GAMS versions), doing also the rename at compile time as you suggested will be implemented according to your suggestion. Thanks for contributing to improving TIMES.

from times_model.

mbussieck avatar mbussieck commented on June 8, 2024

You can access the time routines via $eval at compile time. The printing of 02 if you have a 2 is not so easy and I resorted to printf which we ship for ages with the GAMS Windows system and is available on many POSIX systems. Nowadays, I would use embedded Python code to do such things, but I understand that TIMES should also run on older versions of GAMS, so I used the external tool solution. So the following works under Windows and Linux:

$if not %system.fileSys%==UNIX $set GDXPATH 'd:\tmp\'
$if     %system.fileSys%==UNIX $set GDXPATH '/tmp/'
$echo xx > _dd_.gdx
$set RUN_NAME demo_12

$eval JNOW jnow
$eval GSECOND GSECOND(%JNOW%)
$eval GMINUTE GMINUTE(%JNOW%)
$eval GHOUR GHOUR(%JNOW%)
$eval GDAY GDAY(%JNOW%)
$eval GMONTH GMONTH(%JNOW%)
$eval GYEAR GYEAR(%JNOW%)
$echon $call mv -f _dd_.gdx %GDXPATH%%RUN_NAME%~Data_ > "%gams.scrDir%mv.%gams.scrExt%"
$escape &
$call printf "%&02d%&02d%&02d_%&02d%&02d%&02d.gdx" %GYEAR% %GMONTH% %GDAY% %GHOUR% %GMINUTE% %GSECOND% >> "%gams.scrDir%mv.%gams.scrExt%"
$escape %
$if x==x $include "%gams.scrDir%mv.%gams.scrExt%" 

from times_model.

Antti-L avatar Antti-L commented on June 8, 2024

Here is a streamlined variant I tested on Windows, hopefully this would work also on Linux:

$EVAL GTIME GHOUR(JSTART)*10000+GMINUTE(JSTART)*100+GSECOND(JSTART)
$EVAL GDATE MOD(GYEAR(JSTART),100)*10000+GMONTH(JSTART)*100+GDAY(JSTART)
$ESCAPE &
$hiddencall printf "%&s%&06d_%&06d.gdx" "%GDXPATH%%RUN_NAME%~Data_" %GDATE% %GTIME% | xargs mv -f _dd_.gdx
$ESCAPE %

from times_model.

Antti-L avatar Antti-L commented on June 8, 2024

This change (compile time rename of the data-only gdx file) will be in the next release. I know one user, @kanors-emr , who I expect to be affected by it, due to somewhat "non-standard" modes of usage, and therefore notified hereby in advance.

from times_model.

Related Issues (5)

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.