@@ -200,18 +200,18 @@ Parameter:
200200"""
201201function build_terminal_cost! (model:: SPModel , problem:: JuMP.Model , Vt:: PolyhedralFunction )
202202 # if shape is PolyhedralFunction, build terminal cost with it:
203- alpha = getVar (problem, :alpha )
204- x = getVar (problem, :x )
205- u = getVar (problem, :u )
206- w = getVar (problem, :w )
203+ alpha = getvariable (problem, :alpha )
204+ x = getvariable (problem, :x )
205+ u = getvariable (problem, :u )
206+ w = getvariable (problem, :w )
207207 t = model. stageNumber - 1
208208 if isa (Vt, PolyhedralFunction)
209209 for i in 1 : Vt. numCuts
210210 lambda = vec (Vt. lambdas[i, :])
211- @addConstraint (problem, Vt. betas[i] + dot (lambda, model. dynamics (t, x, u, w)) <= alpha)
211+ @constraint (problem, Vt. betas[i] + dot (lambda, model. dynamics (t, x, u, w)) <= alpha)
212212 end
213213 else
214- @addConstraint (problem, alpha >= 0 )
214+ @constraint (problem, alpha >= 0 )
215215 end
216216end
217217
@@ -247,26 +247,26 @@ function build_models(model::SPModel, param::SDDPparameters)
247247 nu = model. dimControls
248248 nw = model. dimNoises
249249
250- @defVar (m, model. xlim[i][1 ] <= x[i= 1 : nx] <= model. xlim[i][2 ])
251- @defVar (m, model. ulim[i][1 ] <= u[i= 1 : nu] <= model. ulim[i][2 ])
252- @defVar (m, model. xlim[i][1 ] <= xf[i= 1 : nx]<= model. xlim[i][2 ])
253- @defVar (m, alpha)
250+ @variable (m, model. xlim[i][1 ] <= x[i= 1 : nx] <= model. xlim[i][2 ])
251+ @variable (m, model. ulim[i][1 ] <= u[i= 1 : nu] <= model. ulim[i][2 ])
252+ @variable (m, model. xlim[i][1 ] <= xf[i= 1 : nx]<= model. xlim[i][2 ])
253+ @variable (m, alpha)
254254
255- @defVar (m, w[1 : nw] == 0 )
256- m. ext[:cons ] = @addConstraint (m, state_constraint, x .== 0 )
255+ @variable (m, w[1 : nw] == 0 )
256+ m. ext[:cons ] = @constraint (m, state_constraint, x .== 0 )
257257
258- @addConstraint (m, xf .== model. dynamics (t, x, u, w))
258+ @constraint (m, xf .== model. dynamics (t, x, u, w))
259259
260260 if typeof (model) == LinearDynamicLinearCostSPmodel
261- @setObjective (m, Min, model. costFunctions (t, x, u, w) + alpha)
261+ @objective (m, Min, model. costFunctions (t, x, u, w) + alpha)
262262
263263 elseif typeof (model) == PiecewiseLinearCostSPmodel
264- @defVar (m, cost)
264+ @variable (m, cost)
265265
266266 for i in 1 : length (model. costFunctions)
267- @addConstraint (m, cost >= model. costFunctions[i](t, x, u, w))
267+ @constraint (m, cost >= model. costFunctions[i](t, x, u, w))
268268 end
269- @setObjective (m, Min, cost + alpha)
269+ @objective (m, Min, cost + alpha)
270270 end
271271
272272 models[t] = m
@@ -398,16 +398,16 @@ function get_bellman_value(model::SPModel, param::SDDPparameters,
398398 t:: Int64 , Vt:: PolyhedralFunction , xt:: Vector{Float64} )
399399
400400 m = Model (solver= param. solver)
401- @defVar (m, alpha)
401+ @variable (m, alpha)
402402
403403 for i in 1 : Vt. numCuts
404404 lambda = vec (Vt. lambdas[i, :])
405- @addConstraint (m, Vt. betas[i] + dot (lambda, xt) <= alpha)
405+ @constraint (m, Vt. betas[i] + dot (lambda, xt) <= alpha)
406406 end
407407
408- @setObjective (m, Min, alpha)
408+ @objective (m, Min, alpha)
409409 solve (m)
410- return getValue (alpha)
410+ return getvalue (alpha)
411411end
412412
413413
@@ -484,14 +484,14 @@ Parameters:
484484
485485"""
486486function add_cuts_to_model! (model:: SPModel , t:: Int64 , problem:: JuMP.Model , V:: PolyhedralFunction )
487- alpha = getVar (problem, :alpha )
488- x = getVar (problem, :x )
489- u = getVar (problem, :u )
490- w = getVar (problem, :w )
487+ alpha = getvariable (problem, :alpha )
488+ x = getvariable (problem, :x )
489+ u = getvariable (problem, :u )
490+ w = getvariable (problem, :w )
491491
492492 for i in 1 : V. numCuts
493493 lambda = vec (V. lambdas[i, :])
494- @addConstraint (problem, V. betas[i] + dot (lambda, model. dynamics (t, x, u, w)) <= alpha)
494+ @constraint (problem, V. betas[i] + dot (lambda, model. dynamics (t, x, u, w)) <= alpha)
495495 end
496496end
497497
@@ -557,19 +557,19 @@ Return:
557557function is_cut_relevant (model:: SPModel , k:: Int , Vt:: PolyhedralFunction , solver)
558558
559559 m = Model (solver= solver)
560- @defVar (m, alpha)
561- @defVar (m, model. xlim[i][1 ] <= x[i= 1 : model. dimStates] <= model. xlim[i][2 ])
560+ @variable (m, alpha)
561+ @variable (m, model. xlim[i][1 ] <= x[i= 1 : model. dimStates] <= model. xlim[i][2 ])
562562
563563 for i in 1 : Vt. numCuts
564564 if i!= k
565565 lambda = vec (Vt. lambdas[i, :])
566- @addConstraint (m, Vt. betas[i] + dot (lambda, x) <= alpha)
566+ @constraint (m, Vt. betas[i] + dot (lambda, x) <= alpha)
567567 end
568568 end
569569
570570 λ_k = vec (Vt. lambdas[k, :])
571- @setObjective (m, Min, alpha - dot (λ_k, x) - Vt. betas[k])
571+ @objective (m, Min, alpha - dot (λ_k, x) - Vt. betas[k])
572572 solve (m)
573- return getObjectiveValue (m) < 0.
573+ return getobjectivevalue (m) < 0.
574574end
575575
0 commit comments