nx = 4 
 
ny = 7 
 
ns = 3 
 
nv = 11 
 
ne = 11 
 
jumps_to_approximate = [2, 3] 
 
eqns_to_approximate = [4, 7] 
 
derivs_to_approximate_num = Int64[] 
 
derivs_to_approximate_den = Int64[] 
 
eqns_with_derivs = Int64[] 
 
variables = OrderedDict("z" => 1, "ϵ" => 2, "β" => 3, "clag" => 4, "c" => 5, "muca" => 6, "mucb" => 7, "i" => 8, "h" => 9, "infl" => 10, "lm" => 11) 
 
function nlsolve_static_equations(f::Array{T,1},x::Array{T,1}) where {T<:Number} 
 
  f[1] = x[1] - ((0.950)*x[1] + (0.0028)*0.0)
  f[2] = x[2] - ((0.800)*x[2] + (0.025)*0.0)
  f[3] = x[3] - ((1-(0.8))*log((0.995)) + (0.8)*x[3] + (0.004)*0.0)
  f[4] = x[5]^((0.35)-1-(1.100)*(0.35))*(1-x[9])^((1-(1.100))*(1-(0.35))) - (x[6]*(1+x[8]))
  f[5] = x[6] - (exp(x[3])*x[5]^((0.35)-1-(1.100)*(0.35))*(1-x[9])^((1-(1.100))*(1-(0.35)))/(1+x[10]))
  f[6] = x[7] - (exp(x[3])*x[5]^((0.35)-1-(1.100)*(0.35))*(1-x[9])^((1-(1.100))*(1-(0.35)))*x[5]*x[10]*(1+x[10]))
  f[7] = x[10]*(1+x[10]) - ((1-(0.0))*(1-(11.00)*exp(x[2]))/(80.00) + x[7]/(x[5]*x[5]^((0.35)-1-(1.100)*(0.35))*(1-x[9])^((1-(1.100))*(1-(0.35)))) + ((11.00)*exp(x[2])/(80.00))*((1-(0.35))/(0.35))*x[5]/((1-x[9])*exp(x[1])))
  f[8] = x[5] - (exp(x[1])*x[9])
  f[9] = 1+x[8] - (((1+(0.00375))/exp(x[3]))*((1+x[10])/(1+(0.00375)))^(1.5)*(x[5]/x[4])^(0.125) + x[11])
  f[10] = x[8]*x[11] - (0.0)
  f[11] = x[4] - (x[5])

end 
 
function static_equations(x::Array{T,1}) where {T<:Number} 
 
  f = Array{T,1}(undef,length(x)) 
 
  f[1] = x[1] - ((0.950)*x[1] + (0.0028)*0.0)
  f[2] = x[2] - ((0.800)*x[2] + (0.025)*0.0)
  f[3] = x[3] - ((1-(0.8))*log((0.995)) + (0.8)*x[3] + (0.004)*0.0)
  f[4] = x[5]^((0.35)-1-(1.100)*(0.35))*(1-x[9])^((1-(1.100))*(1-(0.35))) - (x[6]*(1+x[8]))
  f[5] = x[6] - (exp(x[3])*x[5]^((0.35)-1-(1.100)*(0.35))*(1-x[9])^((1-(1.100))*(1-(0.35)))/(1+x[10]))
  f[6] = x[7] - (exp(x[3])*x[5]^((0.35)-1-(1.100)*(0.35))*(1-x[9])^((1-(1.100))*(1-(0.35)))*x[5]*x[10]*(1+x[10]))
  f[7] = x[10]*(1+x[10]) - ((1-(0.0))*(1-(11.00)*exp(x[2]))/(80.00) + x[7]/(x[5]*x[5]^((0.35)-1-(1.100)*(0.35))*(1-x[9])^((1-(1.100))*(1-(0.35)))) + ((11.00)*exp(x[2])/(80.00))*((1-(0.35))/(0.35))*x[5]/((1-x[9])*exp(x[1])))
  f[8] = x[5] - (exp(x[1])*x[9])
  f[9] = 1+x[8] - (((1+(0.00375))/exp(x[3]))*((1+x[10])/(1+(0.00375)))^(1.5)*(x[5]/x[4])^(0.125) + x[11])
  f[10] = x[8]*x[11] - (0.0)
  f[11] = x[4] - (x[5])

  return f 
 
end 
 
