Skip to content

Commit 8ea618d

Browse files
committed
changed: removed useless relax calls in setconstraint!
1 parent 391bf73 commit 8ea618d

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/controller/construct.jl

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -235,29 +235,25 @@ function setconstraint!(
235235
size(C_ymin) == (ny*Hp,) || throw(ArgumentError("C_ymin size must be $((ny*Hp,))"))
236236
any(C_ymin .< 0) && error("C_ymin weights should be non-negative")
237237
con.C_ymin[:] = C_ymin
238-
A_Ymin ,_ = relaxŶ(model, C, con.C_ymin, con.C_ymax, E)
239-
con.A_Ymin[:] = A_Ymin
238+
size(con.A_Ymin, 1) 0 && (con.A_Ymin[:, end] = -C_ymin) # for LinModel
240239
end
241240
if !isnothing(C_ymax)
242241
size(C_ymax) == (ny*Hp,) || throw(ArgumentError("C_ymax size must be $((ny*Hp,))"))
243242
any(C_ymax .< 0) && error("C_ymax weights should be non-negative")
244243
con.C_ymax[:] = C_ymax
245-
_, A_Ymax = relaxŶ(model, C, con.C_ymin, con.C_ymax, E)
246-
con.A_Ymax[:] = A_Ymax
244+
size(con.A_Ymax, 1) 0 && (con.A_Ymax[:, end] = -C_ymax) # for LinModel
247245
end
248246
if !isnothing(c_x̂min)
249247
size(c_x̂min) == (nx̂,) || throw(ArgumentError("c_x̂min size must be $((nx̂,))"))
250248
any(c_x̂min .< 0) && error("c_x̂min weights should be non-negative")
251249
con.c_x̂min[:] = c_x̂min
252-
A_x̂min ,_ = relaxterminal(model, C, con.c_x̂min, con.c_x̂max, ex̂)
253-
con.A_x̂min[:] = A_x̂min
250+
size(con.A_x̂min, 1) 0 && (con.A_x̂min[:, end] = -c_x̂min) # for LinModel
254251
end
255252
if !isnothing(c_x̂max)
256253
size(c_x̂max) == (nx̂,) || throw(ArgumentError("c_x̂max size must be $((nx̂,))"))
257254
any(c_x̂max .< 0) && error("c_x̂max weights should be non-negative")
258255
con.c_x̂max[:] = c_x̂max
259-
_, A_x̂max = relaxterminal(model, C, con.c_x̂min, con.c_x̂max, ex̂)
260-
con.A_x̂max[:] = A_x̂max
256+
size(con.A_x̂max, 1) 0 && (con.A_x̂max[:, end] = -c_x̂max) # for LinModel
261257
end
262258
i_Umin, i_Umax = .!isinf.(con.Umin), .!isinf.(con.Umax)
263259
i_ΔŨmin, i_ΔŨmax = .!isinf.(con.ΔŨmin), .!isinf.(con.ΔŨmin)

0 commit comments

Comments
 (0)