Hi!
I try to write up a minimization problem with 5+131 variables, a quadratic objective involving the last 131 variables and 131 constraints that involve a numerical integration using Gauss-Hermite nodes. The variables weight, hp, ac and price are 131-vectors of Float64.
using FastGaussQuadrature
using JuMP
using Ipopt
# Data
(e0, q0) = gausshermite(30)
weight = ones(131)
hp = ones(131)
ac = ones(131)
price = ones(131)
# Model
m = Model(solver=IpoptSolver(print_level=1))
@variable(m, β[1:3], start = 0.0)
@variable(m, μy, start = -0.1)
@variable(m, σy >= 0, start = 0.1)
@variable(m, ξ[i=1:131])
@objective(m, Min, ξ' * ξ)
@NLexpression(m, integrand[i=1:131, k=1:30], exp(ξ[i] + weight[i] * β[1] + hp[i] * β[2] + ac[i] * β[3] - exp(-μy -sqrt(2) * σy * e0[k]) * price[i]) / (1 + sum((exp(ξ[j]) + weight[j] * β[1] + hp[j] * β[2] + ac[j] * β[3] - exp(-μy - sqrt(2) * σy * e0[k]) * price[j]) for j in 1:131)))
@constraint(m, integral_constraint[i=1:131], share[i] == dot(integrand[i, :], q0))
The constraint throws an MethodError: no method matching one(::Type{JuMP.NonlinearExpression})
I read the syntax notes couple of times, and I do not understand why I should not use the dot
in this expression, the notes just say you cannot use it inside nonlinear expressions.
My workaround is to make integrand
a variable (131*30 dimensional!), but when I solve my 16GBs memory fill up in a minute and it does not work.
@variable(m, integrand[1:131, 1:30])
@NLconstraint(m, integrandconst[i=1:131, k=1:30], integrand[i, k] == exp(ξ[i] + weight[i] * β[1] + hp[i] * β[2] + ac[i] * β[3] - exp(-μy -sqrt(2) * σy * e0[k]) * price[i]) / (1 + sum((exp(ξ[j]) + weight[j] * β[1] + hp[j] * β[2] + ac[j] * β[3] - exp(-μy - sqrt(2) * σy * e0[k]) * price[j]) for j in 1:131)))
Any advice?