Writing Custom Optimization Problems

Example script demonstrating the use of RosenbrockRollout for optimization.

This script creates a RosenbrockRollout instance and uses it with an optimizer to find the minimum of the Rosenbrock function.

Output files are written to ~/.cache/curobo/examples/custom_optimization/ by default. Override with curobo.runtime.cache_dir.

load_torch_opt(
rosenbrock_config,
device_cfg,
)
load_scipy_opt(
rosenbrock_config,
device_cfg,
)
main()
visualize_batch_rosenbrock_3d(
action_history,
config,
plot_path=True,
)

Visualize the Rosenbrock function and optimization path in 3D.

Parameters:
  • action_history – List of action tensors with shape (batch_size, horizon, action_dim)

  • config – RosenbrockCfg object containing function parameters

visualize_batch_rosenbrock(
action_history,
config,
plot_path=True,
)

Visualize the Rosenbrock function and optimization path.

Parameters:
  • action_history – List of action tensors with shape (batch_size, horizon, action_dim)

  • config – RosenbrockCfg object containing function parameters

Run this example

python -m curobo.examples.guides.custom_optimization