function dynamic_equations(x::Array{T,1}) where {T<:Number} 
 
  f = Array{T,1}(undef,11) 
 
  f[1] = x[12] - ((0.950)*x[1] + (0.0028)*x[23])
  f[2] = x[13] - ((0.800)*x[2] + (0.025)*x[24])
  f[3] = x[14] - ((1-(0.8))*log((0.995)) + (0.8)*x[3] + (0.004)*x[25])
  f[4] = x[5]^((0.35)-1-(1.100)*(0.35))*(1-x[9])^((1-(1.100))*(1-(0.35))) - (x[17]*(1+x[8]))
  f[5] = x[6] - (exp(x[3])*x[5]^((0.35)-1-(1.100)*(0.35))*(1-x[9])^((1-(1.100))*(1-(0.35)))/(1+x[10]))
  f[6] = x[7] - (exp(x[3])*x[5]^((0.35)-1-(1.100)*(0.35))*(1-x[9])^((1-(1.100))*(1-(0.35)))*x[5]*x[10]*(1+x[10]))
  f[7] = x[10]*(1+x[10]) - ((1-(0.0))*(1-(11.00)*exp(x[2]))/(80.00) + x[18]/(x[5]*x[5]^((0.35)-1-(1.100)*(0.35))*(1-x[9])^((1-(1.100))*(1-(0.35)))) + ((11.00)*exp(x[2])/(80.00))*((1-(0.35))/(0.35))*x[5]/((1-x[9])*exp(x[1])))
  f[8] = x[5] - (exp(x[1])*x[9])
  f[9] = 1+x[8] - (((1+(0.00375))/exp(x[3]))*((1+x[10])/(1+(0.00375)))^(1.5)*(x[5]/x[4])^(0.125) + x[11])
  f[10] = x[8]*x[11] - (0.0)
  f[11] = x[15] - (x[5])

  return f 
 
end 

function dynamic_eqn_1(x::Array{T,1}) where {T<:Number} 
 
  f = x[12] - ((0.950)*x[1] + (0.0028)*x[23])

  return f 
 
end 

function dynamic_eqn_2(x::Array{T,1}) where {T<:Number} 
 
  f = x[13] - ((0.800)*x[2] + (0.025)*x[24])

  return f 
 
end 

function dynamic_eqn_3(x::Array{T,1}) where {T<:Number} 
 
  f = x[14] - ((1-(0.8))*log((0.995)) + (0.8)*x[3] + (0.004)*x[25])

  return f 
 
end 

function dynamic_eqn_4(x::Array{T,1}) where {T<:Number} 
 
  f = x[5]^((0.35)-1-(1.100)*(0.35))*(1-x[9])^((1-(1.100))*(1-(0.35))) - (x[17]*(1+x[8]))

  return f 
 
end 

function dynamic_eqn_5(x::Array{T,1}) where {T<:Number} 
 
  f = x[6] - (exp(x[3])*x[5]^((0.35)-1-(1.100)*(0.35))*(1-x[9])^((1-(1.100))*(1-(0.35)))/(1+x[10]))

  return f 
 
end 

function dynamic_eqn_6(x::Array{T,1}) where {T<:Number} 
 
  f = x[7] - (exp(x[3])*x[5]^((0.35)-1-(1.100)*(0.35))*(1-x[9])^((1-(1.100))*(1-(0.35)))*x[5]*x[10]*(1+x[10]))

  return f 
 
end 

function dynamic_eqn_7(x::Array{T,1}) where {T<:Number} 
 
  f = x[10]*(1+x[10]) - ((1-(0.0))*(1-(11.00)*exp(x[2]))/(80.00) + x[18]/(x[5]*x[5]^((0.35)-1-(1.100)*(0.35))*(1-x[9])^((1-(1.100))*(1-(0.35)))) + ((11.00)*exp(x[2])/(80.00))*((1-(0.35))/(0.35))*x[5]/((1-x[9])*exp(x[1])))

  return f 
 
end 

function dynamic_eqn_8(x::Array{T,1}) where {T<:Number} 
 
  f = x[5] - (exp(x[1])*x[9])

  return f 
 
end 

function dynamic_eqn_9(x::Array{T,1}) where {T<:Number} 
 
  f = 1+x[8] - (((1+(0.00375))/exp(x[3]))*((1+x[10])/(1+(0.00375)))^(1.5)*(x[5]/x[4])^(0.125) + x[11])

  return f 
 
end 

function dynamic_eqn_10(x::Array{T,1}) where {T<:Number} 
 
  f = x[8]*x[11] - (0.0)

  return f 
 
end 

function dynamic_eqn_11(x::Array{T,1}) where {T<:Number} 
 
  f = x[15] - (x[5])

  return f 
 
end 

