# Function getindex does not accept keyword arguments

**URL:** <https://discourse.julialang.org/t/function-getindex-does-not-accept-keyword-arguments/24564>\
**Category:** Optimization (Mathematical)\
**Tags:** jump\
**Created:** [May 24, 2019, 12:26pm UTC](https://discourse.julialang.org/t/function-getindex-does-not-accept-keyword-arguments/24564 "2019-05-24T12:26:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Octarosu](https://avatars.discourse-cdn.com/v4/letter/o/f07891/32.png) [@Octarosu](https://discourse.julialang.org/u/Octarosu)\
**Post date:** [May 24, 2019, 12:26pm UTC](https://discourse.julialang.org/t/function-getindex-does-not-accept-keyword-arguments/24564/1 "2019-05-24T12:26:53Z")

</div>

Hello, I implemented this function for economic dispatch

function solve\_ed(g\_max, g\_min, c\_g, c\_w, d, w\_f)  
#Define the economic dispatch (ED) model  
ed=Model()

```
# Define decision variables    
@defVar(ed, 0 <= g[i=1:2] <= g_max[i]) # power output of generators
@defVar(ed, 0 <= w <= w_f ) # wind power injection

# Define the objective function
@objective(ed,Min,sum{c_g[i] * g[i],i=1:2}+c_w * w)

# Define the constraint on the maximum and minimum power output of each generator
for i in 1:2
    @constraint(ed, g[i] <= g_max[i]) #maximum
    @constraint(ed, g[i] >= g_min[i]) #minimum
end

# Define the constraint on the wind power injection
@constraint(ed, w <= w_f)

# Define the power balance constraint
@constraint(ed, sum{g[i], i=1:2} + w == d)

# Solve statement
solve(ed)

# return the optimal value of the objective function and its minimizers
return getValue(g), getValue(w), w_f-getValue(w), getObjectiveValue(ed)

```

end

# Solve the economic dispatch problem

(g\_opt,w\_opt,ws\_opt,obj)=solve\_ed(g\_max, g\_min, c\_g, c\_w, d, w\_f);

and i’m getting this error :  
function getindex does not accept keyword arguments

Can anybody help me with this issue?

---

<div class="post-metadata">

**Author:** ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)\
**Post date:** [May 24, 2019, 1:21pm UTC](https://discourse.julialang.org/t/function-getindex-does-not-accept-keyword-arguments/24564/2 "2019-05-24T13:21:05Z")

</div>

It looks like you are using a very old version of JuMP, and perhaps also quite an old version of Julia. Can you tell us what version of Julia and JuMP this is?
