Munarita,
I did not analyze your model in depth but your approach to try different formulations and check afterwards if results are satisfactory does not seem quite right to me.
I think you should have a clear idea what you actually want to model and then verify your modeling approach by looking at the “critical” equations in the equation listing. For your model, it seems that first/last elements of set h are somewhat critical and that you are not exactly sure how lag/lead, card and ord operators work. You mention one exemplary equation for which you say you tried three different formulations (btw: none of them is exactly used in the model you attached).
1) ComND(nD,y,h)$(ord(h)< card(h)).. CapnD(nD,y,h) + NCAnD(nD,y,h) =E= CapnD(nD,y,h+1);
2) ComND(nD,y,h)$(ord(h)< card(h)).. CapnD(nD,y,h-1) + NCAnD(nD,y,h-1) =E= CapnD(nD,y,h);
3) ComND(nD,y,h)$(ord(h)<=card(h)).. CapnD(nD,y,h-1) + NCAnD(nD,y,h-1) =E= CapnD(nD,y,h);
Apparently, all of them result in different models. If you are not sure what the actual differences are, you can easily figure it out by looking at the equation listing.
The following excerpts of the equation listing shows the equations of some critical time steps (y,h) =(3,1), …, (3,287), (3,288), (4,1) for the three different formulations.
ComND(1,3,1).. CapnD(1,3,1) - CapnD(1,3,2) + NCAnD(1,3,1) =E= 0 ;
[...]
ComND(1,3,287).. CapnD(1,3,287) - CapnD(1,3,288) + NCAnD(1,3,287) =E= 0 ;
ComND(1,3,288).. EQUATION DOES NOT EXIST
ComND(1,4,1).. CapnD(1,4,1) - CapnD(1,4,2) + NCAnD(1,4,1) =E= 0 ;
ComND(1,3,1).. - CapnD(1,3,1) =E= 0 ;
[...]
ComND(1,3,287).. CapnD(1,3,286) - CapnD(1,3,287) + NCAnD(1,3,286) =E= 0 ;
ComND(1,3,288).. EQUATION DOES NOT EXIST
ComND(1,4,1).. - CapnD(1,4,1) =E= 0 ;
ComND(1,3,1).. - CapnD(1,3,1) =E= 0 ;
[...]
ComND(1,3,287).. CapnD(1,3,286) - CapnD(1,3,287) + NCAnD(1,3,286) =E= 0 ;
ComND(1,3,288).. CapnD(1,3,287) - CapnD(1,3,288) + NCAnD(1,3,287) =E= 0 ;
ComND(1,4,1).. - CapnD(1,4,1) =E= 0 ;
No one else but you can answer which one is the right formulation for your model (or if actually any of them is right…).
You also might want to read again the chapters on ord/card and lag/lead operators in the documentation:
I also wonder whether you actually want to connect hours across years. As far as I can see, you do not do that but your latest post implies to me that you might want to have such connection.
I hope this helps you fixing the model yourself.
Best,
Fred