Merge branch 'dev' into lrossman-dev

This commit is contained in:
Lew Rossman
2018-11-07 23:19:16 -05:00
committed by GitHub
4 changed files with 83 additions and 36 deletions

View File

@@ -1,4 +1,3 @@
Release Notes for EPANET 2.2 (Draft)
============================
@@ -162,6 +161,35 @@ Both network files are available [here](https://doi.org/10.23719/1375314).
|`ENdeleterule` ||
|`ENsetnodeid` ||
|`ENsetlinkid` ||
|`ENgetcurvetype`|Get the type of a curve|
|`ENgetdemandmodel`|Retrieves the type of demand model in use and its parameters|
|`ENsetdemandmodel`|Sets the type of demand model to use and its parameters|
|`ENsetflowunits`|Sets the flow units|
|`ENaddcontrol`|Specify parameters to add a new simple control|
|`ENsetdemandpattern`|Sets the index of the demand pattern assigned to a node for a category index|
|`ENgetrule`|Gets the number of premises, true actions, and false actions and the priority of an existing rule-based control|
|`ENsetrulepriority`|Sets the priority of the existing rule-based control|
|`ENgetpremise`|Gets the components of a premise/condition in an existing rule-based control|
|`ENsetpremise`|Sets the components of a premise/condition in an existing rule-based control|
|`ENsetpremiseindex`|Sets the index of an object in a premise of an existing rule-based control|
|`ENsetpremisestatus`|Sets the status in a premise of an existing rule-based control|
|`ENsetpremisevalue`|Sets the value in a premise of an existing rule-based control|
|`ENgettrueaction`|Gets the components of a true-action in an existing rule-based control|
|`ENsettrueaction`|Sets the components of a true-action in an existing rule-based control|
|`ENgetfalseaction`|Gets the components of a false-action in an existing rule-based control|
|`ENsetfalseaction`|Sets the components of a false-action in an existing rule-based control|
|`ENgetruleID`|Returns the ID of a rule|
|`ENinit`|Initializes an EPANET session|
|`ENsetheadcurveindex`|Sets the curve id for a specified pump index|
|`ENsetlinktype`|Set the link type code for a specified link|
|`ENaddnode`|Adds a new node|
|`ENaddlink`|Adds a new link|
|`ENdeletelink`|Deletes a link|
|`ENdeletenode`|Deletes a node|
| `ENsetnodeid` |Change the ID name for a node|
| `ENsetlinkid` |Change the ID name for a link|
|`ENgetdemandname`|Sets the node's demand name for a category|
|`ENsetdemandname`|Sets the node's demand name for a category|
## API Extensions (additional definitions)
### Link value types:
@@ -178,10 +206,14 @@ Both network files are available [here](https://doi.org/10.23719/1375314).
- `EN_HW`
- `EN_DW`
- `EN_CM`
### Misc. options:
### Option types:
- `EN_HEADERROR`
- `EN_FLOWCHANGE`
- `EN_DEMANDDEFPAT`
- `EN_HEADLOSSFORM`
### Time statistic types:
- `EN_MAXHEADERROR`
- `EN_MAXFLOWCHANGE`
- `EN_MASSBALANCE`
- `EN_UNCONDITIONAL`
- `EN_CONDITIONAL`
@@ -191,6 +223,9 @@ Both network files are available [here](https://doi.org/10.23719/1375314).
- `EN_E_CURVE`
- `EN_H_CURVE`
- `EN_G_CURVE`
### Demand model types:
- `EN_DDA`
- `EN_PDA`
## Authors contributing to this release:
- List item

View File

@@ -3210,6 +3210,9 @@ int DLLEXPORT EN_setlinknodes(EN_ProjectHandle ph, int index, int node1, int nod
EN_Project *p = (EN_Project*)ph;
EN_Network *net = &p->network;
// Check that end and start nodes are not the same
if (node1 == node2) return set_error(p->error_handle, 222);
// Check that nodes exist
if (node1 < 0 || node1 > net->Nnodes) return set_error(p->error_handle, 203);
if (node2 < 0 || node2 > net->Nnodes) return set_error(p->error_handle, 203);

View File

@@ -29,29 +29,37 @@ using namespace std;
// Custom test to check the minimum number of correct decimal digits between
// the test and the ref vectors.
boost::test_tools::predicate_result check_cdd(std::vector<float>& test,
std::vector<float>& ref, long cdd_tol)
{
float tmp, min_cdd = 100.0;
std::vector<float>& ref, long cdd_tol){
float tmp, min_cdd = 10.0;
// TODO: What is the vectors aren't the same length?
// TODO: What if the vectors aren't the same length?
std::vector<float>::iterator test_it;
std::vector<float>::iterator ref_it;
for (test_it = test.begin(); test_it < test.end(); ++test_it) {
for (ref_it = ref.begin(); ref_it < ref.end(); ++ref_it) {
for (test_it = test.begin(), ref_it = ref.begin();
(test_it < test.end()) && (ref_it < ref.end());
++test_it, ++ref_it)
{
if (*test_it != *ref_it) {
tmp = - log10f(abs(*test_it - *ref_it));
if (tmp < min_cdd) min_cdd = tmp;
}
// Compute log absolute error
tmp = abs(*test_it - *ref_it);
if (tmp < 1.0e-7f)
tmp = 1.0e-7f;
else if (tmp > 2.0f)
tmp = 1.0f;
tmp = -log10(tmp);
if (tmp < 0.0f)
tmp = 0.0f;
if (tmp < min_cdd)
min_cdd = tmp;
}
}
if (min_cdd == 100.0)
return true;
else
return floor(min_cdd) <= cdd_tol;
return floor(min_cdd) >= cdd_tol;
}
boost::test_tools::predicate_result check_string(std::string test, std::string ref)

View File

@@ -36,6 +36,7 @@ EXPORTS
ENgetlinkid = _ENgetlinkid@8
ENgetlinkindex = _ENgetlinkindex@8
ENgetlinknodes = _ENgetlinknodes@12
ENsetlinknodes = _ENsetlinknodes@12
ENgetlinktype = _ENgetlinktype@8
ENgetlinkvalue = _ENgetlinkvalue@12
ENgetnodeid = _ENgetnodeid@8