Skip to content

Interaction with MOIU.Parser and Objective.SlackBridge can break MOIT.unittest #1290

@mewilhel

Description

@mewilhel

So I'm reworking the EAGO.jl solver (simplifying the internals and hooking into more MOI functionality). I've setup a working version of the optimizer to only support MOI.ScalarAffineFunction and nonlinear objectives (using bridges to handle scalar quadratic and single variable constraints). Currently, it looks like the parser triggers an error when running MOIT.unittest

`MOI.ObjectiveSense` before `MOI.ObjectiveFunction` when using `MOI.Bridges.Objective.SlackBridge

It looks like the parser currently loads from string which includes the following segment of code (around line 268 of parser.jl)

        elseif label == :maxobjective
            f = parsedtoMOI(model, parsefunction(ex))
            MOI.set(model, MOI.ObjectiveFunction{typeof(f)}(), f)
            MOI.set(model, MOI.ObjectiveSense(), MOI.MAX_SENSE)
        elseif label == :minobjective
            f = parsedtoMOI(model, parsefunction(ex))
            MOI.set(model, MOI.ObjectiveFunction{typeof(f)}(), f)
            MOI.set(model, MOI.ObjectiveSense(), MOI.MIN_SENSE)

If I swap to the ordering around as so,

        elseif label == :maxobjective
            f = parsedtoMOI(model, parsefunction(ex))
            MOI.set(model, MOI.ObjectiveSense(), MOI.MAX_SENSE)
            MOI.set(model, MOI.ObjectiveFunction{typeof(f)}(), f)
        elseif label == :minobjective
            f = parsedtoMOI(model, parsefunction(ex))
            MOI.set(model, MOI.ObjectiveSense(), MOI.MIN_SENSE)
            MOI.set(model, MOI.ObjectiveFunction{typeof(f)}(), f)

then my solver now passes MOIT.unittest.

Mind if I put in a pull request to this effect?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions