Closed msdogan closed 7 years ago
@msdogan
So cost[k].ub is null for d61-c301 and we have the following condition for calculating cost lb (stepBound.LB is physical lower bound):
if( costs[k].lb > stepBounds.LB ) {
clb = costs[k].lb;
} else if ( (costs[k].ub || 0) <= stepBounds.LB ) {
clb = costs[k].ub || 0;
} else {
clb = stepBounds.LB;
}
so the following is being used
} else if ( (costs[k].ub || 0) <= stepBounds.LB ) {
clb = costs[k].ub || 0;
}
setting cost lb to 0 in the matrix.
@jrmerz @jdherman I guess problem is occurring because we impose physical lb and ub in the cost loop, right? When there is no cost associated, it fails to put physical lb and ub.
If fails because cost[k].ub is null, so it checks (0 < stepBounds.LB), which is true, so clb is set to 0.
It is doing fine for imposing physical lb and ub for piecewise costs, but we want to impose physical lb and ub when there is no cost (null) or cost is constant (no piecewise or k=0). Do you have any idea how to do that? :)
So I'm not coming up with a solution other than specifically flagging the condition, which I'm not particularly thrilled with. Thoughts?
I was going to suggest
if( costs[k].lb < stepBounds.LB ) {
clb = stepBounds.LB;
but I am afraid it is going to interfere with current statement to calculate piecewise cost and bounds.
@jdherman current code to calculate bounds is good for piecewise case but not for the case where cost is constant or null. Do you have any suggestion?
I think it has to be a separate flag, unfortunately. Somehow the constraints still need to be imposed for links that have no costs (which is probably the more common condition).
Probably just an outer if-statement: if not a cost link, impose LB/UB directly; otherwise, do everything the code does now.
I agree with that. I just want to add links with constant costs (no piecewise). The constant unit cost can be zero or some other constant number. I guess default (null) cost value is zero. In that case impose physical lb and ub.
@jrmerz while comparing results, I saw that minimum in-stream requirements are not represented in matrix export, and these are causing flow differences between CALVIN and pyvin. Can we fix that? some example links with LBT:
d61-c301
: https://github.com/ucd-cws/calvin-network-data/tree/4705e14151c3ed149033237ec0a0cbf959d3b963/data/sacramento-river/d61-c301d616-c42
: https://github.com/ucd-cws/calvin-network-data/tree/4705e14151c3ed149033237ec0a0cbf959d3b963/data/san-joaquin-river/d616-c42d77-d75
: https://github.com/ucd-cws/calvin-network-data/tree/4705e14151c3ed149033237ec0a0cbf959d3b963/data/sacramento-river/d77-d75