# Occbin simulation with dynare 5.0

Hello everyone,
I want to implement an occasionally binding constraint in my model, similar to borrowing constraint:

``````m_h <= m * p_h_r * y_h / ex_r
``````

Where m is a parameter. Solving the problem I get the following first order condition:

``````delta_e = lambda_bind
``````

Where lambda_bind is the non-negative lagrange multiplier of the binding constraint, and delta_e is the difference in exchange rate.

According to this when the constraint is binding, the next period’s exchange rate is raising because e(+1)=e+lambda_bind. This affects only UIP (lines 137-141 in code)

I’ve tried it (lines 137-146 in code) but it doesn’t give logical IRFs as lambda_bind is negative and close to zero. And it doesn’t reach to convergence for some values of shock. Also piecewise linear and linear solutions are on the same lines.
How can I fix this?
I attach the code below.
util_a.mod (6.5 KB)
Thank you so much

I don’t understand what you are doing with your occasionally binding constraint.
Can you offer a bit more detail about what you are intending to do?

Hi , Thank you for the reply and sorry for the late reply.
I try to solve the following optimization problem.

I consider a currency exchange company which maximizes its profit, which he gets from buying and selling dollar (m_f)
My constraint in real terms is `m_f <= m* p_h * y_h / ex_r`, which indicates that people can buy dollars up till some share of nominal GDP.
I got the following FOC `delta(e(+1)) = lambda`. This means when the constraint is binding, exchange rate is increasing (lambda is a non-negative number) , or , in other words, domestic currency is depreciating .
How can I apply this occasionally binding constraint in my code?