Supported variables, constraints and objectives

This solver is in a pre-release phase right now and not a lot of constraints or objectives are supported. If you want to be up to date you might want to check this page every couple of months.

You can also watch the project to be informed of every change but this might spam you ;)

Supported objectives

Currently the only objective supported is the linear objective i.e

@objective(m, Min, 2x+3y)

Supported variables

All variables need to be bounded and discrete.

@variable(m, x) # does not work
@variable(m, x, Int) # doesn't work because it isn't bounded
@variable(m, x, Bin) # does work because it is discrete and bounded
@variable(m, 1 <= x, Int) # doesn't work because it isn't bounded from above
@variable(m, 1 <= x <= 7, Int) # does work

Additionally you can specify a set of allowed integers:

@variable(m, x, CS.Integers([1,3,5,7]))

Anonymous variables

Besides the named way of defining variables it's also possible to have anonymous variables as provided by JuMP.jl.

This can be useful when one needs to create temporary variables for reformulations of the problem. The values of these variables can be accessed by the name as well as named variables under the condition that the given name is not overwritten and available in the current scope. Anonymous variables are mostly needed to avoid the problem of needing a new name for each temporary variables.

An example:

function does_equal(x, y)
    model = owner_model(x)
    b = @variable(model, binary=true)
    @constraint(model, b := { x == y })
    return b
end
model = Model(optimizer_with_attributes(CS.Optimizer))
@variable(model, x[1:4], CS.Integers([0,2,3,4,5]))
first_equal = does_equal(x[1], x[2])
@objective(model, Max, sum(x)+5*first_equal)
optimize!(model)
@show JuMP.value.(x)
@show JuMP.value(first_equal)

The general usage is described in the JuMP docs but the following gives an idea on how to use them for the most common use-cases in combination with ConstraintSolver.jl .

# create an anonymous array of 5 integer variables with the domain [0,2,3,4,5]
x = @variable(model, [1:5], variable_type=CS.Integers([0,2,3,4,5]))
# create a single anonymous binary variable 
b = @variable(model, binary=true)
# create a single anonymous integer variable **Important:** Needs bounds
y = @variable(model, integer=true, lower_bound=0, upper_bound=10)

Missing

  • Interval variables for scheduling

Supported constraints

The following list shows constraints that are implemented and those which are planned.

  • [X] Linear constraints
    • At the moment this is kind of partially supported as they are not really good at giving bounds yet (See better bound computation)
    • [X] ==
    • [X] <=
    • [X] >=
    • [X] !=
    • [X] <
    • [X] >
  • [X] All different
    • @constraint(m, [x,y,z] in CS.AllDifferent())
    • @constraint(m, [x,y+2,x+y] in CS.AllDifferent())
  • [X] TableSet constraint #130
    • also with VectorAffineFunction i.e [x,y+2,x+y] in CS.TableSet(...)
  • Indicator constraints #167
    • i.e @constraint(m, b => {x + y >= 12})
    • [X] for affine inner constraints
    • [X] for all types of inner constraints
    • [X] Allow && inside the inner constraint i.e @constraint(m, b => {x + y >= 12 && 2x + y <= 7})
    • [X] Allow || inside the inner constraint i.e @constraint(m, b => {x + y >= 12 || 2x + y <= 7})
    • [-] Have Indicator and Reified inside one another
      • this is only supported for simple cases i.e bridge support is missing
    • [ ] VectorAffineFunction in AllDifferentSet or TableSet
      • Please open an issue if needed for a problem. Probably not too hard to add
  • Reified constraints #171
    • i.e @constraint(m, b := {x + y >= 12})
    • [X] for everything that is supported by indicator constraints
  • Boolean constraints
    • i.e @constraint(m, x + y >= 12 || 2x + y <= 7)
    • allows binary variables without writing == 1 or == 0
      • one can write something like a || !b
      • Attention: Does not check whether a and b are actually binary variables
  • Element constraints
    • [X] 1D array with constant values
      • i.e T = [12,87,42,1337] T[y] == z with y and z being variables #213
    • [ ] 2D array with constant values
      • where T is an array
    • [ ] 1D array with variables
      • where T is a vector of variables
  • [ ] Scheduling constraints
  • [ ] Cycle constraints

If I miss something which would be helpful for your needs please open an issue.

Additionally

  • [ ] adding new constraints after optimize! got called #72