-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support "nonscalar" variables (like complex numbers, intervals, sequences of intervals)? #1253
Comments
Here is another case where it would be useful to know the type of the variable. |
After giving it some thoughts, here is what I propose to implement for this, in two parts. Variable traitsA system similar to Holy traits for variables, so that you can easily query if a variable is binary or has bounds, for instance. That would mean a series of functions like Apart from moving some code from JuMP to MOI, I don't think that further changes are really required. It's nothing fundamental, it's more about giving easier access to some information (so that people can decide to perform more type checks or interesting dispatch later on). In the near future, this could be extended to support DCP in JuMP, with vexity, monotonicity, sign. Composite variable indicesA new notion: composite variables (or any other name), More technically, I would implement this with an abstract mutable struct ComplexVariableIndex <: CompositeVariableIndex
re::VariableIndex
im::VariableIndex
end
mutable struct IntervalVariableIndex<: CompositeVariableIndex
start_of::VariableIndex
end_of::VariableIndex
end
mutable struct GraphVariableIndex<: CompositeVariableIndex
edges::Dict{Tuple{Int, Int}, VariableIndex}
function GraphVariableIndex(n_vertices::Int)
return new(Dict((i, j) => new_bin_var for i in 1:n_vertices, j in 1:n_vertices if i != j))
end
end Syntactically, from the point of view of JuMP, this could just be some extension of the Then, constraints could be written in a specific way with these new compound types. You could define affine expressions based on complex variables or intervals: In a way, it would have been more interesting to have Do you have any opinion on this? Shall I open PRs to discuss more concretely? |
Is there any reason this needs to happen in MOI directly? My near-term goal is jump-dev/JuMP.jl#2564, so I'm wary of adding lots of new functionality before we get 1.0 finished. Functions like function is_binary(model::MOI.ModelLike, x::MOI.VariableIndex)::Bool
return MOI.is_valid(
model,
MOI.ConstraintIndex{MOI.SingleVariable,MOI.ZeroOne}(x.value),
)
end I can't find the issue, but I suggested something like @variable(model, x, ConstraintInterval) created |
Indeed, there is no need to include it in MOI right away, but I prefer to discuss the ideas before doing anything, in case I missed something or if there is a better implementation. Thanks for your input! By the way, I believe this belongs to https://github.com/dourouc05/ConstraintProgrammingExtensions.jl for now? Or would it be better to have another package to ease inclusion in a future MOI release? |
Yeah keep adding things to ConstraintProgrammingExtensions for now. Want to give a talk at JuMP-dev about ConstraintProgrammingExtensions? It would be good to generate some wider discussion. |
I'll submit an abstract for the workshop for sure! I suppose that a standard talk would be the best length for such a topic? |
Yes, I would say you would need at least the length of a standard talk |
OK, thanks a lot! |
We've made no progress on this, and I don't think we're going to anytime soon. To some extent, we have support for complex numbers, but it still requires adding two real variables. I think these ideas are perhaps best explored in a JuMP extension package. |
A good example for this would be local solver's I haven't worked through the details, but perhaps |
I wonder if we should close this issue as out-of-scope. Supporting anything other than The most promising thing from the title is complex numbers. But we don't have any solvers at the MOI level requiring complex numbers, and we've shown that it can work at the JuMP level. |
Yes, I'm unsure that we need it, we've also been able to have bridge act differently depending on properties of a variable by checking whether they are constrained to belong to some set in |
To clarify, the closing of this: I talked to @dourouc05 yesterday, and we agreed that adding something other than The current suggestion for "interval" variables would be something like |
For now, MOI only supports scalar variables, i.e. real numbers (or subsets thereof). Complex numbers can be implemented as a pair of real numbers, as in https://github.com/jump-dev/ComplexOptInterface.jl. For constraint programming, I would need to represent intervals (i.e. a pair of integer values: the beginning and the end of the interval) and sequences of intervals (defined based on a series of intervals), but also graphs. This kind of needs spans several engines:
How could this kind of variables fit into MOI? (Or an extension to MOI.) Typical functions cannot be applied on this kind of object: two intervals cannot really be summed up, or be greater than some constant, for instance.
Maybe renaming SingleVariable as SingleScalarVariable/SingleRealVariable (and so on for the other related objects)? This would leave space for something like SingleIntervalVariable, SingleSequenceVariable (and vectors), etc., but also SingleComplexVariable.
In a way, it could also solve some problems with
supports_constraint
: many CP constraints only make sense for integer variables (e.g., an array index), others are generalisable but are not always implemented as such (like counting values equal to something). With a SingleIntegerVariable,supports_constraint
could directly check for the type of variables.The text was updated successfully, but these errors were encountered: