Hello,
I am trying to make the log constraints work with Gurobi.jl and JuMP.jl. However, I don’t seem to be able to successfully use the C call function. Anyone who has managed to use them?
I paste a simple example below.
Thanks!
using JuMP # used for mathematical programming
using Gurobi # solver
a = 0.2;
b = 0.5;
m = direct_model(Gurobi.Optimizer());
set_optimizer_attribute(m, "NonConvex", 2);
set_optimizer_attribute(m, "PreSolve", 0);
# define objects to solve for
@variable(m, costs >= 0.001, start = 1.0);
@variable(m, logCosts >= log(0.001));
# objective function:
@objective(m, Min, a * costs - b * logCosts);
# log constraint:
GRBaddgenconstrLog(m, "logCost", 1, 2, "");
optimize!(m);
This is the error I get:
ERROR: MethodError: no method matching unsafe_convert(::Type{Ptr{Nothing}}, ::Model)
Closest candidates are:
unsafe_convert(::Union{Type{Ptr{Nothing}}, Type{Ptr{Base.Libc.FILE}}}, ::Base.Libc.FILE) at libc.jl:94
unsafe_convert(::Type{Ptr{T}}, ::SubArray{T, N, P, var"#s79", L} where {var"#s79"<:Tuple{Vararg{Union{Int64, AbstractRange{Int64}}, N} where N}, L}) where {T, N, P} at subarray.jl:426
unsafe_convert(::Type{Ptr{T}}, ::SubArray{T, N, P, var"#s79", L} where {var"#s79"<:Tuple{Vararg{Union{Int64, AbstractRange{Int64}, Base.ReshapedArray{T, N, A, Tuple{}} where {T, N, A<:AbstractUnitRange}}, N} where N}, L}) where {T, N, P} at reshapedarray.jl:292
...
Stacktrace:
[1] GRBaddgenconstrLog(model::Model, name::String, xvar::Int64, yvar::Int64, options::String)
@ Gurobi ~/.julia/packages/Gurobi/xvBAY/src/gen100/libgrb_api.jl:528