필터 지우기
필터 지우기

End GAMS simulation from MATLAB

조회 수: 1 (최근 30일)
Sujit Tripathy
Sujit Tripathy 2022년 2월 11일
답변: Dinesh 2023년 12월 22일
Hey.
I am trying to develop a MATLAB based app (standalone .exe file) for setting parameters of a GAMS model, simulate the model and generate output files. Some info on GAMS: it is a modelling software to formulate and solve mathematical optimization problems <https://www.gams.com/>. I am using MATLAB API to implement various GAMS functions from MATLAB (formulate a model, start a simulation etc.) https://www.gams.com/latest/docs/API_MATLAB_GAMS_OVERVIEW.html.
On the app, I want to have various push buttons to implement different functions in a sequential manner (for e.g., read input data, set parameter values, start a simulation, and export results etc.). I am also trying to add a push button to abort a GAMS simulation while (using system and taskkill command) it is being executed.
Right now, When I press the button on app to abort simulation (with underlying call back function: system('taskkill /F /IM gams.exe')), the push button action takes place only after the simulation is over and I get an error as the process is already over. I tried ending the process (GAMS simulation) externally from 'command window' and 'task manager' and it works. However, I have not been able to implement it from the MATLAB based app. I would really appreciate if anyone can suggest how to have this implemented from the MATLAB based app.
Thanks.

답변 (1개)

Dinesh
Dinesh 2023년 12월 22일
Hi Sujat,
It sounds like you're facing an issue with asynchronous execution in your app designer app, specifically when trying to terminate a GAMS simulation process mid-execution. One way to handle this might be to ensure that your abort button initiates a separate thread or process to kill the GAMS task. This can often be achieved by using MATLAB's batch function or other parallel computing tools to run the system('taskkill /F /IM gams.exe') command independently of the main app process. This way, the command to terminate the simulation doesn't have to wait for the simulation to complete before executing.
Another approach might be to investigate how MATLAB handles external calls and processes while a simulation is running. Ensuring that the app remains responsive and can execute commands even during intensive computational tasks is key. It may involve setting up your simulation or app architecture to periodically check for an abort signal or to run simulations in a mode that doesn't block other operations.
The following links might help you:

카테고리

Help CenterFile Exchange에서 Modeling에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by