individual_equations = Array{Function}(undef,11) 
individual_equations[1] = dynamic_eqn_1
individual_equations[2] = dynamic_eqn_2
individual_equations[3] = dynamic_eqn_3
individual_equations[4] = dynamic_eqn_4
individual_equations[5] = dynamic_eqn_5
individual_equations[6] = dynamic_eqn_6
individual_equations[7] = dynamic_eqn_7
individual_equations[8] = dynamic_eqn_8
individual_equations[9] = dynamic_eqn_9
individual_equations[10] = dynamic_eqn_10
individual_equations[11] = dynamic_eqn_11

function closure_chebyshev_equations(state,scaled_weights,order,domain) 
 
  function chebyshev_equations(f::Array{T,1},x::Array{T,1}) where {T<:Number} 
 
    approx2 = chebyshev_evaluate(scaled_weights[1],x[7+1:end],order,domain)
    approx3 = chebyshev_evaluate(scaled_weights[2],x[7+1:end],order,domain)

    #f = Array{T,1}(undef,11) 
 
    f[1] = x[8] - ((0.950)*state[1] + (0.0028)*0.0)
    f[2] = x[9] - ((0.800)*state[2] + (0.025)*0.0)
    f[3] = x[10] - ((1-(0.8))*log((0.995)) + (0.8)*state[3] + (0.004)*0.0)
    f[4] = x[1]^((0.35)-1-(1.100)*(0.35))*(1-x[5])^((1-(1.100))*(1-(0.35))) - (approx2*(1+x[4]))
    f[5] = x[2] - (exp(state[3])*x[1]^((0.35)-1-(1.100)*(0.35))*(1-x[5])^((1-(1.100))*(1-(0.35)))/(1+x[6]))
    f[6] = x[3] - (exp(state[3])*x[1]^((0.35)-1-(1.100)*(0.35))*(1-x[5])^((1-(1.100))*(1-(0.35)))*x[1]*x[6]*(1+x[6]))
    f[7] = x[6]*(1+x[6]) - ((1-(0.0))*(1-(11.00)*exp(state[2]))/(80.00) + approx3/(x[1]*x[1]^((0.35)-1-(1.100)*(0.35))*(1-x[5])^((1-(1.100))*(1-(0.35)))) + ((11.00)*exp(state[2])/(80.00))*((1-(0.35))/(0.35))*x[1]/((1-x[5])*exp(state[1])))
    f[8] = x[1] - (exp(state[1])*x[5])
    f[9] = 1+x[4] - (((1+(0.00375))/exp(state[3]))*((1+x[6])/(1+(0.00375)))^(1.5)*(x[1]/state[4])^(0.125) + x[7])
    f[10] = x[4]*x[7] - (0.0)
    f[11] = x[11] - (x[1])

    #return f 
 
  end 
 
  return chebyshev_equations 
 
end 

function closure_smolyak_equations(state,scaled_weights,order,domain) 
 
  function smolyak_equations(f::Array{T,1},x::Array{T,1}) where {T<:Number} 
 
    poly = smolyak_polynomial(x[7+1:end],order,domain) 
    approx2 = smolyak_evaluate(scaled_weights[1],poly)
    approx3 = smolyak_evaluate(scaled_weights[2],poly)

    #f = Array{T,1}(undef,11) 
 
    f[1] = x[8] - ((0.950)*state[1] + (0.0028)*0.0)
    f[2] = x[9] - ((0.800)*state[2] + (0.025)*0.0)
    f[3] = x[10] - ((1-(0.8))*log((0.995)) + (0.8)*state[3] + (0.004)*0.0)
    f[4] = x[1]^((0.35)-1-(1.100)*(0.35))*(1-x[5])^((1-(1.100))*(1-(0.35))) - (approx2*(1+x[4]))
    f[5] = x[2] - (exp(state[3])*x[1]^((0.35)-1-(1.100)*(0.35))*(1-x[5])^((1-(1.100))*(1-(0.35)))/(1+x[6]))
    f[6] = x[3] - (exp(state[3])*x[1]^((0.35)-1-(1.100)*(0.35))*(1-x[5])^((1-(1.100))*(1-(0.35)))*x[1]*x[6]*(1+x[6]))
    f[7] = x[6]*(1+x[6]) - ((1-(0.0))*(1-(11.00)*exp(state[2]))/(80.00) + approx3/(x[1]*x[1]^((0.35)-1-(1.100)*(0.35))*(1-x[5])^((1-(1.100))*(1-(0.35)))) + ((11.00)*exp(state[2])/(80.00))*((1-(0.35))/(0.35))*x[1]/((1-x[5])*exp(state[1])))
    f[8] = x[1] - (exp(state[1])*x[5])
    f[9] = 1+x[4] - (((1+(0.00375))/exp(state[3]))*((1+x[6])/(1+(0.00375)))^(1.5)*(x[1]/state[4])^(0.125) + x[7])
    f[10] = x[4]*x[7] - (0.0)
    f[11] = x[11] - (x[1])

    #return f 
 
  end 
 
  return smolyak_equations 
 
