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

Add support for starting values #166

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Add support for starting values #166

wants to merge 8 commits into from

Conversation

blegat
Copy link
Member

@blegat blegat commented Nov 10, 2023

This also fixes a bug: the result_index were ignored and we would invariably query the first solution.

  • Test for starting values
  • Test for the result_index bug
  • Constrained variables

Closes #165

Copy link

codecov bot commented Nov 10, 2023

Codecov Report

Attention: 36 lines in your changes are missing coverage. Please review.

Comparison is base (208b284) 94.73% compared to head (2438c31) 90.20%.

❗ Current head 2438c31 differs from pull request most recent head 7bd05ee. Consider uploading reports for the commit 7bd05ee to get more accurate results

Files Patch % Lines
src/MOI_wrapper.jl 14.28% 36 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #166      +/-   ##
==========================================
- Coverage   94.73%   90.20%   -4.54%     
==========================================
  Files          13       13              
  Lines         703      745      +42     
==========================================
+ Hits          666      672       +6     
- Misses         37       73      +36     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

::MOI.VariablePrimalStart,
::Type{MOI.VariableIndex},
)
return true
Copy link
Member

Choose a reason for hiding this comment

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

This needs to check whether the inner optimizer supports ConstraintDualStart

Copy link
Member Author

Choose a reason for hiding this comment

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

It's a bit tricky because we don't know the type of constraints. The inner may not support equality constraints in which case we cannot even ask for whether the solver supports ScalarAffineFunction-in-EqualTo

Copy link
Member

Choose a reason for hiding this comment

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

Yeah I don't know what a good answer is here

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 think I have an idea that I'll try next week

if vi in keys(primal_dual_map.constrained_var_idx)
error(
"Setting starting value for variables constrained at creation is not supported yet",
)
Copy link
Member

Choose a reason for hiding this comment

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

This should throw MOI.SetAttributeNotAllowed{MOI.VariablePrimalStart}

@@ -330,23 +389,53 @@ function MOI.get(
ci_dual = primal_dual_map.constrained_var_dual[ci_primal]
return _get_at_index(
optimizer,
MOI.ConstraintDual(),
_dual_attribute(attr),
ci_primal,
ci_dual,
idx,
)
else
return -MOI.get(
Copy link
Member

Choose a reason for hiding this comment

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

The - does not account for VariablePrimalStart returning nothing

::Union{MOI.ConstraintDualStart,MOI.ConstraintPrimalStart},
::Type{<:MOI.ConstraintIndex},
)
return true
Copy link
Member

Choose a reason for hiding this comment

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

Needs to check the inner optimizer supports VariablePrimalStart. I don't know if ConstraintPrimalStart makes sense to support?

end

function _dual_attribute(
::Union{MOI.VariablePrimalStart,MOI.ConstraintPrimalStart},
Copy link
Member

Choose a reason for hiding this comment

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

I know know that it makes sense to support MOI.ConstraintPrimalStart?

if ci in keys(primal_dual_map.constrained_var_dual)
error(
"Setting starting value for variables constrained at creation is not supported yet",
)
Copy link
Member

Choose a reason for hiding this comment

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

SetAttributeNotAllowed

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.

Support starting values
2 participants