In this example, you learn to use ResultAnalyzer. You has already use it in preivous example to instanciate plotting: agg = hd.ResultAnalyzer(study, result)
ResultAnalyzer
agg = hd.ResultAnalyzer(study, result)
Let’s begin by build little study with two nodes (A and B) both has a sinus-like load from 1500 to 500. Node A has a constant nuclear plan, node B has eolien with linear random.
import hadar as hd import numpy as np import pandas as pd
t = np.linspace(0, np.pi * 14, 168) load = 1000 + np.sin(t) * 500 eolien = np.random.rand(t.size) * 1000
study = hd.Study(horizon=t.size, nb_scn=1)\ .network()\ .node('a')\ .consumption(name='load', cost=10 ** 6, quantity=load)\ .production(name='nuclear', cost=100, quantity=1500)\ .node('b')\ .consumption(name='load', cost=10 ** 6, quantity=load)\ .production(name='eolien', cost=50, quantity=eolien)\ .link(src='a', dest='b', cost=5, quantity=2000)\ .link(src='b', dest='a', cost=5, quantity=2000)\ .build()
opt = hd.LPOptimizer() res = opt.solve(study)
agg = hd.ResultAnalyzer(study=study, result=res)
Analyzer provide a low api, that means result could not be ready-to-use, but it’s a very flexible way to analyze data. Low API enable to thinks: - set order. data has for level : node, element, scn and time. Low API can organize for your these level - filtering: for each level you can apply a filter, to only select node ‘a’, or time from 10 to 35 timestep
For examples you want select consumption named load other all node just for 57 to 78 timestep
agg.network().scn(0).consumption('load').node().time(slice(57, 78))
TIP If filter return only one element, set it at first. First indexes with one element are removed to avoir useless indexes.
Another example: Analyze all production first 24 timestep
agg.network().scn(0).node().production().time(slice(0,24))
To summrize low api, you can organize and filter data by network, scenarios, time, node and elements on node.
High API is ready to use data. It gives you a business oriented data about adequacy. Today we have: - Get balance to compute net position on a node - Get cost to compute cost on a node - Get Remain Available Capacities
import plotly.graph_objects as go
def plot(y): return go.Figure(go.Scatter(x=t, y=y.flatten()))
data = agg.get_balance(node='a') # Compute net exchange for all scenario and timestep plot(data)