What is the correct way to use unset_binary when working with DenisAxisArrays? For example, assume that indices of the vector x, are x[A1] and x[A2] and I want to relax x[A2]. Using the above code unset_binary(x[A2]) throws an error that x[A2] is not defined.
No, it is a single index. I have given a more detailed example below:
using JuMP, Cbc, DataFrames
function get_data()
ID_t = collect(1:15)
ID = Vector{String}(undef,15)
for i in 1:15
ID[i]="A".*string(ID_t[i])
end
PRICE = rand(10.0:100.0,15)
Data = DataFrame(ID = ID,PRICE = PRICE)
return Data
end
Data = get_data()
price = Data.PRICE
model = Model(Cbc.Optimizer)
@variable(model, x[Data.ID],Bin)
@objective(model,Min,sum(price*x[id] for (id, price) in zip(Data.ID, Data.PRICE)))