File tree 2 files changed +2
-13
lines changed
2 files changed +2
-13
lines changed Original file line number Diff line number Diff line change @@ -306,26 +306,17 @@ end
306
306
307
307
Write the current problem to the file at `filename`.
308
308
309
- Requires solving the problem at least once using [`solve!`](@ref) to ensure that
310
- the problem is loaded into a MathOptInterface model.
311
-
312
309
The file format is inferred from the filename extension. Supported file
313
310
types depend on the model type.
314
311
315
312
Currently, `Float64` is the only supported coefficient type. This may be
316
313
relaxed in future if file formats support other types.
317
314
"""
318
315
function 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})
326
317
dest = MOI. FileFormats. Model (; filename)
327
318
model = MOI. Bridges. full_bridge_optimizer (dest, T)
328
- MOI. copy_to (model, p . model)
319
+ MOI. copy_to (model, src . model)
329
320
MOI. write_to_file (dest, filename)
330
321
return
331
322
end
Original file line number Diff line number Diff line change @@ -922,8 +922,6 @@ function test_write_to_file()
922
922
p = minimize (logsumexp (x))
923
923
dir = mktempdir ()
924
924
filename = joinpath (dir, " test.mof.json" )
925
- @test_throws ArgumentError write_to_file (p, filename)
926
- solve! (p, SCS. Optimizer; silent_solver = true )
927
925
write_to_file (p, filename)
928
926
@test occursin (" ExponentialCone" , read (filename, String))
929
927
p_int = minimize (logsumexp (x); numeric_type = Int)
You can’t perform that action at this time.
0 commit comments