Closed chriscoey closed 1 year ago
We could add write support, but read support is tricky because existing file formats do not have the concept of a value type.
How would MOF know the difference between ScalarAffineFunction{Int64}
and ScalarAffineFunction{Float64}
if the coefficient was an integer?
Ditto for LP/MPS/CBF/etc.
We could add a new field like value_type
, but this would need some careful thought. MOF is meant to be language agnostic, and it isn't obvious how you could generalize to arbitrary value types.
"function": {
"type": "ScalarAffineFunction",
"terms": [],
"constant": 0,
"value_type": "Int64",
}
I didn't really think about the read case - actually all I need personally is the write case.
If it was necessary to support reading, then maybe the type T should just be given once in the model, and numbers in the JSON should all be converted to that type when read (if possible, else error). But yeah I don't really need this.
What's the point of write if you can't read?
We return model files to the user so they can inspect them manually 😆
MOF files aren't that easy to inspect manually. Why not just pipe them the output of print(model)
?
I have a model parametrized by Int, and I cannot write it using the MOF JSON writer - I get:
so it would be great to generalize the MOF (and other file formats!) writers/readers. cc @odow