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

TNLPAdapter::ResortBnds may return uninitialized values #352

Closed
cnpetra opened this issue Nov 14, 2019 · 1 comment
Closed

TNLPAdapter::ResortBnds may return uninitialized values #352

cnpetra opened this issue Nov 14, 2019 · 1 comment

Comments

@cnpetra
Copy link

cnpetra commented Nov 14, 2019

Calling TNLPAdapter::ResortBnds from TNLP::intermediate_callback leaves entries in the (output) second and fourth double arrays uninitialized. Please note that the uninitialized entries occur both when 'fixed_variable_treatment' is 'make_parameter' and 'make_constraint'. These uninitialized values/multipliers (seem to) correspond to the fixed variables, as expected. I can provide a modification of the simple Cpp_example for which valgrind reports uninitialized values.

First, I find that it is not good practice to let uninitialized values in an output array for obvious reasons. For my code, this creates some serious damage since I'm sending these arrays over MPI and some low-level system socket communication functions just freeze on a particular OS.

Second, it is a intriguing that this occurs also when 'fixed_variable_treatment' is 'make_constraint'. Isn't ResortBnds supposed to compute bound multipliers for fixed variables?

A quick fix on the caller code side is to initialize the two bound multipliers once prior to calling ResortBnds. But I hope this can be also fixed inside Ipopt or at least the method's signature to be changed to make it clear that not all values are returned (e.g., should also return a flag and indexes of the bounds computed/returned).

Cosmin

@svigerske
Copy link
Member

ResortBnds doesn't compute multipliers, it only fills the entries of the given arrays that do not correspond to fixed variables.
The bound multipliers for fixed variables after set after the call to ResortBnds, see from https://github.com/coin-or/Ipopt/blob/master/src/Interfaces/IpTNLPAdapter.cpp#L2101 on.

I think I can change the method to initialize all array entries to 0.0 by default and add a flag that allows to disable this.

svigerske added a commit that referenced this issue Apr 12, 2021
- makes the code from FinalizeSolution that gets the duals for fixed
  variables if fixed-variable-treatment is set to make_constraint
  available
- use it in TNLP::get_current_iterate()
- related to #352, 2695051
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

No branches or pull requests

2 participants