Skip to content

reject NL objectives in MOI wrapper #128

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v1
- uses: actions/cache@v4
env:
cache-name: cache-artifacts
with:
Expand Down
44 changes: 44 additions & 0 deletions src/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ end
MOI.is_empty(optimizer::Optimizer) = optimizer.inner.isempty

function MOI.copy_to(dest::Optimizer, src::MOI.ModelLike)

#check all model/variable/constraint attributes to
#ensure that everything passed is handled by the solver
copy_to_check_attributes(dest,src)

MOI.empty!(dest)
idxmap = MOIU.IndexMap(dest, src)
assign_constraint_row_ranges!(dest.rowranges, idxmap, src)
Expand All @@ -167,6 +172,45 @@ function MOI.copy_to(dest::Optimizer, src::MOI.ModelLike)
return idxmap
end

function copy_to_check_attributes(dest, src)

#allowable model attributes
for attr in MOI.get(src, MOI.ListOfModelAttributesSet())
if attr == MOI.Name() ||
attr == MOI.ObjectiveSense() ||
attr isa MOI.ObjectiveFunction
continue
end
throw(MOI.UnsupportedAttribute(attr))
end

#allowable variable attributes
for attr in MOI.get(src, MOI.ListOfVariableAttributesSet())
if attr == MOI.VariableName() ||
attr == MathOptInterface.VariablePrimalStart()
continue
end
throw(MOI.UnsupportedAttribute(attr))
end

#allowable constraint types and attributes
for (F, S) in MOI.get(src, MOI.ListOfConstraintTypesPresent())
if !MOI.supports_constraint(dest, F, S)
throw(MOI.UnsupportedConstraint{F, S}())
end
for attr in MOI.get(src, MOI.ListOfConstraintAttributesSet{F, S}())
if attr == MOI.ConstraintName() ||
attr == MOI.ConstraintDualStart()
continue
end
throw(MOI.UnsupportedAttribute(attr))
end
end

return nothing
end


"""
Set up index map from `src` variables and constraints to `dest` variables and constraints.
"""
Expand Down
26 changes: 13 additions & 13 deletions test/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,28 +61,28 @@ function test_runtests()
MOI.Test.runtests(
model,
config,
exclude = String[
exclude = Union{String, Regex}[
"test_attribute_SolverVersion",
# Expected test failures:
# MathOptInterface.jl issue #1431
"test_model_LowerBoundAlreadySet",
"test_model_UpperBoundAlreadySet",
# FIXME
# See https://github.com/jump-dev/MathOptInterface.jl/issues/1773
"test_infeasible_MAX_SENSE",
"test_infeasible_MAX_SENSE_offset",
"test_infeasible_MIN_SENSE",
"test_infeasible_MIN_SENSE_offset",
"test_infeasible_affine_MAX_SENSE",
"test_infeasible_affine_MAX_SENSE_offset",
"test_infeasible_affine_MIN_SENSE",
"test_infeasible_affine_MIN_SENSE_offset",
r"^test_infeasible_MAX_SENSE$",
r"test_infeasible_MAX_SENSE_offset$",
r"^test_infeasible_MIN_SENSE$",
r"test_infeasible_MIN_SENSE_offset$",
r"^test_infeasible_affine_MAX_SENSE$",
r"test_infeasible_affine_MAX_SENSE_offset$",
r"^test_infeasible_affine_MIN_SENSE$",
r"test_infeasible_affine_MIN_SENSE_offset$",
# FIXME
# See https://github.com/jump-dev/MathOptInterface.jl/issues/1759
"test_unbounded_MAX_SENSE",
"test_unbounded_MAX_SENSE_offset",
"test_unbounded_MIN_SENSE",
"test_unbounded_MIN_SENSE_offset",
r"test_unbounded_MAX_SENSE$",
r"test_unbounded_MAX_SENSE_offset$",
r"^test_unbounded_MIN_SENSE$",
r"test_unbounded_MIN_SENSE_offset$",
# FIXME
"test_model_copy_to_UnsupportedAttribute",
Copy link
Contributor

Choose a reason for hiding this comment

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

This might be fixed now?

Copy link
Author

@goulart-paul goulart-paul Mar 7, 2025

Choose a reason for hiding this comment

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

It seems like quite a few of the disabled tests are passing now. I have reenabled those that pass on my local machine. If they also pass CI checks that probably OK to bring them back.

# Segfault
Expand Down
Loading