end 

function closure_hcross_equations(state,scaled_weights,order,domain) 
 
  function hcross_equations(f::Array{T,1},x::Array{T,1}) where {T<:Number} 
 
    poly = hyperbolic_cross_polynomial(x[7+1:end],order,domain) 
    approx2 = hyperbolic_cross_evaluate(scaled_weights[1],poly)
    approx3 = hyperbolic_cross_evaluate(scaled_weights[2],poly)

    #f = Array{T,1}(undef,11) 
 
    f[1] = x[8] - ((0.950)*state[1] + (0.0028)*0.0)
    f[2] = x[9] - ((0.800)*state[2] + (0.025)*0.0)
    f[3] = x[10] - ((1-(0.8))*log((0.995)) + (0.8)*state[3] + (0.004)*0.0)
    f[4] = x[1]^((0.35)-1-(1.100)*(0.35))*(1-x[5])^((1-(1.100))*(1-(0.35))) - (approx2*(1+x[4]))
    f[5] = x[2] - (exp(state[3])*x[1]^((0.35)-1-(1.100)*(0.35))*(1-x[5])^((1-(1.100))*(1-(0.35)))/(1+x[6]))
    f[6] = x[3] - (exp(state[3])*x[1]^((0.35)-1-(1.100)*(0.35))*(1-x[5])^((1-(1.100))*(1-(0.35)))*x[1]*x[6]*(1+x[6]))
    f[7] = x[6]*(1+x[6]) - ((1-(0.0))*(1-(11.00)*exp(state[2]))/(80.00) + approx3/(x[1]*x[1]^((0.35)-1-(1.100)*(0.35))*(1-x[5])^((1-(1.100))*(1-(0.35)))) + ((11.00)*exp(state[2])/(80.00))*((1-(0.35))/(0.35))*x[1]/((1-x[5])*exp(state[1])))
    f[8] = x[1] - (exp(state[1])*x[5])
    f[9] = 1+x[4] - (((1+(0.00375))/exp(state[3]))*((1+x[6])/(1+(0.00375)))^(1.5)*(x[1]/state[4])^(0.125) + x[7])
    f[10] = x[4]*x[7] - (0.0)
    f[11] = x[11] - (x[1])

    #return f 
 
  end 
 
  return hcross_equations 
 
end 

function closure_piecewise_equations(variables,grid,state,integrals) 
 
  function piecewise_equations(f::Array{T,1},x::Array{T,1}) where {T<:Number} 
 
    approx2 = piecewise_linear_evaluate(variables[2],grid,x[7+1:end],integrals)
    approx3 = piecewise_linear_evaluate(variables[3],grid,x[7+1:end],integrals)

    #f = Array{T,1}(undef,11) 
 
    f[1] = x[8] - ((0.950)*state[1] + (0.0028)*0.0)
    f[2] = x[9] - ((0.800)*state[2] + (0.025)*0.0)
    f[3] = x[10] - ((1-(0.8))*log((0.995)) + (0.8)*state[3] + (0.004)*0.0)
    f[4] = x[1]^((0.35)-1-(1.100)*(0.35))*(1-x[5])^((1-(1.100))*(1-(0.35))) - (approx2*(1+x[4]))
    f[5] = x[2] - (exp(state[3])*x[1]^((0.35)-1-(1.100)*(0.35))*(1-x[5])^((1-(1.100))*(1-(0.35)))/(1+x[6]))
    f[6] = x[3] - (exp(state[3])*x[1]^((0.35)-1-(1.100)*(0.35))*(1-x[5])^((1-(1.100))*(1-(0.35)))*x[1]*x[6]*(1+x[6]))
    f[7] = x[6]*(1+x[6]) - ((1-(0.0))*(1-(11.00)*exp(state[2]))/(80.00) + approx3/(x[1]*x[1]^((0.35)-1-(1.100)*(0.35))*(1-x[5])^((1-(1.100))*(1-(0.35)))) + ((11.00)*exp(state[2])/(80.00))*((1-(0.35))/(0.35))*x[1]/((1-x[5])*exp(state[1])))
    f[8] = x[1] - (exp(state[1])*x[5])
    f[9] = 1+x[4] - (((1+(0.00375))/exp(state[3]))*((1+x[6])/(1+(0.00375)))^(1.5)*(x[1]/state[4])^(0.125) + x[7])
    f[10] = x[4]*x[7] - (0.0)
    f[11] = x[11] - (x[1])

    #return f 
 
  end 
 
  return piecewise_equations 
 
end 

unassigned_parameters = String[] 

solvers = "Projection" 