brechtevens / GPG-drive

Simulator for interacting dynamical systems using generalized potential games
MIT License
16 stars 3 forks source link

Approximate Run time of the code #1

Open saxenam06 opened 2 years ago

saxenam06 commented 2 years ago

Hello, Many Thanks for your repository. I was trying to run merging_scenario_paper.py code. It displayed the following output in the console and then seems to have stucked since 4 hrs now. Does the code really takes time or something has gone wrong in my installation? Many Thanks for your help.

added constraint between 0 and 1 for 0 added constraint between 1 and 2 for 0 added constraint between 1 and 3 for 0 added constraint between 0 and 2 for 0 added constraint between 0 and 3 for 0 added constraint between 1 and 0 for 1 added constraint between 0 and 2 for 1 added constraint between 0 and 3 for 1 added constraint between 1 and 2 for 1 added constraint between 1 and 3 for 1

brechtevens commented 2 years ago

Hello,

Glad to hear you are trying out the simulator! The game starts in a 'paused' state, you just need to press the spacebar to start the game. I just added the instructions for interfacing with the simulator in the readme. I also packaged the src code now using flit, which is better practice than the weird implicit imports I did before.

Let me know how it goes!

Best, Brecht

saxenam06 commented 2 years ago

Thanks a lot for your feedback. After pressing space bar I start getting the following message. Could you please have a quick glance below and give me a feedback again what could be going wrong. Many Thanks again for your help.

NEW GAME ITERATION__ Traceback (most recent call last):

File "C:\Users\pulom\Downloads\GPG-drive-master\GPG-drive-master\examples\merging_

scenario_paper.py", line 126, in vis.run()

File "C:\Users\pulom\Downloads\GPG-drive-master\GPG-drive-master\src\visualize.py", line 725, in run pyglet.app.run()

File "C:\Users\pulom\anaconda3\lib\site-packages\pyglet\app__init__.py", line 107, in run event_loop.run()

File "C:\Users\pulom\anaconda3\lib\site-packages\pyglet\app\base.py", line 167, in run timeout = self.idle()

File "C:\Users\pulom\anaconda3\lib\site-packages\pyglet\app\base.py", line 237, in idle redraw_all = self.clock.call_scheduled_functions(dt)

File "C:\Users\pulom\anaconda3\lib\site-packages\pyglet\clock.py", line 292, in call_scheduled_functions item.func(now - item.last_ts, *item.args, **item.kwargs)

File "C:\Users\pulom\Downloads\GPG-drive-master\GPG-drive-master\src\visualize.py", line 304, in control_loop vehicle.control(steer, gas)

File "C:\Users\pulom\Downloads\GPG-drive-master\GPG-drive-master\src\car.py", line 767, in control self.initialize_solvers()

