8000 Python: `build` and `generate` flags for batch solvers by sandmaennchen · Pull Request #1404 · acados/acados · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Python: build and generate flags for batch solvers #1404

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,30 @@

class AcadosOcpBatchSolver():
"""
Batch Integrator for parallel integration.
Batch OCP solver for parallel solves.

:param sim: type :py:class:`~acados_template.acados_sim.AcadosOcp`
:param ocp: type :py:class:`~acados_template.acados_ocp.AcadosOcp`
:param N_batch: batch size, positive integer
:param json_file: Default: 'acados_sim.json'
:param json_file: Default: 'acados_ocp.json'
:param build: Flag indicating whether solver should be (re)compiled. If False an attempt is made to load an already compiled shared library for the solver. Default: True
:param generate: Flag indicating whether problem functions should be code generated. Default: True
:verbose: bool, default: True
"""

__ocp_solvers : List[AcadosOcpSolver]

def __init__(self, ocp: AcadosOcp, N_batch: int, json_file: str = 'acados_ocp.json', verbose: bool=True):
def __init__(self, ocp: AcadosOcp, N_batch: int, json_file: str = 'acados_ocp.json', build: bool = True, generate: bool = True, verbose: bool=True):

if not isinstance(N_batch, int) or N_batch <= 0:
raise Exception("AcadosOcpBatchSolver: argument N_batch should be a positive integer.")

self.__N_batch = N_batch
self.__ocp_solvers = [AcadosOcpSolver(ocp, json_file=json_file, build=n==0, generate=n==0, verbose=verbose) for n in range(self.N_batch)]
self.__ocp_solvers = [AcadosOcpSolver(ocp,
json_file=json_file,
build=n==0 if build else False,
generate=n==0 if generate else False,
verbose=verbose)
for n in range(self.N_batch)]

self.__shared_lib = self.ocp_solvers[0].shared_lib
self.__acados_lib = self.ocp_solvers[0].acados_lib
Expand Down
8000
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,25 @@ class AcadosSimBatchSolver():
:param sim: type :py:class:`~acados_template.acados_sim.AcadosSim`
:param N_batch: batch size, positive integer
:param json_file: Default: 'acados_sim.json'
:param build: Flag indicating whether solver should be (re)compiled. If False an attempt is made to load an already compiled shared library for the solver. Default: True
:param generate: Flag indicating whether problem functions should be code generated. Default: True
:verbose: bool, default: True
"""

__sim_solvers : List[AcadosSimSolver]

def __init__(self, sim: AcadosSim, N_batch: int, json_file: str = 'acados_sim.json', verbose: bool=True):
def __init__(self, sim: AcadosSim, N_batch: int, json_file: str = 'acados_sim.json', build: bool = True, generate: bool = True, verbose: bool=True):

if not isinstance(N_batch, int) or N_batch <= 0:
raise Exception("AcadosSimBatchSolver: argument N_batch should be a positive integer.")

self.__N_batch = N_batch
self.__sim_solvers = [AcadosSimSolver(sim, json_file=json_file, build=n==0, generate=n==0, verbose=verbose) for n in range(self.N_batch)]
self.__sim_solvers = [AcadosSimSolver(sim,
json_file=json_file,
build=n==0 if build else False,
generate=n==0 if generate else False,
verbose=verbose)
for n in range(self.N_batch)]

self.__shared_lib = self.sim_solvers[0].shared_lib
self.__model_name = self.sim_solvers[0].model_name
Expand Down
Loading
0