You get this error because you are invoking Cplex.linear_constraints.add() with a SparsePair() in lin_expr that has duplicate constraints in its ind[] array. You will have to debug your code to figure out why you are adding more than one term for the same variable in a constraint.
I took a quick look at your code and this looks suspicious to me:
for k in range(noph):
thevarxs=[z[i][k]]
thecoefxs=[O[i]]
for l in [q for q in xrange(noph) if q!=k]:
thevarxs.append(y[i][k][l]) # (*)
thecoefxs.append(-1)
thevarxs.append(y[i][l][k]) # (**)
thecoefxs.append(1)
Consider two indices a0 and a1 in xrange(noph). As far as I can tell, for k=a0, l=a1 you will add terms for y[i][a0][a1] (by row (*)) and y[i][a1][a0] (by row (**)). But in your iteration you will also encounter k=a1 and l=a0. Then you will add two more terms, one for y[i][a1][a0] (by row (*)) and one for y[i][a0][a1] (by row (**)). As you can see, two terms for each of y[i][a0][a1] and y[i][a1][a0]. This is probably not what you intended to do?
Also, the loop
for j in range(noph):
thevarxs.append(z[j][k])
thecoefxs.append(-dem[k][j])
will add a term for z[i][k] which you already added a few lines above that.
#CPLEXOptimizers#DecisionOptimization