File "C:\Users\pulom\Downloads\GPG-drive-master\GPG-drive-master\src\car.py", line 747, in initialize_solvers self.optimizer = lagrangiansolver.solver(self.id, self.players, self.shared_reward, self.g, self.h, self.v, self.lbv, self.ubv,

File "C:\Users\pulom\Downloads\GPG-drive-master\GPG-drive-master\src\lagrangiansolver.py", line 144, in init self.solver = src.solvers.get_panocpy_solver(self.problem, self.solver_settings, self.bounds, self.id)

File "C:\Users\pulom\Downloads\GPG-drive-master\GPG-drive-master\src\solvers.py", line 186, in get_panocpy_solver panocpy_prob = pa.generate_and_compile_casadi_problem_full(f_prob, g1_prob, g2_prob, name=name)

File "C:\Users\pulom\anaconda3\lib\site-packages\panocpy\casadi_problem.py", line 415, in generate_and_compile_casadi_problem_full subprocess.run(configure_cmd, check=True)

File "C:\Users\pulom\anaconda3\lib\subprocess.py", line 528, in run raise CalledProcessError(retcode, process.args,

CalledProcessError: Command '['cmake', '-B', 'C:\Users\pulom\AppData\Local\Temp\panocpy\cache\build\build', '-S', 'C:\Users\pulom\AppData\Local\Temp\panocpy\cache\build']' returned non-zero exit status 1.

brechtevens commented 2 years ago

That is strange, it seems like the provided 'panocpy' package is unable to build the quadratic penalty solver. Basically, as you probably have noticed, I am using a forked version of PANOC-ALM as my solver since the numerical experiments seem to perform better when using a quadratic penalty method instead of ALM.

Could you try the following things?

saxenam06 commented 2 years ago

Hello, Many Thanks again for your inputs and time. I am working on Windows 11 Home, with Anaconda and using Python 3.9.7 version. Please also see this notebook to have a quick galnce of my installation procedure. https://github.com/saxenam06/GPG-drive/blob/master/GPG_Drive_Installed.ipynb By using the first proposal to use panoc_alm I get the same error as above mentioned. By using the second proposal of using OpEn solver, I get some progress but then get the following error. __NEW GAME ITERATION__ [INFO] Initialising builder [INFO] Checking user parameters [INFO] Creating necessary folders [INFO] Copying icasadi interface to target directory [INFO] Generating icasadi's Cargo.toml [INFO] Generating Cargo.toml for target optimizer [INFO] Generating icasadi Rust library file Traceback (most recent call last):

File "C:\Users\pulom\Downloads\GPG-drive-master\GPG-drive-master\examples\merging_scenario_paper.py", line 129, in vis.run()

File "C:\Users\pulom\Downloads\GPG-drive-master\GPG-drive-master\src\visualize.py", line 725, in run pyglet.app.run()

File "C:\Users\pulom\anaconda3\lib\site-packages\pyglet\app__init__.py", line 107, in run event_loop.run()

File "C:\Users\pulom\anaconda3\lib\site-packages\pyglet\app\base.py", line 167, in run timeout = self.idle()

File "C:\Users\pulom\anaconda3\lib\site-packages\pyglet\app\base.py", line 237, in idle redraw_all = self.clock.call_scheduled_functions(dt)

File "C:\Users\pulom\anaconda3\lib\site-packages\pyglet\clock.py", line 292, in call_scheduled_functions item.func(now - item.last_ts, *item.args, **item.kwargs)

File "C:\Users\pulom\Downloads\GPG-drive-master\GPG-drive-master\src\visualize.py", line 304, in control_loop vehicle.control(steer, gas)

File "C:\Users\pulom\Downloads\GPG-drive-master\GPG-drive-master\src\car.py", line 767, in control self.initialize_solvers()

File "C:\Users\pulom\Downloads\GPG-drive-master\GPG-drive-master\src\car.py", line 747, in initialize_solvers self.optimizer = lagrangiansolver.solver(self.id, self.players, self.shared_reward, self.g, self.h, self.v, self.lbv, self.ubv,

File "C:\Users\pulom\Downloads\GPG-drive-master\GPG-drive-master\src\lagrangiansolver.py", line 141, in init self.solver = src.solvers.get_OpEn_solver(self.problem, self.solver_settings, self.bounds, self.id)

File "C:\Users\pulom\Downloads\GPG-drive-master\GPG-drive-master\src\solvers.py", line 120, in get_OpEn_solver build_OpEn_problem(OpEn_problem, solver_settings, optimizers_dir, id, id2, name)

File "C:\Users\pulom\Downloads\GPG-drive-master\GPG-drive-master\src\solvers.py", line 73, in build_OpEn_problem builder.build()

File "C:\Users\pulom\anaconda3\lib\site-packages\opengen\builder\optimizer_builder.py", line 632, in build self.__generate_icasadi_lib() # generate icasadi lib.rs

File "C:\Users\pulom\anaconda3\lib\site-packages\opengen\builder\optimizer_builder.py", line 225, in __generate_icasadi_lib icasadi_lib_output_template = icasadi_lib_template.render(meta=self.__meta,

File "C:\Users\pulom\anaconda3\lib\site-packages\jinja2\environment.py", line 1090, in render self.environment.handle_exception()

File "C:\Users\pulom\anaconda3\lib\site-packages\jinja2\environment.py", line 832, in handle_exception reraise(*rewrite_traceback_stack(source=source))

File "C:\Users\pulom\anaconda3\lib\site-packages\jinja2_compat.py", line 28, in reraise raise value.with_traceback(tb)

File "C:\Users\pulom\anaconda3\lib\site-packages\opengen\templates\icasadi\icasadi_lib.rs", line 23, in top-level template code const NUM_DECISION_VARIABLES: usize = {{ problem.dim_decision_variables() }};

File "C:\Users\pulom\anaconda3\lib\site-packages\opengen\builder\problem.py", line 118, in dim_decision_variables return self.__u.size(1)

TypeError: 'int' object is not callable

brechtevens commented 2 years ago

Hmmm, I am quite surprised to see that. Doesn't cmake give an error? I guess panocpy is unable to find a C++ compiler. Do you have a C compiler installed, such as MSVC on Windows?

For the problem you encountered with OpEn, I encountered this as well a couple of days ago as well when packaging the repository and testing OpEn. This is due to OpEn not being compatible with casadi.tools. Commit 7a6b467b233be109e448b85b3e6b7a1380fbef9e contains a fix to this. Basically, I think you just need to change these lines: https://github.com/brechtevens/GPG-drive/blob/7a6b467b233be109e448b85b3e6b7a1380fbef9e/src/GPGdrive/lagrangiansolver.py#L140-L147

saxenam06 commented 2 years ago

Let me check deeper about panocpy and then I will give you a feedback.

Regarding OpEn, I did as you proposed, I get some progress but then get the following error in Building Optimizer. Could you please look through. Many Thanks for your help. added constraint between 0 and 1 for 0 added constraint between 1 and 2 for 0 added constraint between 1 and 3 for 0 added constraint between 0 and 2 for 0 added constraint between 0 and 3 for 0 added constraint between 1 and 0 for 1 added constraint between 0 and 2 for 1 added constraint between 0 and 3 for 1 added constraint between 1 and 2 for 1 added constraint between 1 and 3 for 1 __NEW GAME ITERATION__ C:\Users\pulom\anaconda3\lib\site-packages\pyglet\image\codecs\wic.py:289: UserWarning: [WinError -2147417850] Cannot change thread mode after it is set warnings.warn(str(err)) [INFO] Initialising builder [INFO] Checking user parameters [INFO] Creating necessary folders [INFO] Copying icasadi interface to target directory [INFO] Generating icasadi's Cargo.toml [INFO] Generating Cargo.toml for target optimizer [INFO] Generating icasadi Rust library file [INFO] Defining CasADi functions and generating C code [INFO] Defining function psi(u, xi, p) and its gradient [INFO] Function psi and its gradient (C code) [INFO] Defining function F1(u, p) [INFO] Mapping F1 (C code) [INFO] Defining function F2(u, p) [INFO] Mapping F2 (C code) [INFO] Generating casadi_memory.h [INFO] Generating intercafe.c (C interface) [INFO] Generating main code for target optimizer (lib.rs) [INFO] Generating build.rs for target optimizer [INFO] Generating YAML configuration file [INFO] Building optimizer Traceback (most recent call last): File "C:\Users\pulom\Downloads\GPG-drive-master\GPG-drive-master\examples\merging_scenario_paper.py", line 129, in vis.run() File "C:\Users\pulom\Downloads\GPG-drive-master\GPG-drive-master\src\visualize.py", line 725, in run pyglet.app.run() File "C:\Users\pulom\anaconda3\lib\site-packages\pyglet\app__init__.py", line 107, in run event_loop.run() File "C:\Users\pulom\anaconda3\lib\site-packages\pyglet\app\base.py", line 167, in run timeout = self.idle() File "C:\Users\pulom\anaconda3\lib\site-packages\pyglet\app\base.py", line 237, in idle redraw_all = self.clock.call_scheduled_functions(dt) File "C:\Users\pulom\anaconda3\lib\site-packages\pyglet\clock.py", line 292, in call_scheduled_functions item.func(now - item.last_ts, *item.args, **item.kwargs) File "C:\Users\pulom\Downloads\GPG-drive-master\GPG-drive-master\src\visualize.py", line 304, in control_loop vehicle.control(steer, gas) File "C:\Users\pulom\Downloads\GPG-drive-master\GPG-drive-master\src\car.py", line 767, in control self.initialize_solvers() File "C:\Users\pulom\Downloads\GPG-drive-master\GPG-drive-master\src\car.py", line 747, in initialize_solvers self.optimizer = lagrangiansolver.solver(self.id, self.players, self.shared_reward, self.g, self.h, self.v, self.lbv, self.ubv, File "C:\Users\pulom\Downloads\GPG-drive-master\GPG-drive-master\src\lagrangiansolver.py", line 147, in init self.solver = src.solvers.get_OpEn_solver(OpEn_problem, self.solver_settings, self.bounds, self.id) File "C:\Users\pulom\Downloads\GPG-drive-master\GPG-drive-master\src\solvers.py", line 120, in get_OpEn_solver build_OpEn_problem(OpEn_problem, solver_settings, optimizers_dir, id, id2, name) File "C:\Users\pulom\Downloads\GPG-drive-master\GPG-drive-master\src\solvers.py", line 73, in build_OpEn_problem builder.build() File "C:\Users\pulom\anaconda3\lib\site-packages\opengen\builder\optimizer_builder.py", line 646, in build self.build_optimizer() # build overall project File "C:\Users\pulom\anaconda3\lib\site-packages\opengen\builder\optimizer_builder.py", line 422, in build_optimizer p = subprocess.Popen(command, cwd=target_dir) File "C:\Users\pulom\anaconda3\lib\subprocess.py", line 951, in init self._execute_child(args, executable, preexec_fn, close_fds, File "C:\Users\pulom\anaconda3\lib\subprocess.py", line 1420, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, FileNotFoundError: [WinError 2] The system cannot find the file specified