jukaukor

NonlinearOptim1.jl

Mar 2nd, 2021 (edited)
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. using JuMP, Ipopt
  2. # Esimerkki epälieaarisesta optimoinnista
  3. # Juhani Kaukoranta 2.3.2021
  4. # Ajetaan komennolla Esim1()
  5.  
  6. function Esim1()
  7. model = Model(Ipopt.Optimizer)
  8. @variable(model, x)
  9. @variable(model, y >= 0)
  10. @variable(model, z >= 0)
  11. @objective(model, Max, x) # maksimoidaan x
  12. @constraint(model, x + y + z == 1) # lineaarinen ehto
  13. @constraint(model, x^2 + y^2 - z * z <= 0) # epälin ehto
  14. @constraint(model, x^2 - y * z <= 0) # epälin ehto
  15. optimize!(model)
  16. print(model)
  17. println("Objective value: ", objective_value(model)) # tulostaa maksimin
  18. println("x = ",value(x))
  19. println("y = ",value(y))
  20. println("z = ",value(z))
  21. end
Add Comment
Please, Sign In to add comment