tseyanglim / VST

Vensim Script Tools for improving workflow in Vensim
GNU General Public License v3.0
4 stars 1 forks source link

Calibration not stopping with return code 3221225477 #1

Closed hyunjimoon closed 2 years ago

hyunjimoon commented 2 years ago

Hi when I run the last block of your jupyter file, I face the following error and the calibration doesn't stop:

-----
Starting new log at Sun Sep 25 11:53:57 2022
Ready to work!
Initialising PrPr_main_opt!
-----
Starting new log at Sun Sep 25 12:12:20 2022
Ready to work!
Initialising PrPr_main_opt!
Return code is 3221225477
Vensim! Trying again...
Return code is 3221225477
Vensim! Trying again...
Return code is 3221225477
Vensim! Trying again...
Return code is 3221225477
Vensim! Trying again...
Checking for PrPr_main_opt.log...
At Sun Sep 25 12:23:35 2022, 608.106s since last output. Calibration timed out!
Return code is None
Vensim! Trying again...
Checking for PrPr_main_opt.log...
At Sun Sep 25 12:33:40 2022, 1213.162s since last output. Calibration timed out!
Return code is None
Vensim! Trying again...
Return code is 3221225477
Vensim! Trying again...
Return code is 3221225477
Vensim! Trying again...
Checking for PrPr_main_opt.log...
At Sun Sep 25 12:46:14 2022, 608.398s since last output. Calibration timed out!
Return code is None
Vensim! Trying again...
Return code is 3221225477
Vensim! Trying again...
-----
Starting new log at Thu Oct  6 04:43:40 2022
Ready to work!
Initialising PrPr_main_opt!
Return code is 3221225477
Vensim! Trying again...
Return code is 3221225477
Vensim! Trying again...
Return code is 3221225477
Vensim! Trying again...
Return code is 3221225477
Vensim! Trying again...
tseyanglim commented 2 years ago

This is the issue we just discussed over email; Vengine 9.x sometimes gives that return code with cmd scripts even when closing correctly. You need to change the line in the function run_vengine_script where it checks the returncode:

if proc.returncode != 1:

Change it to something like:

if not (proc.returncode == 0 or proc.returncode == 3221225477):

(This will preclude compatibility with Vengine 7.2; if you want that as well you need to allow proc.returncode == 1 to pass also.

hyunjimoon commented 2 years ago

Thanks! I noticed, but wanted to make a pull request with updated code :)

tseyanglim commented 2 years ago

I've updated the automation example with the temporary fix, and it will also be incorporated into the main codebase which will hopefully be ready to test soon!

hyunjimoon commented 2 years ago

Another error code is discovered 3221226525. If I push the warning sign once, it disappears and run calibration correctly in the second attempt. This error does not happens everytime, but around once in five runs. I am using the updated version Tom shared with the following comment.

The expiration warning no longer uses a dialog. This means it's not visible unless you look in the .err log in %appdata%.
Running XPARALLEL

@tseyanglim do you know how to 1. turn off warning dialog and 2.run XPARALLEL?

Initialising <__main__.Script object at 0x00000130250F8640>
-----
Starting new log at Thu Oct  6 13:18:04 2022
Ready to work!
Initialising <__main__.Script object at 0x0000013025106950>
Initialising PrPr_main_opt!
Return code is 3221226525
Vensim! Trying again...
Payoff for PrPr_main_opt is -878.334, calibration complete!
Optimization complete - payoff is -878.334!
More work? Okay!
Initialising <__main__.RunScript object at 0x0000013025106950>
Traceback (most recent call last):
  File "C:\Users\amoon\Dropbox\WINcode\VST\VST Automation\VST Automation Example v2.py", line 349, in <module>
    compile_script(cf, RunScript, 'main', 'run', {}, logfile, chglist=[('main', 'opt')])
  File "C:\Users\amoon\Dropbox\WINcode\VST\VST Automation\VST Automation Example v2.py", line 164, in compile_script
    return mainscript.run_script(scriptname, controlfile, subdir, logfile)
  File "C:\Users\amoon\Dropbox\WINcode\VST\VST Automation\VST Automation Example v2.py", line 116, in run_script
    return run_vensim_script(scriptname, controlfile['vensimpath'], 10, logfile)
  File "C:\Users\amoon\Dropbox\WINcode\VST\VST Automation\VST Automation Example v2.py", line 274, in run_vensim_script
    subprocess.run(f"{vensimpath} \"./{scriptname}.cmd\"", check=True)
  File "C:\Users\amoon\Miniconda3\envs\VST\lib\subprocess.py", line 501, in run
    with Popen(*popenargs, **kwargs) as process:
  File "C:\Users\amoon\Miniconda3\envs\VST\lib\subprocess.py", line 966, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\amoon\Miniconda3\envs\VST\lib\subprocess.py", line 1435, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
OSError: [WinError 87] The parameter is incorrect

Process finished with exit code 1