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

Don't eval jac_structure if problem has no constraints #71

Merged
merged 1 commit into from
Dec 8, 2016

Conversation

abelsiqueira
Copy link
Contributor

No description provided.

@tkelman
Copy link
Contributor

tkelman commented Oct 25, 2016

shouldn't you be implementing the empty jacobian in this case?

@mlubin
Copy link
Member

mlubin commented Oct 25, 2016

@tkelman, there's an argument that NLP evaluators for unconstrained models shouldn't need to do anything at all for jacobians

@coveralls
Copy link

coveralls commented Oct 25, 2016

Coverage Status

Coverage decreased (-0.1%) to 82.609% when pulling 7c7e2a2 on abelsiqueira:nojac into 41b1e70 on JuliaOpt:master.

@tkelman
Copy link
Contributor

tkelman commented Oct 25, 2016

when trying to use a constrained solver?

@mlubin
Copy link
Member

mlubin commented Oct 25, 2016

MPB has no distinction between a constrained and unconstrained solver. I don't see the harm in not asking for jacobian information if we already know that the problem has no constraints.

@mlubin
Copy link
Member

mlubin commented Oct 25, 2016

@abelsiqueira, have you tested if Ipopt invokes the jacobian callbacks when there are no constraints?

@abelsiqueira
Copy link
Contributor Author

No, let me check.

@abelsiqueira
Copy link
Contributor Author

I tested it, it invokes the callback with mode = :Structure. What do you suggest I do?

@mlubin
Copy link
Member

mlubin commented Oct 25, 2016

@abelsiqueira, that's not an issue since we initialize Ijac, Jjac.

@dpo
Copy link
Contributor

dpo commented Oct 25, 2016

It's really IPOPT's job to allocate a vacuous Jacobian (if it really wants to) when a problem is unconstrained.

@tkelman
Copy link
Contributor

tkelman commented Oct 25, 2016

Not really, the solver API specifies what you're responsible for providing.

@dpo
Copy link
Contributor

dpo commented Oct 25, 2016

It simply makes no sense to ask a user to implement cons and jac for an unconstrained problem.

@tkelman
Copy link
Contributor

tkelman commented Oct 25, 2016

then you're requiring separate api's for unconstrained vs constrained. from a primarily constrained solver's perspective, it makes perfect sense to only have the more general api.

@dpo
Copy link
Contributor

dpo commented Oct 25, 2016

Nah.

@mlubin
Copy link
Member

mlubin commented Oct 25, 2016

@tkelman, I don't see the harm in accommodating this use case given that it doesn't complicate the code and @abelsiqueira has stepped forward to do the work.

If we want to make this more "formally" part of the MPB interface, it would be nice for the unit tests to have a case that covers an unconstrained problem where jac isn't implemented.

This also relates to the discussion at JuliaOpt/MathProgBase.jl#87.

@tkelman
Copy link
Contributor

tkelman commented Oct 26, 2016

Are you going to require every solver to implement this the same way? Seems like you're getting lucky that Ipopt only evaluates this callback in structure mode here, but other constrained solvers may always require the same set of callbacks to be defined and always call them.

@abelsiqueira
Copy link
Contributor Author

I don't know who is calling the Jacobian callback, but perhaps it should not be called for an unconstrained problem. Otherwise, I can redefine the callback when the problem is unconstrained and solve locally.

I'm implementing this way because before it was always using the :Jac feature, regardless of availability.

For our models, we're considering prohibitive behaviour on calling functions not in a list of features.

@mlubin
Copy link
Member

mlubin commented Oct 26, 2016

@abelsiqueira, @tkelman's point is that you're now redefining the MPB interface. So let's do it correctly. We need a unit test at https://github.com/JuliaOpt/MathProgBase.jl/blob/master/test/nlp.jl for this behavior and the other open-source solvers (i.e., NLopt) need to be checked and updated as well.

@tkelman
Copy link
Contributor

tkelman commented Oct 26, 2016

I don't think MPB should be imposing that all constrained solvers have to support this.

@mlubin
Copy link
Member

mlubin commented Oct 26, 2016

@tkelman, it seems like a very small amount of work. Worst case you have a boolean flag that skips the call to eval_jac_g.

@tkelman
Copy link
Contributor

tkelman commented Oct 26, 2016

Not if it's built into the way the solver works, several of which we won't be able to change.

@mlubin
Copy link
Member

mlubin commented Oct 26, 2016

@tkelman, what do you mean? This is only at the level at the MPB wrapper which we have full control over.

@tkelman
Copy link
Contributor

tkelman commented Oct 26, 2016

Aren't MPB wrappers supposed to be low level with as little required complication as possible on top of the solver API's themselves?

@mlubin
Copy link
Member

mlubin commented Oct 26, 2016

@tkelman, even so, replacing eval_jac_g(...) with m.has_jac && eval_jac_g(...) hardly seems to exceed the "little required complication" barrier.

@mlubin
Copy link
Member

mlubin commented Oct 26, 2016

(The translation from the triplet-with-duplicates form to upper-triangular-no-duplicates form in KNITRO is more complicated, in fact.)

@dpo
Copy link
Contributor

dpo commented Oct 26, 2016

If we can establish that Knitro attempts to evaluate the constraints/Jacobian on unconstrained problems, I'm happy to talk about it with its authors.

@mlubin
Copy link
Member

mlubin commented Nov 29, 2016

@abelsiqueira, if you're willing to add the unit tests to MathProgBase as discussed above, I'm okay proceeding with this.

@abelsiqueira
Copy link
Contributor Author

Okay, I'll look into it.

@abelsiqueira
Copy link
Contributor Author

@mlubin , it looks like nlp.jl is not being used ATM. There's no include to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

5 participants