hadar.optimizer package¶
Subpackages¶
Submodules¶
hadar.optimizer.input module¶
-
class
hadar.optimizer.input.
Consumption
(quantity: Union[List[T], numpy.ndarray, float], cost: Union[List[T], numpy.ndarray, float], name: str = '')¶ Bases:
hadar.optimizer.input.JSON
Consumption element.
-
static
from_json
(dict)¶
-
static
-
class
hadar.optimizer.input.
Link
(dest: str, quantity: Union[List[T], numpy.ndarray, float], cost: Union[List[T], numpy.ndarray, float])¶ Bases:
hadar.optimizer.input.JSON
Link element
-
static
from_json
(dict)¶
-
static
-
class
hadar.optimizer.input.
Production
(quantity: Union[List[T], numpy.ndarray, float], cost: Union[List[T], numpy.ndarray, float], name: str = 'in')¶ Bases:
hadar.optimizer.input.JSON
Production element
-
static
from_json
(dict)¶
-
static
-
class
hadar.optimizer.input.
Storage
(name, capacity: int, flow_in: float, flow_out: float, cost: float = 0, init_capacity: int = 0, eff: float = 0.99)¶ Bases:
hadar.optimizer.input.JSON
Storage element
-
static
from_json
(dict)¶
-
static
-
class
hadar.optimizer.input.
Converter
(name: str, src_ratios: Dict[Tuple[str, str], float], dest_network: str, dest_node: str, cost: float, max: float)¶ Bases:
hadar.optimizer.input.JSON
Converter element
-
static
from_json
(dict: dict)¶
-
to_json
() → dict¶
-
static
-
class
hadar.optimizer.input.
InputNetwork
(nodes: Dict[str, hadar.optimizer.input.InputNode] = None)¶ Bases:
hadar.optimizer.input.JSON
Network element
-
static
from_json
(dict)¶
-
static
-
class
hadar.optimizer.input.
InputNode
(consumptions: List[hadar.optimizer.input.Consumption], productions: List[hadar.optimizer.input.Production], storages: List[hadar.optimizer.input.Storage], links: List[hadar.optimizer.input.Link])¶ Bases:
hadar.optimizer.input.JSON
Node element
-
static
from_json
(dict)¶
-
static
-
class
hadar.optimizer.input.
Study
(horizon: int, nb_scn: int = 1, version: str = None)¶ Bases:
hadar.optimizer.input.JSON
Main object to facilitate to build a study
-
add_link
(network: str, src: str, dest: str, cost: int, quantity: Union[List[float], numpy.ndarray, float])¶ Add a link inside network.
Parameters: - network – network where nodes belong
- src – source node name
- dest – destination node name
- cost – cost of use
- quantity – transfer capacity
Returns:
-
add_network
(network: str)¶
-
add_node
(network: str, node: str)¶
-
static
from_json
(dict)¶
-
network
(name='default')¶ Entry point to create study with the fluent api.
Returns:
-
-
class
hadar.optimizer.input.
NetworkFluentAPISelector
(study, selector)¶ Bases:
object
Network level of Fluent API Selector.
-
build
()¶ Build study.
Returns: return study
-
converter
(name: str, to_network: str, to_node: str, max: float, cost: float = 0)¶ Add a converter element.
Parameters: - name – converter name
- to_network – converter output network
- to_node – converter output node on network
- max – maximum quantity from converter
- cost – cost for each quantity produce by converter
Returns:
-
link
(src: str, dest: str, cost: int, quantity: Union[List[T], numpy.ndarray, float])¶ Add a link on network.
Parameters: - src – node source
- dest – node destination
- cost – unit cost transfer
- quantity – available capacity
Returns: NetworkAPISelector with new link.
-
network
(name='default')¶ Go to network level.
Parameters: name – network level, ‘default’ as default name Returns: NetworkAPISelector with selector set to ‘default’
-
node
(name)¶ Go to node level.
Parameters: name – node to select when changing level Returns: NodeFluentAPISelector initialized
-
-
class
hadar.optimizer.input.
NodeFluentAPISelector
(study, selector)¶ Bases:
object
Node level of Fluent API Selector
-
build
()¶ Build study.
Returns: study
-
consumption
(name: str, cost: int, quantity: Union[List[T], numpy.ndarray, float])¶ Add consumption on node.
Parameters: - name – consumption name
- cost – cost of unsuitability
- quantity – consumption to sustain
Returns: NodeFluentAPISelector with new consumption
-
converter
(name: str, to_network: str, to_node: str, max: float, cost: float = 0)¶ Add a converter element.
Parameters: - name – converter name
- to_network – converter output network
- to_node – converter output node on network
- max – maximum quantity from converter
- cost – cost for each quantity produce by converter
Returns:
-
link
(src: str, dest: str, cost: int, quantity: Union[List[T], numpy.ndarray, float])¶ Add a link on network.
Parameters: - src – node source
- dest – node destination
- cost – unit cost transfer
- quantity – available capacity
Returns: NetworkAPISelector with new link.
-
network
(name='default')¶ Go to network level.
Parameters: name – network level, ‘default’ as default name Returns: NetworkAPISelector with selector set to ‘default’
-
node
(name)¶ Go to different node level.
Parameters: name – new node level Returns: NodeFluentAPISelector
-
production
(name: str, cost: int, quantity: Union[List[T], numpy.ndarray, float])¶ Add production on node.
Parameters: - name – production name
- cost – unit cost of use
- quantity – available capacities
Returns: NodeFluentAPISelector with new production
-
storage
(name, capacity: int, flow_in: float, flow_out: float, cost: float = 0, init_capacity: int = 0, eff: int = 0.99)¶ Create storage.
Parameters: - capacity – maximum storage capacity (like of many quantity to use inside storage)
- flow_in – max flow into storage during on time step
- flow_out – max flow out storage during on time step
- cost – unit cost of storage at each time-step. default 0
- init_capacity – initial capacity level. default 0
- eff – storage efficient (applied on input flow stored). default 0.99
-
to_converter
(name: str, ratio: float = 1)¶ Add an ouptput to converter.
Parameters: - name – converter name
- ratio – ratio for output
Returns:
-
hadar.optimizer.optimizer module¶
-
class
hadar.optimizer.optimizer.
LPOptimizer
¶ Bases:
hadar.optimizer.optimizer.Optimizer
Basic Optimizer works with linear programming.
-
solve
(study: hadar.optimizer.input.Study) → hadar.optimizer.output.Result¶ Solve adequacy study.
Parameters: study – study to resolve Returns: study’s result
-
-
class
hadar.optimizer.optimizer.
RemoteOptimizer
(url: str, token: str = '')¶ Bases:
hadar.optimizer.optimizer.Optimizer
Use a remote optimizer to compute on cloud.
-
solve
(study: hadar.optimizer.input.Study) → hadar.optimizer.output.Result¶ Solve adequacy study.
Parameters: study – study to resolve Returns: study’s result
-
hadar.optimizer.output module¶
-
class
hadar.optimizer.output.
OutputProduction
(quantity: Union[numpy.ndarray, list], cost: Union[numpy.ndarray, list], name: str = 'in')¶ Bases:
hadar.optimizer.input.JSON
Production element
-
static
from_json
(dict)¶
-
static
-
class
hadar.optimizer.output.
OutputNode
(consumptions: List[hadar.optimizer.output.OutputConsumption], productions: List[hadar.optimizer.output.OutputProduction], storages: List[hadar.optimizer.output.OutputStorage], links: List[hadar.optimizer.output.OutputLink])¶ Bases:
hadar.optimizer.input.JSON
Node element
-
static
build_like_input
(input: hadar.optimizer.input.InputNode, fill: numpy.ndarray)¶ Use an input node to create an output node. Keep list elements fill quantity by zeros.
Parameters: - input – InputNode to copy
- fill – array to use to fill data
Returns: OutputNode like InputNode with all quantity at zero
-
static
from_json
(dict)¶
-
static
-
class
hadar.optimizer.output.
OutputStorage
(name: str, capacity: Union[numpy.ndarray, list], flow_in: Union[numpy.ndarray, list], flow_out: Union[numpy.ndarray, list])¶ Bases:
hadar.optimizer.input.JSON
Storage element
-
static
from_json
(dict)¶
-
static
-
class
hadar.optimizer.output.
OutputLink
(dest: str, quantity: Union[numpy.ndarray, list], cost: Union[numpy.ndarray, list])¶ Bases:
hadar.optimizer.input.JSON
Link element
-
static
from_json
(dict)¶
-
static
-
class
hadar.optimizer.output.
OutputConsumption
(quantity: Union[numpy.ndarray, list], cost: Union[numpy.ndarray, list], name: str = '')¶ Bases:
hadar.optimizer.input.JSON
Consumption element
-
static
from_json
(dict)¶
-
static
-
class
hadar.optimizer.output.
OutputNetwork
(nodes: Dict[str, hadar.optimizer.output.OutputNode])¶ Bases:
hadar.optimizer.input.JSON
Network element
-
static
from_json
(dict)¶
-
static