Equation, Condition and variables

Hi, I’m trying to establish a condition to my equation by a variable.

Basicaly, my problem consist into a sewer system that converg to a node (n), so, another tube get out from this node.
But I need to find the cote of this tube that get out of this node (n). This shuld be iqual or lower, of the lowest cote of the tubes that converge to the node (n).
Another condition is, if any tube converge to the node, so, it is a start node, than I should use the cote of the terrain.

I tried using a binary, BigM and Dolar condition.

SET - n - node, si(n) - the last node, out, nn(n,np) - arc.
alias (n,np,npp)

Variables CGSu, CGSd, qri, ql
CGS - cote of upstream and downstream
qri - the initial flow
ql - minimal flow

Binary variable
binPV and binPV1

out(n)$(not si(n))..
                binPV1(n) =l= sum(nn(np,n), binPV(nn));
out1(np,n)$(nn(np,n))..
                binPV(np,n) =l= binPV1(n);

pan8(n,np)$(nn(n,np))..
      cgsd(n,np) =l= sum(nn(npp,n),cgsu(nn)*binPV(nn))$(qri.l(n,np)>ql.l(n,np))
                        + ctn(n)$(qri.l(n,np)<=ql.l(n,np)) ;

I appreciate it if someone can help.
Thanks and regards,