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

Enabled warm-start flag for MOSEK10 and moved var initialization to _add_vars #2647

Merged
merged 4 commits into from
Jan 10, 2023

Conversation

Utkarsh-Detha
Copy link
Contributor

Summary/Motivation:

Issue #2613 was caused by a rare assert failure within MOSEK 10. That has since been fixed (please upgrade to MOSEK 10.0.30).

But, while looking at the warmstart function in mosek_direct.py, I noticed that a parameter required to turn on initial solution utilization (only for v10 onwards) was missing.

Changes proposed in this PR:

  • Enabed mosek.iparam.mio_construct_sol in warm_start function in mosek_direct.py
  • Moved the code that passes variable initialization values from the _warm_start function to the _add_vars function.

Legal Acknowledgement

By contributing to this software project, I have read the contribution guide and agree to the following terms and conditions for my contribution:

  1. I agree my contributions are submitted under the BSD license.
  2. I represent I am authorized to make the contributions and grant the license. If my employer has rights to intellectual property that includes these contributions, I represent that I have received permission to make contributions and grant the required license on behalf of that employer.

jsiirola
jsiirola previously approved these changes Dec 2, 2022
Copy link
Member

@jsiirola jsiirola left a comment

Choose a reason for hiding this comment

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

Looks good!

Comment on lines 365 to 370
# Initialize variables
for m_v, p_v in zip(var_ids, var_seq):
if p_v.value is not None:
for sol_type in mosek.soltype.values:
self._solver_model.putxxslice(
sol_type, m_v, m_v + 1, [(p_v.value)])
Copy link
Member

Choose a reason for hiding this comment

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

Question: by moving this to _add_vars(), does this prevent the variable values from being updated between subsequent solves in the case of the persistent solver?

Copy link
Contributor Author

@Utkarsh-Detha Utkarsh-Detha Dec 2, 2022

Choose a reason for hiding this comment

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

The same task object instance will be used over subsequent solves (when using mosek_persistent). So, the variable values from the previous solve will already be in that particular task. Pyomo would not have to pass them again. We only need to tell mosek if it should use those values or ignore them. (@jsiirola )

Copy link
Member

Choose a reason for hiding this comment

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

@Utkarsh-Detha: Correct, but if the user changed the Pyomo variable value between calls to solve() (e.g., in the context of a multistart procedure), those new values will no longer be sent to to MOSEK. I think that the correct thing to do is to leave this in _warm_start, but if you do move it, then the logic also needs to be added to update_vars() in mosek_persistent.py.

Copy link
Member

Choose a reason for hiding this comment

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

@Utkarsh-Detha, reminder that this PR is waiting on a response from you to the above comment from @jsiirola.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jsiirola then I suppose we just leave it as is. I will undo the changes concerning this.

(Sorry about the slow response, I have been on holiday)

@jsiirola jsiirola dismissed their stale review December 2, 2022 18:51

(Need an answer about the effect of moving the variable warmstart on the persistent solver interface before morging)

@codecov
Copy link

codecov bot commented Dec 2, 2022

Codecov Report

Base: 87.06% // Head: 87.06% // Increases project coverage by +0.00% 🎉

Coverage data is based on head (e15746d) compared to base (2e01eb7).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2647   +/-   ##
=======================================
  Coverage   87.06%   87.06%           
=======================================
  Files         757      757           
  Lines       84448    84455    +7     
=======================================
+ Hits        73521    73529    +8     
+ Misses      10927    10926    -1     
Flag Coverage Δ
linux 84.49% <7.14%> (-0.01%) ⬇️
osx 74.52% <7.14%> (-0.01%) ⬇️
other 84.67% <7.14%> (-0.01%) ⬇️
win 81.83% <7.14%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pyomo/solvers/plugins/solvers/mosek_direct.py 67.84% <100.00%> (+0.28%) ⬆️
pyomo/core/expr/visitor.py 93.40% <0.00%> (+0.15%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@Utkarsh-Detha Utkarsh-Detha mentioned this pull request Jan 3, 2023
Copy link
Member

@jsiirola jsiirola left a comment

Choose a reason for hiding this comment

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

This looks good!

@mrmundt mrmundt merged commit 7b1c396 into Pyomo:main Jan 10, 2023
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.

5 participants