Skip to content
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

Update OptimizationFunction, OptimizationProblem and solve docstrings #431

Merged
merged 9 commits into from
Oct 28, 2023

Conversation

Vaibhavdixit02
Copy link
Member

@codecov
Copy link

codecov bot commented Apr 6, 2023

Codecov Report

Merging #431 (7b733bd) into master (37042e1) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     SciML/Optimization.jl#431      +/-   ##
==========================================
+ Coverage   56.47%   56.48%   +0.01%     
==========================================
  Files          54       54              
  Lines        3938     3937       -1     
==========================================
  Hits         2224     2224              
+ Misses       1714     1713       -1     
Files Coverage Δ
src/problems/basic_problems.jl 78.75% <ø> (ø)
src/scimlfunctions.jl 62.35% <100.00%> (-0.07%) ⬇️
src/solve.jl 71.87% <ø> (ø)

... and 1 file with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

* `p`: the constant parameters used for defining the problem. Defaults to `NullParameters`.
* `lb`: the lower bounds for the optimization variables `u`.
* `ub`: the upper bounds for the optimization variables `u`.
* `int`: integrality indicator for `u`. If `int[i] == 1`, then `u[i]` is an integer variable.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not boolean?

Copy link
Contributor

@baggepinnen baggepinnen May 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Integer variables are more general. Integer constraint together with $0 \leq x \leq 1$ indicates boolean. Most mixed-integer solvers support integer variables, not only boolean.

Comment on lines 2028 to 2056
- `cons_j(res,x,p)`: the Jacobian of the constraints.
- `cons_h(res,x,p)`: the Hessian of the constraints, provided as
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing the oop version

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The oop versions are not supported yet right

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, that's a solver implementation thing, not an interface thing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There have been a couple of issues asking about this and since it is not there I think it makes sense to remove it for now and add back once it is implemented?

- `syms`: the symbol names for the elements of the equation. This should match `u0` in size. For
example, if `u = [0.0,1.0]` and `syms = [:x, :y]`, this will apply a canonical naming to the
values, allowing `sol[:x]` in the solution and automatically naming values in plots.
- `paramsyms`: the symbol names for the parameters of the equation. This should match `p` in
size. For example, if `p = [0.0, 1.0]` and `paramsyms = [:a, :b]`, this will apply a canonical
naming to the values, allowing `sol[:a]` in the solution.
- `hess_colorvec`: a color vector according to the SparseDiffTools.jl definition for the sparsity
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added the fields back but removing it from docstrings seems reasonable until there is a release with support for it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These pieces are still correct if they are unused though. It's not like it leads to any correctness, it's just lack of optimization for them to not be used.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But as a user, it would be confusing to see documented fields that are not used anywhere? It will be trivial to add them back as soon as their use gets implemented

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be trivial to add them back as soon as their use gets implemented

We have a policy of not going this direction because it never happens as planned. Docs of interfaces stay complete. If a package isn't matching the interface, the package should change.

But as a user, it would be confusing to see documented fields that are not used anywhere?

We've never had issues with that in the past. Not useful features are generally just ignored until they are useful. And this one is deep in the weeds.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added it back

for `u₀`; one is allowed to provide `u₀` as arbitrary matrices /
higher-dimension tensors as well.
higher-dimension tensors as well if the optimization solver supports it.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which optimizers don't support it? why is it not vec/reshaped?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just not implemented

src/problems/basic_problems.jl Outdated Show resolved Hide resolved
src/problems/basic_problems.jl Outdated Show resolved Hide resolved
Comment on lines 2028 to 2056
- `cons_j(res,x,p)`: the Jacobian of the constraints.
- `cons_h(res,x,p)`: the Hessian of the constraints, provided as
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The oop versions are not supported yet right

- `syms`: the symbol names for the elements of the equation. This should match `u0` in size. For
example, if `u = [0.0,1.0]` and `syms = [:x, :y]`, this will apply a canonical naming to the
values, allowing `sol[:x]` in the solution and automatically naming values in plots.
- `paramsyms`: the symbol names for the parameters of the equation. This should match `p` in
size. For example, if `p = [0.0, 1.0]` and `paramsyms = [:a, :b]`, this will apply a canonical
naming to the values, allowing `sol[:a]` in the solution.
- `hess_colorvec`: a color vector according to the SparseDiffTools.jl definition for the sparsity
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added the fields back but removing it from docstrings seems reasonable until there is a release with support for it?

- `hv(Hv,u,v,p)` or `Hv=hv(u,v,p)`: the Hessian-vector product ``(d^2 f / du^2) v``.
- `cons(res,x,p)` or `cons(x,p)` : the constraints function, should mutate or return a vector
- `grad(G,u,p)`: the gradient of `f` with respect to `u`. If `f` takes additional arguments
then `grad(G,u,p,args...)` should be used.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

? what's a case for that?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh data handling.

then `grad(G,u,p,args...)` should be used.
- `hess(H,u,p)`: the Hessian of `f` with respect to `u`. If `f` takes additional arguments
then `hess(H,u,p,args...)` should be used.
- `hv(Hv,u,v,p)`: the Hessian-vector product ``(d^2 f / du^2) v``. If `f` takes additional arguments
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are missing the out of place definitions.

@Vaibhavdixit02
Copy link
Member Author

LGTM?

@ChrisRackauckas ChrisRackauckas merged commit a29ecf1 into master Oct 28, 2023
64 of 70 checks passed
@ChrisRackauckas ChrisRackauckas deleted the optdocs branch October 28, 2023 03:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Documentation callbacks.
4 participants