Skip to content

Instantly share code, notes, and snippets.

@vikjam
Created October 28, 2017 19:57
Show Gist options
  • Save vikjam/f6948592da52ce5398d0fd84e544f0c1 to your computer and use it in GitHub Desktop.
Save vikjam/f6948592da52ce5398d0fd84e544f0c1 to your computer and use it in GitHub Desktop.
Nonlinear solver
using JuMP, Ipopt
A = 1; δ = 0.1; θ = 0.3; β = 0.96; ɛ = 0.5; χ = 0.5;
r = (1 / β) - (1 - δ);
m = Model(solver = IpoptSolver())
@variable(m, 0 <= k <= Inf)
@variable(m, 0 <= n <= Inf)
@variable(m, 0 <= w <= Inf)
@objective(m, Max, 1)
@NLconstraint(m, (A * (k^θ * n^(1 - θ))^((ɛ - 1)/ɛ) + (e)^((ɛ - 1)/ɛ))^(1/(ɛ - 1)) * (1 - θ) * A * (k^(θ * (ɛ - 1)) * n^((1 - θ) * (ɛ - 1) - ɛ))^(1 / ɛ) == w)
@NLconstraint(m, (A * (k^θ * n^(1 - θ))^((ɛ - 1)/ɛ) + (e)^((ɛ - 1)/ɛ))^(1/(ɛ - 1)) * θ * A * (k^(θ) * (ɛ - 1) - ɛ) * n^((1 - θ) * (ɛ - 1))^(1 / ɛ) == r)
@NLconstraint(m, (A * (k^θ * n^(1 - θ))^((ɛ - 1)/ɛ) + (e)^((ɛ - 1)/ɛ))^(1/(ɛ - 1)) * e^(1 / ɛ) == w / χ)
print(m)
status = solve(m)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment