Open dvnoble opened 9 months ago
The way to define the penalty factor for a constraint is through the ToQUBO.Attributes.ConstraintEncodingPenaltyHint()
atttribute, as in
julia> using JuMP, QUBO
julia> model = Model(ToQUBO.Optimizer)
A JuMP Model
├ solver: Virtual QUBO Model
├ objective_sense: FEASIBILITY_SENSE
├ num_variables: 0
├ num_constraints: 0
└ Names registered in the model: none
julia> @variable(model, 0 <= x[1:3] <= 10)
3-element Vector{VariableRef}:
x[1]
x[2]
x[3]
julia> @constraint(model, c, x[1] + x[2] + x[3] <= 10)
c : x[1] + x[2] + x[3] ≤ 10
julia> set_attribute(c, ToQUBO.Attributes.ConstraintEncodingPenaltyHint(), 20.0)
julia> optimize!(model)
Hello!
I'd like to know how can I add a constraint and set its penalty at the same time. Which is the best way of doing that? Can I do it in batches (adding many constraints and their respective penalties in a single command)?
I haven't found an answer in the documentation, sorry if I missed something.
Thanks