You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
using DisjunctiveProgramming
import HiGHS
# example input to test it with
input =rand(100, 6) .*collect(1:6)'# objective functionfunctionobjective(chosen::AbstractVector{Int})
# given a vector of integers (columns to select)# return a real number. Not possible to write down analytic expression,# this is just an example
sums = [sum(input[:, i]) for i in chosen]
returnmean(sums)
end# start the model
model =GDPModel(HiGHS.Optimizer)
D =size(input, 2)
# Make as many logical variables as columns@variable(model, I[1:D], Logical)
# we add a constrain that at most Fmax indicators are true
Fmax =3@constraint(model, I inAtMost(Fmax))
# goal: find indices, at most Fmax, where `objective`# of these indices is maximized# however, I have the same problem, I don't know how to extract# an integer from `LogicalVariableRef{Model}` inside the# `objective` function@objective(model, Max, objective(I))
# I would hope that this worksoptimize!(model, gdp_method =BigM(100, false))
print(model)
my code errors in @objective(model, Max, objective(I)) with
ERROR: MethodError: no method matching objective(::Vector{LogicalVariableRef{Model}})
Which is to be expected. I am facing the same issue as the one I posted in the aforementioned discourse thread.
The question therefore is, is it possible via DisjunctiveProgramming.jl and the usage of some disjunctions, to achieve this: optimize the selection of which columns of a matrix to choose (i.e., a vector of integers), so that when using these specific columns to compute a real number, this real number is maximized?
The text was updated successfully, but these errors were encountered:
Unfortunately no. Your objective function must be an algebraic expression of your decision variables. It has the same limitations as standard mathematical optimization.
Hi there,
I just discovered this package and it re-ignited my hopes of solving https://discourse.julialang.org/t/using-a-jump-bin-vector-to-index-an-array-checkbounds-fails-with-type-variableref/102674 via JuMP.
I have the following MWE:
my code errors in
@objective(model, Max, objective(I))
withWhich is to be expected. I am facing the same issue as the one I posted in the aforementioned discourse thread.
The question therefore is, is it possible via DisjunctiveProgramming.jl and the usage of some disjunctions, to achieve this: optimize the selection of which columns of a matrix to choose (i.e., a vector of integers), so that when using these specific columns to compute a real number, this real number is maximized?
The text was updated successfully, but these errors were encountered: