ucd-cws / calvin-network-tools

Command line tools for calvin-network-data and calvin-network-app. Includes prm tool for export PRI and DSS files
MIT License
3 stars 5 forks source link

Missing `lb` for some time steps for some links #40

Closed msdogan closed 7 years ago

msdogan commented 7 years ago

@jrmerz I am having some problem with some (not all of them) SINK links. For some time steps, lb is not written in the network matrix.

Here are a few example links. There is probably more than that:

D653b.2000-02-28    SINK.2000-02-28 0   0   1       1000000000
D897.2000-02-28 SINK.2000-02-28 0   0   1       1000000000
D744a.2000-02-28    SINK.2000-02-28 0   0   1       1000000000

Below is the error message from pyomo:

ValueError: The value=('SINK.2000-03-31', 0, 0) is not valid for set=A
    because it is not within the domain=A_domain
[   45.12] Pyomo Finished
ERROR: Unexpected exception while running model:
    The value=('SINK.2000-03-31', 0, 0) is not valid for set=A
    because it is not within the domain=A_domain

I can't think of any reason why this would be happening.

jrmerz commented 7 years ago

@msdogan D653b.2000-02-28 has a constrained flow, but cub is null. This because we set lb=0, ub=null for costs for all constant costs. Then for constrained flows, we set lb=ub if constrained flow. The the final processing setup is to set all ub == null to Max UB, but the lb == null is not handled.

Thoughts?

msdogan commented 7 years ago

@jrmerz yes, looks like they are all constrained SINK flows, so lb must equal to ub. I don't understand how cub gets null.

EDIT: It should be lb=ub=data from time-series

jrmerz commented 7 years ago

Because the sinks cost is set to constant. Which we assign here: https://github.com/ucd-cws/calvin-network-tools/blob/master/nodejs/matrix/cost.js#L232

jrmerz commented 7 years ago

PS, great tool for viewing JSON in browser if you don't have it https://chrome.google.com/webstore/detail/jsonview/chklaanhfefbnpoihckbnefhakgolnmc

msdogan commented 7 years ago

okay, zero cost is okay but for node D653b there are two types of flow first one is correct, with time series. After that there is another flow equal to null. Could it be the reason for null dataset?

{"type":"Feature",
 "geometry":{"type":"Point","coordinates":[-120.920994,37.738836]},
 "properties":{"prmname":"D653b",
 "description":"Stanislaus River accretion & depletion",
 "type":"Junction",
 "inflows":{"default":{"description":"Accretion: Stanislaus River d/s Goodwin Reservoir","inflow":{"$ref" : "inflows/default.csv"}}},
 "sinks":[{"default" : {"description" : "Depletion: Stanislaus River d/s Goodwin Reservoir", "costs" : {"type":"Constant",
 "cost":0}, "bounds" : [{"type":"EQT","bound": {"$ref":"./sinks/default/EQT.csv"}}], "flow" : {"$ref" : "./sinks/default/flow.csv"}}}],
 "flow":null}}
msdogan commented 7 years ago

So for some reason, the code is not picking lb and ub from "$ref":"./sinks/default/EQT.csv" right?

jrmerz commented 7 years ago

yup.

Ok, think I found the problem... data issue. And there are lots like that. Every leap year, the last day of Feb is marked as the 29th (seems logical), but we check for the 28th, based on flow. I can fix.

msdogan commented 7 years ago

Yes, you are right, they are all FEB. Thanks a lot.

jrmerz commented 7 years ago

Wait, flows are set to 29th... I think this is my 'fake the flow' logic... when I create the dates w/o the existence of flow. Need to check for leap year.

jrmerz commented 7 years ago

Ok, fix pushed, give it a try.

msdogan commented 7 years ago

alright, now correct lb and ub show up in the matrix for leap years. Thanks.

D744a.2000-02-29    SINK.2000-02-29 0   0   1   0.647345    0.647345
jrmerz commented 7 years ago

pushed to npm calvin-network-tools@1.0.50