We can learn from the print(model) (๐ ) that if a model has a variable which is not purely continuous (e.g. Integer/binary/semi~).
julia> model
A JuMP Model
โ solver: Gurobi
โ objective_sense: FEASIBILITY_SENSE
โ num_variables: 1
โ num_constraints: 1
โ โ JuMP.VariableRef in MOI.ZeroOne: 1 ๐
โ Names registered in the model
โ :x
Then, can I programmatically query this related property?
e.g. the provisional JuMP.is_continuous(model) as follows
What is the motivation for adding is_continuous? In what settings is it useful?
JuMP doesnt have strict categories like โthis model is linearโ.
You could loop over list_of_constraint_types(model) to decide what type of model you have.
You could do
function is_linear(model)
if objective_sense(model) != FEASIBILITY_SENSE
F = objective_function_type(model)
# But what about Vector{AffExpr}?
if !(F <: VariableRef || F <: AffExpr)
return false
end
end
for (F, S) in list_of_constraint_types(model)
# But what about F = Vector{AffExpr}? Some sets are linear...
if !(F <: VariableRef || F <: AffExpr)
return false
end
end
return true
end
and
function is_continuous(model)
for (F, S) in list_of_constraint_types(model)
if S <: Union{
MOI.ZeroOne,
MOI.Integer,
MOI.Semiinteger,
MOI.Semicontinuous,
# What about MOI.SOS1, MOI.SOS2, MOI.Indicator, MOI.Complements,
# MOI.AllDifferent, MOI.BinPacking... there are others
}
return false
end
end
return true
end
An issue is that the concept of โis linearโ and โis continuousโ is not perfectly defined.
We could make it much easier, i.e.,
is there a method to associate a String to a model? (e.g. a so-called name?)
model = JuMP.Model()
JuMP.write_note(model, "mip_master"::String)
# many lines ...
my_note = JuMP.read_note(model)
occursin("mip", my_note) && print("I know it is a mip!")
Currently do we already have these two functions?
What is meant by โSome sets are linearโฆโ? Please give me a link? I wonder what sets are linear.
JuMP already has set_name for ConstraintRef and GenericVariableRef, what about also for Model (alias for JuMP.GenericModel{Float64}).
And then use JuMP.get_name(model) to fetch it (the get_name do not exist though). These 2 API should be not very strenuous?
In this case users will feel more convenience, e.g. memorizing attributes of different models they have created.
VectorOfVariables or VectorAffineFunction in Zeros, Nonpositives, Nonnegatives, and Hyperrectangle, depending on how you wanted to define things, perhaps also NormOneCone and NormInfinityCone, and then if those, NormCone, but only if p is 1.0 or Inf.
JuMP does not have a neat standard form like you might find in a textbook. Questions like is_linear are surprisingly nuanced.