On Friday, September 25, 2015 at 1:12:57 PM UTC, NV wrote: > > Hi, > I am new to Julia and would like to run a set of operations repeatedly > for a finite set of time. I tried to implement the following code: > > using JuMP, Ipopt > Truck = Model(solver=IpoptSolver(print_level=0)) > #Initial Values > gear_0 = 1 > v_0 = 20 > N_0 = 600 > #Constants: > i_f = 3.27 > eta_f = 0.95 > eta_t = 0.95 > r_w = 0.52 > gear = 1 > i = [11.27 9.14 7.17 5.81 4.62 3.75 3.01 2.44 1.91 1.55 1.23 1] > #Discretization > n = 500 > @defVar(Truck,Δt≥0,start = 1/n) > @defNLExpr(t_f,Δt*n) > @defVar(Truck,600<=N[0:n]<=2500) > @defVar(Truck,1<=gear[0:n]<=12) > @defVar(Truck,i_t[0:n]) > @addConstraint(Truck,N[0]==N_0) > @addConstraint(Truck,gear[0]==gear_0) > @addConstraint(Truck,i_t[0]==i[1]) > @defNLExpr(N[j=0:n],(30*i_t[j]*i_f)/(pi*r_w)) > for j in 1:n > if(gear[j]==1) >
I counted this as line 25, but that would be "wrong".. I tried to look into this* but note there is another mailing-list: https://groups.google.com/forum/#!forum/julia-opt * I can't clearly see that gear is an array.. I assume JuMP is doing some magic. Or Ipopt. for me I got some error on a missing Fortran compiler trying to install that.. so I get: ERROR: Ipopt not properly installed. Please run Pkg.build("Ipopt") in error at error.jl:21 in include at ./boot.jl:245 in include_from_node1 at ./loading.jl:128 in reload_path at loading.jl:152 in _require at loading.jl:67 in require at loading.jl:51 while loading /home/palli/.julia/v0.3/Ipopt/src/Ipopt.jl, in expression starting on line 6 Then I get some subsequent errors and one in "line 3", that tells me, that you should count line 25 from the for-loop. Everything in Julia is an expression, including the for loop (what you "last entered"). Then this seems to be your error line: if(N[j]>=1503) I'm used to lines counting from the top, but I also use functions (usually recommended). julia> gear 1 julia> gear[1] 1 julia> gear[2] ERROR: BoundsError() in getindex at number.jl:15 julia> n 500 -- Palli.
