I have functions: portfoliomean(weights; rmean = r_mean) = sum(weights .* rmean')…
Jump to turn (9)
- 1I have functions: portfoliomean(weights; rmean = rmean) = sum(weights . rmean')
- 2Unrecognized function "portfoliovar" used in nonlinear expression. You must regi
- 3Unable to register the function :portfoliomean1. Common reasons for this include
- 4Please ad 1 to the name of protfoliomean and portfoliovar functions and update t
- 5To those functions: function portfoliomean1(model, weights::Real…; rmean = rmean
- 6Whater you are doing is wrong and goes in wrong direction, lets come back to ini
- 7No method matching mean.
- 8UndefVarError: quadform not defined
- 9There is no such thing as quadform
- User
I have functions: portfolio_mean(weights; r_mean = r_mean) = sum(weights .* r_mean') portfolio_var(weights; covar = covar) = weights'covarweights and I want to optimize them like that: function opt_portfolio_both(rates_of_return, rmin,var_max) portfolio = Model(Ipopt.Optimizer) set_silent(portfolio) @variable(portfolio, x[1:size(rates_of_return)[2]] >= 0) @objective(portfolio, Max, (portfolio_mean(x)/portfolio_var(x))) @constraint(portfolio, sum(x) == 1) @constraint(portfolio, portfolio_mean(x) >= r_min) @constraint(portfolio, portfolio_var(x) <= var_max); optimize!(portfolio) objective_value(portfolio) weights_opt = value.(x); return weights_opt end in Julia, but when I try to run it I get error: /(::Int64,::QuadExpr) is not defined. Are you trying to build a nonlinear problem? Make sure you use @NLconstraint/@NLobjective. If you are using an
@NLmacro and you encountered this error message, it is because you are attempting to use another unsupported function which calls this method internally.Stacktrace: [1] /(#unused#::Int64, #unused#::QuadExpr) @ JuMP C:\Users\Użytkownik.julia\packages\JuMP\AKvOr\src\operators.jl:511 [2] macro expansion @ C:\Users\Użytkownik.julia\packages\MutableArithmetics\h0wjj\src\rewrite.jl:322 [inlined] [3] macro expansion @ C:\Users\Użytkownik.julia\packages\JuMP\AKvOr\src\macros.jl:1501 [inlined] [4] opt_portfolio_both(rates_of_return::DataFrame, rmin::Float64, var_max::Float64) @ Main .\In[43]:5 [5] top-level scope @ In[44]:1