Skip to content

Commit

Permalink
fixing tests 2
Browse files Browse the repository at this point in the history
  • Loading branch information
FilippoAiraldi committed May 27, 2024
1 parent 1f901b8 commit ab715ad
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions examples/bayesopt.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
from gymnasium import Env, ObservationWrapper
from gymnasium.spaces import Box
from gymnasium.wrappers import TimeLimit, TransformReward
from joblib import Parallel
from scipy.stats.qmc import LatinHypercube

from mpcrl import (
Expand Down Expand Up @@ -246,12 +245,11 @@ def get_cstr_mpc(
env: CstrEnv, horizon: int, multistarts: int, n_jobs: int
) -> Mpc[cs.SX]:
"""Returns an MPC controller for the given CSTR env."""
# create a custom parallel object for the multistart NLP
parallel = Parallel(n_jobs=n_jobs, return_as="generator")
parallel.__enter__() # not strictly necessary, but good practice

# create NLP instance and MPC wrapper
nlp = ParallelMultistartNlp[cs.SX]("SX", starts=multistarts, parallel=parallel)
nlp = ParallelMultistartNlp[cs.SX](
"SX",
starts=multistarts,
parallel_kwargs={"n_jobs": n_jobs, "return_as": "generator"},
)
mpc = Mpc[cs.SX](nlp, horizon)

# variables (state, action)
Expand Down

0 comments on commit ab715ad

Please sign in to comment.