Skip to content

Commit

Permalink
[SymForce] Reorder optimizer.py docstring
Browse files Browse the repository at this point in the history
To put the more typical case first

Reviewers: nathan,bradley,chao
Topic: sym-optimizer-py-docstring
GitOrigin-RevId: dc80c42943265b90b7b618b18e4d91f714cb17d3
  • Loading branch information
aaron-skydio committed Mar 8, 2023
1 parent 35fd2d9 commit 7269521
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions symforce/opt/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,22 @@ class Optimizer:
Typical usage is to construct an Optimizer from a set of factors and keys to optimize, and then
call `optimize` repeatedly with a `Values`.
Example creation with a single `Factor`:
factor = Factor(
[my_key_0, my_key_1, my_key_2], my_residual_function
)
optimizer = Optimizer(
factors=[factor],
optimized_keys=[my_key_0, my_key_1],
)
And usage:
initial_guess = Values(...)
result = optimizer.optimize(initial_guess)
print(result.optimized_values)
Example creation with an `OptimizationProblem` using `make_numeric_factors()`. The linearization
functions are generated in `make_numeric_factors()` and are linearized with respect to
`problem.optimized_keys()`.
Expand All @@ -44,22 +60,6 @@ class Optimizer:
factors = problem.make_symbolic_factors("my_problem")
optimizer = Optimizer(factors, problem.optimized_keys())
Example creation with a single `Factor`:
factor = Factor(
[my_key_0, my_key_1, my_key_2], my_residual_function
)
optimizer = Optimizer(
factors=[factor],
optimized_keys=[my_key_0, my_key_1],
)
And usage:
initial_guess = Values(...)
result = optimizer.optimize(initial_guess)
print(result.optimized_values)
Wraps the C++ `sym::Optimizer` class in `opt/optimizer.h`, so the API is mostly the same and
optimization results will be identical.
Expand Down

0 comments on commit 7269521

Please sign in to comment.