alphaville / optimization-engine

Nonconvex embedded optimization: code generation for fast real-time optimization + ROS support
https://alphaville.github.io/optimization-engine/
Other
509 stars 53 forks source link

Print or log out parameter length when compiling the solver #316

Closed strimble08 closed 1 year ago

strimble08 commented 1 year ago

Is your feature request related to a problem? Please describe. When creating the solver it would be useful to have a way to return the length of the parameters list. This would allow for faster local debug, or unit testing.

Describe the solution you'd like On compile, the length of the parameter list is returned and can be stored as a variable.

Describe alternatives you've considered The length of the list being sent to the solver can be checked manually at runtime by checking the parameters going in, but there is no way to check the length that the solver expects until there is an error returned.

Additional context Nope.

alphaville commented 1 year ago

Shane, that's a good point. Just note that the number of parameters is the length of the vector p, which is provided by the user. I will improve the error message as well.

alphaville commented 1 year ago

@strimble08 Now the builder returns this information (in the form of a dictionary). Will this be sufficient?

build_config:
  build_c_bindings: true
  build_directory: my_optimizers
  build_mode: debug
  build_python_bindings: true
  open_version: '*'
  rebuild: false
  ros_config:
    description: cool ROS node
    node_name: open_node
    package_name: parametric_optimizer
    params_topic_queue_size: 100
    publisher_subtopic: result
    rate: 35
    result_topic_queue_size: 100
    subscriber_subtopic: parameters
  target_system: null
  tcp_interface_config:
    ip: 127.0.0.1
    port: 8333
meta:
  author:
  - John Smith
  licence: MIT
  name: rosenbrock
  version: 0.0.0
paths:
  target: /Users/me/Documents/Development/OpEn/open-codegen/my_optimizers/rosenbrock
problem:
  dim_constraints_aug_lagrangian: 0
  dim_constraints_penalty: 2
  dim_decision_variables: 5
  dim_parameters: 2
solver_config:
  cbfgs_alpha: null
  cbfgs_epsilon: null
  cbfgs_sy_epsilon: null
  constraints_tolerance: 0.0001
  do_preconditioning: true
  initial_penalty: null
  initial_tolerance: 0.0001
  inner_tolerance_update_factor: 0.1
  lbfgs_memory: 10
  max_duration_micros: 5000000
  max_inner_iterations: 1000
  max_outer_iterations: 30
  penalty_weight_update_factor: 1.5
  sufficient_decrease_coefficient: 0.1
  tolerance: 1.0e-06
strimble08 commented 1 year ago

Yes looks great - I can see this info in one dict being useful for more than just the initial feature I suggested.

alphaville commented 1 year ago

This is now available in opengen, version 0.7.1.