# Problem with Occbin convergence

Dear Dynare team,
I did my PhD in the 1990s, so I am quite rusty after so many years. I tried to solve a classic model adding investment in flood defences, d, but as they sometimes were negative I introduced an occbin constrant. However, I must be doing something wrong as I get the “Simulation did not converge, increase maxit or check_ahead_periods” warning no matter how many maxit or check ahead periods I increase. The file is
Defences1.mod (1.1 KB)
Thank you for your help

It seems your setup is wrong. The constraint seems to be always binding.

Thank you for your quick response, Dr Pfeifer, but how can it be? In the unconstrained model investment in defences was only negative about one in every 10 times and that’s the only constrain I am imposing.

Can you please explain the logic behind your implementation? Just staring at the equations does not help.

Good morning doctor Pfeifer and than you again for your help and your patience with this.

d is the stock of flood defences, a type of capital that minimises damages caused by bad weather and investment in this type of capital is d - (1-deltad)*z where deltad is the depeciation rate for this type of capital and z = d(-1), an auxiliary variable introduced to avoid lags in the constrain. This investment needs to be positive (although I have just realised that I sent you a version of the model where I relaxed this hypothesis to bigger than -5000 to see if it worked)

In the model block, k+d = (y-g-c)+(1-deltak)*k(-1)+(1-deltad)*d(-1) is the change in all types of capital where capital this year is investment plus the capital last year minus depreciation but, when investment in d is zero the terms with d at both sides of the equation cancel each other.

g is GDP lost each year because of extreme weather events. It depends on the weather shock tau

1. First of all, does the model properly work without any constraints? Your timing for capital seems strange.
2. You have
``````occbin_constraints;
name 'neg';  bind d - (1-deltad)*z >= -50000;
end;
``````

So the constraint is binding whenever investment is above -50000. It should be `<=` from what I can see.

Yes, the model works without the constrain
I wanted the constrain to be always positive, I just tried the 5000 to see it relaxing it a bit would work. From your answer, should I have a <= 0 constrain to have investment strictly positive at all times? I may be reading the logic behind the constrain equation the opposite way

The logic of the constraint is: the equation with the `bind`-tag will be operative whenever `d - (1-deltad)*z >= -50000; ` evaluates to true.

I am so sorry for having bothered you, I must have been especially thick this week as I was reading it the other way around. Now the model works. Thank you so much for your time and help

Glad I could help.