File tree Expand file tree Collapse file tree 2 files changed +2
-13
lines changed Expand file tree Collapse file tree 2 files changed +2
-13
lines changed Original file line number Diff line number Diff line change @@ -306,26 +306,17 @@ end
306306
307307Write the current problem to the file at `filename`.
308308
309- Requires solving the problem at least once using [`solve!`](@ref) to ensure that
310- the problem is loaded into a MathOptInterface model.
311-
312309The file format is inferred from the filename extension. Supported file
313310types depend on the model type.
314311
315312Currently, `Float64` is the only supported coefficient type. This may be
316313relaxed in future if file formats support other types.
317314"""
318315function write_to_file (p:: Problem{T} , filename:: String ) where {T<: Float64 }
319- if p. model === nothing
320- msg = """
321- Problem has not been loaded into a MathOptInterface model;
322- call `solve!(problem, optimizer)` before writing problem to file.
323- """
324- throw (ArgumentError (msg))
325- end
316+ src = Context (p, MOI. Utilities. Model{T})
326317 dest = MOI. FileFormats. Model (; filename)
327318 model = MOI. Bridges. full_bridge_optimizer (dest, T)
328- MOI. copy_to (model, p . model)
319+ MOI. copy_to (model, src . model)
329320 MOI. write_to_file (dest, filename)
330321 return
331322end
Original file line number Diff line number Diff line change @@ -922,8 +922,6 @@ function test_write_to_file()
922922 p = minimize (logsumexp (x))
923923 dir = mktempdir ()
924924 filename = joinpath (dir, " test.mof.json" )
925- @test_throws ArgumentError write_to_file (p, filename)
926- solve! (p, SCS. Optimizer; silent_solver = true )
927925 write_to_file (p, filename)
928926 @test occursin (" ExponentialCone" , read (filename, String))
929927 p_int = minimize (logsumexp (x); numeric_type = Int)
You can’t perform that action at this time.
0 commit comments