Skip to content

Instantly share code, notes, and snippets.

@frapac
Created October 10, 2019 16:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frapac/86fd965a252012ba1d4ce3b39dee0390 to your computer and use it in GitHub Desktop.
Save frapac/86fd965a252012ba1d4ce3b39dee0390 to your computer and use it in GitHub Desktop.
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
Copy link

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
Copy link
Author

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