-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add binary and/or integer variables #187
Comments
This is the first commit of using the Highs solver to model binary variables, and using those variables to apply a mutual exclusivity constraint. I.e. flow is allow through up to N nodes at a time. TODO: - [ ] Add support in pywr-schema. - [ ] Implement in CLP/CBC solver. - [ ] Add additional tests. This starts to resolve issue #187.
This is the first commit of using the Highs solver to model binary variables, and using those variables to apply a mutual exclusivity constraint. I.e. flow is allow through up to N nodes at a time. TODO: - [ ] Add support in pywr-schema. - [ ] Implement in CLP/CBC solver. - [ ] Add additional tests. This starts to resolve issue #187.
This is the first commit of using the Highs solver to model binary variables, and using those variables to apply a mutual exclusivity constraint. I.e. flow is allow through up to N nodes at a time. TODO: - [ ] Add support in pywr-schema. - [ ] Implement in CLP/CBC solver. - [ ] Add additional tests. This starts to resolve issue #187.
See below for a suggestion on this. Here we use the #[derive(serde::Deserialize, serde::Serialize, Clone, Debug, JsonSchema, PywrVisitAll)]
#[serde(tag = "type")]
pub enum Factors {
Proportion {
factors: Vec<Metric>,
},
Ratio {
factors: Vec<Metric>,
},
/// Flows are exclusive with at least `min` and at most `max` nodes active.
Exclusive {
min: Option<usize>,
max: Option<usize>,
},
}
#[derive(serde::Deserialize, serde::Serialize, Clone, Default, Debug, JsonSchema, PywrVisitAll)]
pub struct AggregatedNode {
#[serde(flatten)]
pub meta: NodeMeta,
pub nodes: Vec<String>,
pub max_flow: Option<Metric>,
pub min_flow: Option<Metric>,
pub factors: Option<Factors>,
} |
This is the first commit of using the Highs solver to model binary variables, and using those variables to apply a mutual exclusivity constraint. I.e. flow is allow through up to N nodes at a time. TODO: - [ ] Add support in pywr-schema. - [ ] Implement in CLP/CBC solver. - [ ] Add additional tests. This starts to resolve issue #187.
This is the initial support for using binary variables to apply a mutual exclusivity constraint. I.e. flow is allow through up to N nodes at a time. Aggregated node is refactored to allow support for sets of nodes. These are typically created when a compound node (e.g. PiecewiseLink) is added to an AggregatedNode. The compound node creates multiple "core" nodes, and these should all be constrained by the AggregatedNode's factors or exclusivity. The same consideration applies to the virtual storage nodes. To do this there is a new method on Node in the schema to retrieve the core node indices which that node has added to the core model. For now this is a static implementation, but there are some nodes which the user may to configure how this is done. E.g. should a LossLink be constrained on its net or gross flow. Renames aggregated node `Factors` to `Relationship`. This starts to resolve issue #187.
Link to the Pywr v1.x issue: pywr/pywr#702
Following use cases
Discrete flow
The flow in a given edge should only be a discrete value. For example, 0 or 10.0 (but no other value). This will require adding a binary (or integer) value and relating it to the capacity constraints.
Current max capacity constraint:$x_e \le b_e^{max}$
With discrete variable:$x_e - x_e^b b_e^{max} = 0$
The min flow constraints will be similar.
The user should be able to associate a cost with the variable. However, the units might get confusing.
Mutually exclusive flows
There can only be flow in one edge from a given set. This will require two new constraints to be added. The first is the same as above where the flow capacity is constrained by a new variable$x_e^b$ . Then a second constraint is added which ensures that only one of the binaries can "on": $\sum_{e \in E} x_e \le 1$ . An alternative could be an equality constraint to require one of the set to be active.
If this is implemented it would allow a more correct minimum flow to be set when configuring a bi-directional transfer.
Schema
How would this look to the user? Ideally we would have a
DiscreteLink
or similar node that defined the discrete flow requirement. The mutual exclusivity one is similar to an aggregated node, and perhaps could be an optional field onAggregatedNode
that, if defined, would create the additional constraints.Implementation challenges
isActive
for the newDiscreteLink
) for use in the model and/or output.The text was updated successfully, but these errors were encountered: