julia-jump

Error with JuMP and Ipopt

廉价感情. 提交于 2019-12-24 10:31:24
问题 I am trying to use JumP and Ipopt under Julia v0.7.0. When I try to construct a model: julia> m = Model(solver=IpoptSolver()) I get the following error message: Feasibility problem with: * 0 linear constraints * 0 variables Solver is Error showing value of type Model: ERROR: BoundsError: attempt to access 1-element Array{SubString{String},1} at index [2] I am using the following versions of the packages: Ipopt v0.4.0 JuMP v0.18.2 Any ideas? Thanks! 回答1: JuMP v0.18.2 does not support Julia v0

How to do “for all” in sum notation in Julia/JuMP

半世苍凉 提交于 2019-12-23 12:28:35
问题 I am trying to add constraints to a linear optimization problem in Julia using JuMP. I am using the sum{} function however, I am having trouble with some of the constraints. Does anyone know how to write "for all" in JuMP (the upside down A)? Here is the code I have so far: using JuMP m = Model() c= [3 5 2 ; 4 3 5 ; 4 5 3 ; 5 4 3 ; 3 5 4] @variable(m, x[i=1:5,j=1:3] >= 0) @objective(m,Min,sum{c[i,j]*x[i,j],i=1:5,j=1:3}) for i=1:5 @constraint(m, sum{x[i,j],i,j=1:3} <= 480) end What I am trying

Maximise Sharpe ratio subject to contraints in Julia

北慕城南 提交于 2019-12-13 00:07:58
问题 I want to maximize the value of q[1](Sharpe Ratio), subject to following constraints in julia. Value elements of W is positive. ( W[i] >0 ) Sum of values of W is 1. ( sum(W[1:5]) == 1 ) function getSharpeRatio(W,ex_mu,S) q = ( W'*ex_mu ) / sqrt((W'*S*W)) return q[1] end For Reference :: W is (5X1) vector,ex_mu is (5x1) vector and S is (5x5) matrix. I found out two julia libraries to use JuMP and Optim.jl , but not able to translate the function getSharpeRatio as required by the libraries.

Quadratically constrained MIQP with julia and gurobi

偶尔善良 提交于 2019-12-11 04:57:23
问题 This is an attempt to answer the following question: https://matheducators.stackexchange.com/questions/11757/small-data-sets-with-integral-sample-standard-deviations So the intent of the following code is to find examples of small datasets with integer standard deviation. That can be formulated as a quadratically constrained mixed integer quadratic program, so I try to use Gurobin from Julia. Following is my code: using JuMP using Gurobi m = Model(solver = GurobiSolver() ) @variable(m, 0<= x

Gurobi reports unbounded model despite mathematical impossibility

廉价感情. 提交于 2019-12-11 04:15:44
问题 I'm using Julia's wonderful JuMP package to solve a linear program with Gurobi 6.0.4 as a solver. The objective function is a sum of decision variables, clearly defined as nonnegative, and the problem requires it to be minimized. For some reason, Gurobi thinks the model is unbounded. Here is the definition of the variables and the objective: @defVar(model, delta2[i=irange,j=pair[i]] >= 0) @setObjective(model, Min, sum{delta2[i,j], i=irange, j=pair[i]}) Strange observation #1: although this is

How can I make strict constraint in the Julia JuMP software?

北城以北 提交于 2019-12-08 09:06:46
问题 How can I make strict constraint in Julia JuMP?(https://github.com/JuliaOpt/JuMP.jl). For example: 2x-3y>15 回答1: It seems that none of the solvers accept strict constraints because of the way they solve the problem and to avoid some issues! Here is what Gurobi says: Gurobi supports a limited set of comparators. Specifically, you can constrain an expression to be less-than-or-equal, greater-than-or-equal, or equal another. We do not support strict less-than, strict greater-than, or not-equal

Julia+JuMP: variable number of arguments to function

久未见 提交于 2019-12-07 09:22:54
问题 I'm trying to use JuMP to solve a non-linear problem, where the number of variables are decided by the user - that is, not known at compile time. To accomplish this, the @NLobjective line looks like this: @eval @JuMP.NLobjective(m, Min, $(Expr(:call, :myf, [Expr(:ref, :x, i) for i=1:n]...))) Where, for instance, if n=3 , the compiler interprets the line as identical to: @JuMP.NLobjective(m, Min, myf(x[1], x[2], x[3])) The issue is that @eval works only in the global scope, and when contained

Julia+JuMP: variable number of arguments to function

℡╲_俬逩灬. 提交于 2019-12-05 13:33:44
I'm trying to use JuMP to solve a non-linear problem, where the number of variables are decided by the user - that is, not known at compile time. To accomplish this, the @NLobjective line looks like this: @eval @JuMP.NLobjective(m, Min, $(Expr(:call, :myf, [Expr(:ref, :x, i) for i=1:n]...))) Where, for instance, if n=3 , the compiler interprets the line as identical to: @JuMP.NLobjective(m, Min, myf(x[1], x[2], x[3])) The issue is that @eval works only in the global scope, and when contained in a function, an error is thrown. My question is: how can I accomplish this same functionality --