Skip to content

Instantly share code, notes, and snippets.

@frapac

frapac/dualizer.jl

Created Oct 10, 2019
Embed
What would you like to do?
using MathOptInterface
using MathOptFormat
using Dualization
const MOI = MathOptInterface
const MOIU = MathOptInterface.Utilities
const MOF = MathOptFormat
# Mock model
MOIU.@model(TestModel,
(MOI.ZeroOne, MOI.Integer),
(MOI.EqualTo, MOI.GreaterThan, MOI.LessThan, MOI.Interval,
MOI.Semicontinuous, MOI.Semiinteger),
(MOI.Reals, MOI.Zeros, MOI.Nonnegatives, MOI.Nonpositives,
MOI.SecondOrderCone, MOI.RotatedSecondOrderCone,
MOI.GeometricMeanCone, MOI.ExponentialCone, MOI.DualExponentialCone,
MOI.PositiveSemidefiniteConeTriangle, MOI.PositiveSemidefiniteConeSquare,
MOI.RootDetConeTriangle, MOI.RootDetConeSquare, MOI.LogDetConeTriangle,
MOI.LogDetConeSquare),
(MOI.PowerCone, MOI.DualPowerCone, MOI.SOS1, MOI.SOS2),
(),
(MOI.ScalarAffineFunction, MOI.ScalarQuadraticFunction),
(MOI.VectorOfVariables,),
(MOI.VectorAffineFunction, MOI.VectorQuadraticFunction))
# Import original model
import_model = MOF.MPS.Model()
MOI.read_from_file(import_model, "input.mps")
# However, does not work with LP yet ...
# import_model = MOF.LP.Model() ->> FAIL
# Load it into mock model
model = TestModel{Float64}()
MOI.copy_to(model, import_model)
# Dualization.
dualmodel = dualize(model);
# Export dual model
export_model = MOF.LP.Model()
MOI.copy_to(export_model, dualmodel.dual_model)
MOI.write_to_file(export_model, "dual.lp")
@JanBerling

This comment has been minimized.

Copy link

@JanBerling JanBerling commented Oct 10, 2019

I get following error when trying with any example file:

julia> include("dualizer.jl")
ERROR: LoadError: Constraints of funtion MathOptInterface.SingleVariable in the Set MathOptInterface.ZeroOne are not implemented
.. snip...
in expression starting at C:\Users***\AppData\Local\Julia-1.2.0\dualizer.jl:38

With Julia v1.2.0, JuMP v0.20.0, MathOptInterface v0.9.4, MathOptFormat v0.2.2, Dualization v0.2.0

@frapac

This comment has been minimized.

Copy link
Owner Author

@frapac frapac commented Oct 15, 2019

I am able to reproduce the issue with some MPS files. I think the issue is related to MathOptFormat.jl: I will open a new issue for this package. Thanks for pointing me out this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.