|
| 1 | +function operatorspb() |
| 2 | + nlp = Model() |
| 3 | + x0 = [390, 1000, 419.5, 340.5, 198.175, 0.5] |
| 4 | + lvar = [0, 0, 340, 340, -1000, 0] |
| 5 | + uvar = [400, 1000, 420, 420, 10000, 0.5236] |
| 6 | + @variable(nlp, lvar[i] <= x[i = 1:6] <= uvar[i], start = x0[i]) |
| 7 | + |
| 8 | + a = 131078 // 1000 |
| 9 | + b = 148577 // 100000 |
| 10 | + ci = 90798 // 100000 |
| 11 | + d = cos(147588 // 100000) |
| 12 | + e = sin(147588 // 100000) |
| 13 | + |
| 14 | + @constraint(nlp, 300 - x[1] - 1 / a * x[3] * x[4] * cos(b - x[6]) + ci / a * d * x[3] == 0) |
| 15 | + @constraint(nlp, -x[2] - 1 / a * x[3] * x[4] * cos(b + x[6]) + ci / a * d * x[4]^2 == 0) |
| 16 | + @constraint(nlp, -x[5] - 1 / a * x[3] * x[4] * cos(b + x[6]) + ci / a * e * x[4]^2 == 0) |
| 17 | + @constraint(nlp, 200 - 1 / a * x[3] * x[4] * sin(b - x[6]) + ci / a * e * x[3]^2 == 0) |
| 18 | + |
| 19 | + function f1(t) |
| 20 | + return if 0 <= t <= 300 |
| 21 | + 30 * t |
| 22 | + elseif 300 <= t <= 400 |
| 23 | + 31 * t |
| 24 | + else |
| 25 | + eltype(x)(Inf) |
| 26 | + end |
| 27 | + end |
| 28 | + |
| 29 | + function f2(t) |
| 30 | + return if 0 <= t <= 100 |
| 31 | + 28 * t |
| 32 | + elseif 100 <= t <= 200 |
| 33 | + 29 * t |
| 34 | + elseif 200 <= t <= 1000 |
| 35 | + 30 * t |
| 36 | + else |
| 37 | + eltype(t)(Inf) |
| 38 | + end |
| 39 | + end |
| 40 | + @operator(nlp, op_f1, 1, f1) |
| 41 | + @expression(nlp, op_f1) |
| 42 | + @operator(nlp, op_f2, 1, f2) |
| 43 | + @expression(nlp, op_f2) |
| 44 | + @objective(nlp, Min, op_f1(x[1]) + op_f2(x[2])) |
| 45 | + |
| 46 | + return nlp |
| 47 | +end |
0 commit comments