Open stanleybak opened 8 years ago
Can you tell the path to the nav_*.py file describing hybrid automaton for the case you ran the rrt code? The first error seems to be an error, where the guard_sympy expression declared in this file is boolean and not a string.
It's probably better if you get my branch and can run the scripts yourself rather than having to interact with me for each problem. The script will not produce *.py files, as it's using hypy which puts them in temporary directories behind the scenes unless an explicit output file is requested.
To produce the model file for debugging, you need to run Hyst on the input .xml file, with the flag to use the rrt printer. In this case, since the file causing the issue is lorenz, we go the the src folder which contains Hyst.jar
and run java -jar Hyst.jar -pyrrt ../examples/lorenz/lorenz.xml -o output.py
. This produces output.py in the local directory.
As for this particular case, the latest rrt code doesn't use sympy. It's true that it looks like the parser
function is using sympy due to its signature: def parser(guard_sympy, varorder):
, but the actual call to the function is using something else: A, b = test_cvxopt.parser(self.ha.modes[modes].inv_strings, self.ha.variables)
. In this case, it's using inv_strings
. We should probably update the variable names in the code to fix this.
For this case, after producing the output.py, I saw in the model definition running.inv_strings = [True]
. The bug, then, was in Hyst's PyRRT printer. This file is part of Hyst, located at hyst/src/java/com/verivital/hyst/printers/PyRrtPrinter.java
. I would then edit this file, run ant
to rebuild Hyst.jar, and try again.
In the RRT printer file, there is a RrtSymbolicPrinter
class that has methods printTrue
and printFalse
, which affect the printing for such constants in the output .py file. The question then is, what should the correct printing be for an invariant that is true? For now, I've replaced it with 0 == 0
for true and 0 == 1
for false, although that seems like a little bit of a hack.
After that fix, I get a different error:
Test failed for 2/90 model lorenz with pyrrt: Error (Tool)
Log:
Running pyrrt on model /home/stan/repositories/hyst/src/tests/regression/models/lorenz/lorenz.xml
Hyst command: ['java', '-jar', '/home/stan/repositories/hyst/src/Hyst.jar', '/home/stan/repositories/hyst/src/tests/regression/models/lorenz/lorenz.xml', '-o', '/home/stan/repositories/hyst/src/tests/regression/result/lorenz_pyrrt.py', '-pyrrt']
Finished converting in 385 ms
Seconds for Hyst conversion: 2.02757406235
Traceback (most recent call last):
File "/home/stan/repositories/hyst/src/hybridpy/hybridpy/tool_pyrrt.py", line 54, in <module>
tool_main(PyRrtTool())
File "/home/stan/repositories/hyst/src/hybridpy/hybridpy/hybrid_tool.py", line 75, in tool_main
code = tool_obj.run()
File "/home/stan/repositories/hyst/src/hybridpy/hybridpy/hybrid_tool.py", line 271, in run
rv = self._run_tool()
File "/home/stan/repositories/hyst/src/hybridpy/hybridpy/tool_pyrrt.py", line 30, in _run_tool
self._result = run()
File "/tmp/pyrrt_759_1466558/lorenz_pyrrt.py", line 40, in run
File "/home/stan/repositories/hyst/src/hybridpy/hybridpy/pyrrt/expt_opt.py", line 1133, in run
my_rrt = RRT(ha, list_of_initial_states, init_states[0][0])
File "/home/stan/repositories/hyst/src/hybridpy/hybridpy/pyrrt/expt_opt.py", line 342, in __init__
self.ha.modes[modes].inv_strings, self.ha.variables)
File "/home/stan/repositories/hyst/src/hybridpy/hybridpy/pyrrt/util.py", line 45, in parser
b.append(float(eq_1[1]))
IndexError: list index out of range
Elapsed Seconds: 2.76715898514
Result: Error (Tool)
Error detected running regression tests.
I've attached the output.py file for this model, although I hope you can repeat the steps above yourself to find and fix any remaining errors. I'll be traveling for two weeks so I won't be able to be re-running these. The rrt source files are located in hyst/src/hybridpy/hybridpy/pyrrt
if you need to change them. There's a readme in the main hyst folder for getting setup with hypy (you may need to adjust your PYTHONPATH environment variable).
One small correction: The regression test script does output the intermediate files with the models so you may not need to run the Hyst jar manually, unless you want to. They are placed in hyst/src/tests/regression/result
, and in this case the model file is called lorenz_pyrrt.py
.
I think for the true invariant, we can simply write it as "True" (boolean) and I will incorporate this in the RRT code (utils.py) .
go ahead and try to update the PyRrtPrinter.java
file yourself. Once all the tests pass you can submit the changes to my branch as a pull request.
I've made an initial integration of Aviral's rrt-hybrid repository code into the hyst repostory. Use this branch to perform further development: https://github.com/stanleybak/hyst/tree/rrt-printer
There are several things that need to be addressed before we integrate it into the main release.
First, I get errors when I run the rrt tool. I tried it on three models in our examples folder and got three different errors for each one. I suggest we make sure the tool works on the examples in the examples directory. I added to our regression tests which runs all tools on all models. You can run that script by going to src/tests/regression and doing
python run_tests.py
. Here's a snippet of the current output:The second issue is code quality and customization. For customization, the
expt_opt
function needs to take in parameters like the amount of time per step. The plotting function should automatically detect a reasonable plot range, in addition to being able to used fixed coordinates. The script outputs random output to stdout. A percent done or # of iterations might be okay, but it looks like debugging output at this point. The names are unclear, why is it called expt_opt? I renamed test_cvxopt to util since it looks like utilities. I moved the global variablet = np.linspace(0, 0.2, 4)
into functions (why was it global?). There may be other such issues in the code which should be cleaned up. The global pylint score for pyrrt is currently 6.71/10, let's try to get it above 9.