@@ -349,84 +349,84 @@ function setconstraint!(
349349 nϵ, nw, nc = mpc. nϵ, con. nw, con. nc
350350 notSolvedYet = (JuMP. termination_status (optim) == JuMP. OPTIMIZE_NOT_CALLED)
351351 if isnothing (Umin) && ! isnothing (umin)
352- size (umin) == (nu,) || throw (ArgumentError (" umin size must be $((nu,)) " ))
352+ size (umin) == (nu,) || throw (DimensionMismatch (" umin size must be $((nu,)) " ))
353353 for i = 1 : nu* Hp
354354 con. U0min[i] = umin[(i- 1 ) % nu + 1 ] - mpc. Uop[i]
355355 end
356356 elseif ! isnothing (Umin)
357- size (Umin) == (nu* Hp,) || throw (ArgumentError (" Umin size must be $((nu* Hp,)) " ))
357+ size (Umin) == (nu* Hp,) || throw (DimensionMismatch (" Umin size must be $((nu* Hp,)) " ))
358358 con. U0min .= Umin .- mpc. Uop
359359 end
360360 if isnothing (Umax) && ! isnothing (umax)
361- size (umax) == (nu,) || throw (ArgumentError (" umax size must be $((nu,)) " ))
361+ size (umax) == (nu,) || throw (DimensionMismatch (" umax size must be $((nu,)) " ))
362362 for i = 1 : nu* Hp
363363 con. U0max[i] = umax[(i- 1 ) % nu + 1 ] - mpc. Uop[i]
364364 end
365365 elseif ! isnothing (Umax)
366- size (Umax) == (nu* Hp,) || throw (ArgumentError (" Umax size must be $((nu* Hp,)) " ))
366+ size (Umax) == (nu* Hp,) || throw (DimensionMismatch (" Umax size must be $((nu* Hp,)) " ))
367367 con. U0max .= Umax .- mpc. Uop
368368 end
369369 if isnothing (ΔUmin) && ! isnothing (Δumin)
370- size (Δumin) == (nu,) || throw (ArgumentError (" Δumin size must be $((nu,)) " ))
370+ size (Δumin) == (nu,) || throw (DimensionMismatch (" Δumin size must be $((nu,)) " ))
371371 for i = 1 : nu* Hc
372372 con. ΔŨmin[i] = Δumin[(i- 1 ) % nu + 1 ]
373373 end
374374 elseif ! isnothing (ΔUmin)
375- size (ΔUmin) == (nu* Hc,) || throw (ArgumentError (" ΔUmin size must be $((nu* Hc,)) " ))
375+ size (ΔUmin) == (nu* Hc,) || throw (DimensionMismatch (" ΔUmin size must be $((nu* Hc,)) " ))
376376 con. ΔŨmin[1 : nu* Hc] .= ΔUmin
377377 end
378378 if isnothing (ΔUmax) && ! isnothing (Δumax)
379- size (Δumax) == (nu,) || throw (ArgumentError (" Δumax size must be $((nu,)) " ))
379+ size (Δumax) == (nu,) || throw (DimensionMismatch (" Δumax size must be $((nu,)) " ))
380380 for i = 1 : nu* Hc
381381 con. ΔŨmax[i] = Δumax[(i- 1 ) % nu + 1 ]
382382 end
383383 elseif ! isnothing (ΔUmax)
384- size (ΔUmax) == (nu* Hc,) || throw (ArgumentError (" ΔUmax size must be $((nu* Hc,)) " ))
384+ size (ΔUmax) == (nu* Hc,) || throw (DimensionMismatch (" ΔUmax size must be $((nu* Hc,)) " ))
385385 con. ΔŨmax[1 : nu* Hc] .= ΔUmax
386386 end
387387 if isnothing (Ymin) && ! isnothing (ymin)
388- size (ymin) == (ny,) || throw (ArgumentError (" ymin size must be $((ny,)) " ))
388+ size (ymin) == (ny,) || throw (DimensionMismatch (" ymin size must be $((ny,)) " ))
389389 for i = 1 : ny* Hp
390390 con. Y0min[i] = ymin[(i- 1 ) % ny + 1 ] - mpc. Yop[i]
391391 end
392392 elseif ! isnothing (Ymin)
393- size (Ymin) == (ny* Hp,) || throw (ArgumentError (" Ymin size must be $((ny* Hp,)) " ))
393+ size (Ymin) == (ny* Hp,) || throw (DimensionMismatch (" Ymin size must be $((ny* Hp,)) " ))
394394 con. Y0min .= Ymin .- mpc. Yop
395395 end
396396 if isnothing (Ymax) && ! isnothing (ymax)
397- size (ymax) == (ny,) || throw (ArgumentError (" ymax size must be $((ny,)) " ))
397+ size (ymax) == (ny,) || throw (DimensionMismatch (" ymax size must be $((ny,)) " ))
398398 for i = 1 : ny* Hp
399399 con. Y0max[i] = ymax[(i- 1 ) % ny + 1 ] - mpc. Yop[i]
400400 end
401401 elseif ! isnothing (Ymax)
402- size (Ymax) == (ny* Hp,) || throw (ArgumentError (" Ymax size must be $((ny* Hp,)) " ))
402+ size (Ymax) == (ny* Hp,) || throw (DimensionMismatch (" Ymax size must be $((ny* Hp,)) " ))
403403 con. Y0max .= Ymax .- mpc. Yop
404404 end
405405
406406 if isnothing (Wmin) && ! isnothing (wmin)
407- size (wmin) == (nw,) || throw (ArgumentError (" wmin size must be $((nw,)) " ))
407+ size (wmin) == (nw,) || throw (DimensionMismatch (" wmin size must be $((nw,)) " ))
408408 for i = 1 : nw* (Hp+ 1 )
409409 con. Wmin[i] = wmin[(i- 1 ) % nw + 1 ]
410410 end
411411 elseif ! isnothing (Wmin)
412- size (Wmin) == (nw* (Hp+ 1 ),) || throw (ArgumentError (" Wmin size must be $((nw* (Hp+ 1 ),)) " ))
412+ size (Wmin) == (nw* (Hp+ 1 ),) || throw (DimensionMismatch (" Wmin size must be $((nw* (Hp+ 1 ),)) " ))
413413 con. Wmin .= Wmin
414414 end
415415 if isnothing (Wmax) && ! isnothing (wmax)
416- size (wmax) == (nw,) || throw (ArgumentError (" wmax size must be $((nw,)) " ))
416+ size (wmax) == (nw,) || throw (DimensionMismatch (" wmax size must be $((nw,)) " ))
417417 for i = 1 : nw* (Hp+ 1 )
418418 con. Wmax[i] = wmax[(i- 1 ) % nw + 1 ]
419419 end
420420 elseif ! isnothing (Wmax)
421- size (Wmax) == (nw* (Hp+ 1 ),) || throw (ArgumentError (" Wmax size must be $((nw* (Hp+ 1 ),)) " ))
421+ size (Wmax) == (nw* (Hp+ 1 ),) || throw (DimensionMismatch (" Wmax size must be $((nw* (Hp+ 1 ),)) " ))
422422 con. Wmax .= Wmax
423423 end
424424 if ! isnothing (x̂min)
425- size (x̂min) == (nx̂,) || throw (ArgumentError (" x̂min size must be $((nx̂,)) " ))
425+ size (x̂min) == (nx̂,) || throw (DimensionMismatch (" x̂min size must be $((nx̂,)) " ))
426426 con. x̂0min .= x̂min .- mpc. estim. x̂op
427427 end
428428 if ! isnothing (x̂max)
429- size (x̂max) == (nx̂,) || throw (ArgumentError (" x̂max size must be $((nx̂,)) " ))
429+ size (x̂max) == (nx̂,) || throw (DimensionMismatch (" x̂max size must be $((nx̂,)) " ))
430430 con. x̂0max .= x̂max .- mpc. estim. x̂op
431431 end
432432 allECRs = (
@@ -448,57 +448,57 @@ function setconstraint!(
448448 isnothing (C_wmin) && ! isnothing (c_wmin) && (C_wmin = repeat (c_wmin, Hp+ 1 ))
449449 isnothing (C_wmax) && ! isnothing (c_wmax) && (C_wmax = repeat (c_wmax, Hp+ 1 ))
450450 if ! isnothing (C_umin)
451- size (C_umin) == (nu* Hp,) || throw (ArgumentError (" C_umin size must be $((nu* Hp,)) " ))
451+ size (C_umin) == (nu* Hp,) || throw (DimensionMismatch (" C_umin size must be $((nu* Hp,)) " ))
452452 any (< (0 ), C_umin) && error (" C_umin weights should be non-negative" )
453453 con. A_Umin[:, end ] .= - C_umin
454454 end
455455 if ! isnothing (C_umax)
456- size (C_umax) == (nu* Hp,) || throw (ArgumentError (" C_umax size must be $((nu* Hp,)) " ))
456+ size (C_umax) == (nu* Hp,) || throw (DimensionMismatch (" C_umax size must be $((nu* Hp,)) " ))
457457 any (< (0 ), C_umax) && error (" C_umax weights should be non-negative" )
458458 con. A_Umax[:, end ] .= - C_umax
459459 end
460460 if ! isnothing (C_Δumin)
461- size (C_Δumin) == (nu* Hc,) || throw (ArgumentError (" C_Δumin size must be $((nu* Hc,)) " ))
461+ size (C_Δumin) == (nu* Hc,) || throw (DimensionMismatch (" C_Δumin size must be $((nu* Hc,)) " ))
462462 any (< (0 ), C_Δumin) && error (" C_Δumin weights should be non-negative" )
463463 con. A_ΔŨmin[1 : end - 1 , end ] .= - C_Δumin
464464 end
465465 if ! isnothing (C_Δumax)
466- size (C_Δumax) == (nu* Hc,) || throw (ArgumentError (" C_Δumax size must be $((nu* Hc,)) " ))
466+ size (C_Δumax) == (nu* Hc,) || throw (DimensionMismatch (" C_Δumax size must be $((nu* Hc,)) " ))
467467 any (< (0 ), C_Δumax) && error (" C_Δumax weights should be non-negative" )
468468 con. A_ΔŨmax[1 : end - 1 , end ] .= - C_Δumax
469469 end
470470 if ! isnothing (C_ymin)
471- size (C_ymin) == (ny* Hp,) || throw (ArgumentError (" C_ymin size must be $((ny* Hp,)) " ))
471+ size (C_ymin) == (ny* Hp,) || throw (DimensionMismatch (" C_ymin size must be $((ny* Hp,)) " ))
472472 any (< (0 ), C_ymin) && error (" C_ymin weights should be non-negative" )
473473 con. C_ymin .= C_ymin
474474 size (con. A_Ymin, 1 ) ≠ 0 && (con. A_Ymin[:, end ] .= - con. C_ymin) # for LinModel
475475 end
476476 if ! isnothing (C_ymax)
477- size (C_ymax) == (ny* Hp,) || throw (ArgumentError (" C_ymax size must be $((ny* Hp,)) " ))
477+ size (C_ymax) == (ny* Hp,) || throw (DimensionMismatch (" C_ymax size must be $((ny* Hp,)) " ))
478478 any (< (0 ), C_ymax) && error (" C_ymax weights should be non-negative" )
479479 con. C_ymax .= C_ymax
480480 size (con. A_Ymax, 1 ) ≠ 0 && (con. A_Ymax[:, end ] .= - con. C_ymax) # for LinModel
481481 end
482482 if ! isnothing (C_wmin)
483- size (C_wmin) == (nw* (Hp+ 1 ),) || throw (ArgumentError (" C_wmin size must be $((nw* (Hp+ 1 ),)) " ))
483+ size (C_wmin) == (nw* (Hp+ 1 ),) || throw (DimensionMismatch (" C_wmin size must be $((nw* (Hp+ 1 ),)) " ))
484484 any (< (0 ), C_wmin) && error (" C_wmin weights should be non-negative" )
485485 con. C_wmin .= C_wmin
486486 con. A_Wmin[:, end ] .= - C_wmin
487487 end
488488 if ! isnothing (C_wmax)
489- size (C_wmax) == (nw* (Hp+ 1 ),) || throw (ArgumentError (" C_wmax size must be $((nw* (Hp+ 1 ),)) " ))
489+ size (C_wmax) == (nw* (Hp+ 1 ),) || throw (DimensionMismatch (" C_wmax size must be $((nw* (Hp+ 1 ),)) " ))
490490 any (< (0 ), C_wmax) && error (" C_wmax weights should be non-negative" )
491491 con. C_wmax .= C_wmax
492492 con. A_Wmax[:, end ] .= - C_wmax
493493 end
494494 if ! isnothing (c_x̂min)
495- size (c_x̂min) == (nx̂,) || throw (ArgumentError (" c_x̂min size must be $((nx̂,)) " ))
495+ size (c_x̂min) == (nx̂,) || throw (DimensionMismatch (" c_x̂min size must be $((nx̂,)) " ))
496496 any (< (0 ), c_x̂min) && error (" c_x̂min weights should be non-negative" )
497497 con. c_x̂min .= c_x̂min
498498 size (con. A_x̂min, 1 ) ≠ 0 && (con. A_x̂min[:, end ] .= - con. c_x̂min) # for LinModel
499499 end
500500 if ! isnothing (c_x̂max)
501- size (c_x̂max) == (nx̂,) || throw (ArgumentError (" c_x̂max size must be $((nx̂,)) " ))
501+ size (c_x̂max) == (nx̂,) || throw (DimensionMismatch (" c_x̂max size must be $((nx̂,)) " ))
502502 any (< (0 ), c_x̂max) && error (" c_x̂max weights should be non-negative" )
503503 con. c_x̂max .= c_x̂max
504504 size (con. A_x̂max, 1 ) ≠ 0 && (con. A_x̂max[:, end ] .= - con. c_x̂max) # for LinModel
0 commit comments