partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | PSATReader.push_line | Adds a Branch object to the case. | pylon/io/psat.py | def push_line(self, tokens):
""" Adds a Branch object to the case.
"""
logger.debug("Pushing line data: %s" % tokens)
from_bus = self.case.buses[tokens["fbus"]-1]
to_bus = self.case.buses[tokens["tbus"]-1]
e = Branch(from_bus=from_bus, to_bus=to_bus)
e.r = token... | def push_line(self, tokens):
""" Adds a Branch object to the case.
"""
logger.debug("Pushing line data: %s" % tokens)
from_bus = self.case.buses[tokens["fbus"]-1]
to_bus = self.case.buses[tokens["tbus"]-1]
e = Branch(from_bus=from_bus, to_bus=to_bus)
e.r = token... | [
"Adds",
"a",
"Branch",
"object",
"to",
"the",
"case",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/psat.py#L390-L415 | [
"def",
"push_line",
"(",
"self",
",",
"tokens",
")",
":",
"logger",
".",
"debug",
"(",
"\"Pushing line data: %s\"",
"%",
"tokens",
")",
"from_bus",
"=",
"self",
".",
"case",
".",
"buses",
"[",
"tokens",
"[",
"\"fbus\"",
"]",
"-",
"1",
"]",
"to_bus",
"=... | 916514255db1ae1661406f0283df756baf960d14 |
train | PSATReader.push_slack | Finds the slack bus, adds a Generator with the appropriate data
and sets the bus type to slack. | pylon/io/psat.py | def push_slack(self, tokens):
""" Finds the slack bus, adds a Generator with the appropriate data
and sets the bus type to slack.
"""
logger.debug("Pushing slack data: %s" % tokens)
bus = self.case.buses[tokens["bus_no"] - 1]
g = Generator(bus)
g.q_max = tokens[... | def push_slack(self, tokens):
""" Finds the slack bus, adds a Generator with the appropriate data
and sets the bus type to slack.
"""
logger.debug("Pushing slack data: %s" % tokens)
bus = self.case.buses[tokens["bus_no"] - 1]
g = Generator(bus)
g.q_max = tokens[... | [
"Finds",
"the",
"slack",
"bus",
"adds",
"a",
"Generator",
"with",
"the",
"appropriate",
"data",
"and",
"sets",
"the",
"bus",
"type",
"to",
"slack",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/psat.py#L418-L435 | [
"def",
"push_slack",
"(",
"self",
",",
"tokens",
")",
":",
"logger",
".",
"debug",
"(",
"\"Pushing slack data: %s\"",
"%",
"tokens",
")",
"bus",
"=",
"self",
".",
"case",
".",
"buses",
"[",
"tokens",
"[",
"\"bus_no\"",
"]",
"-",
"1",
"]",
"g",
"=",
"... | 916514255db1ae1661406f0283df756baf960d14 |
train | PSATReader.push_pv | Creates and Generator object, populates it with data, finds its Bus
and adds it. | pylon/io/psat.py | def push_pv(self, tokens):
""" Creates and Generator object, populates it with data, finds its Bus
and adds it.
"""
logger.debug("Pushing PV data: %s" % tokens)
bus = self.case.buses[tokens["bus_no"]-1]
g = Generator(bus)
g.p = tokens["p"]
g.q_max = toke... | def push_pv(self, tokens):
""" Creates and Generator object, populates it with data, finds its Bus
and adds it.
"""
logger.debug("Pushing PV data: %s" % tokens)
bus = self.case.buses[tokens["bus_no"]-1]
g = Generator(bus)
g.p = tokens["p"]
g.q_max = toke... | [
"Creates",
"and",
"Generator",
"object",
"populates",
"it",
"with",
"data",
"finds",
"its",
"Bus",
"and",
"adds",
"it",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/psat.py#L438-L454 | [
"def",
"push_pv",
"(",
"self",
",",
"tokens",
")",
":",
"logger",
".",
"debug",
"(",
"\"Pushing PV data: %s\"",
"%",
"tokens",
")",
"bus",
"=",
"self",
".",
"case",
".",
"buses",
"[",
"tokens",
"[",
"\"bus_no\"",
"]",
"-",
"1",
"]",
"g",
"=",
"Genera... | 916514255db1ae1661406f0283df756baf960d14 |
train | PSATReader.push_pq | Creates and Load object, populates it with data, finds its Bus and
adds it. | pylon/io/psat.py | def push_pq(self, tokens):
""" Creates and Load object, populates it with data, finds its Bus and
adds it.
"""
logger.debug("Pushing PQ data: %s" % tokens)
bus = self.case.buses[tokens["bus_no"] - 1]
bus.p_demand = tokens["p"]
bus.q_demand = tokens["q"] | def push_pq(self, tokens):
""" Creates and Load object, populates it with data, finds its Bus and
adds it.
"""
logger.debug("Pushing PQ data: %s" % tokens)
bus = self.case.buses[tokens["bus_no"] - 1]
bus.p_demand = tokens["p"]
bus.q_demand = tokens["q"] | [
"Creates",
"and",
"Load",
"object",
"populates",
"it",
"with",
"data",
"finds",
"its",
"Bus",
"and",
"adds",
"it",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/psat.py#L457-L465 | [
"def",
"push_pq",
"(",
"self",
",",
"tokens",
")",
":",
"logger",
".",
"debug",
"(",
"\"Pushing PQ data: %s\"",
"%",
"tokens",
")",
"bus",
"=",
"self",
".",
"case",
".",
"buses",
"[",
"tokens",
"[",
"\"bus_no\"",
"]",
"-",
"1",
"]",
"bus",
".",
"p_de... | 916514255db1ae1661406f0283df756baf960d14 |
train | PSATReader.push_supply | Adds OPF and CPF data to a Generator. | pylon/io/psat.py | def push_supply(self, tokens):
""" Adds OPF and CPF data to a Generator.
"""
logger.debug("Pushing supply data: %s" % tokens)
bus = self.case.buses[tokens["bus_no"] - 1]
n_generators = len([g for g in self.case.generators if g.bus == bus])
if n_generators == 0:
... | def push_supply(self, tokens):
""" Adds OPF and CPF data to a Generator.
"""
logger.debug("Pushing supply data: %s" % tokens)
bus = self.case.buses[tokens["bus_no"] - 1]
n_generators = len([g for g in self.case.generators if g.bus == bus])
if n_generators == 0:
... | [
"Adds",
"OPF",
"and",
"CPF",
"data",
"to",
"a",
"Generator",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/psat.py#L493-L518 | [
"def",
"push_supply",
"(",
"self",
",",
"tokens",
")",
":",
"logger",
".",
"debug",
"(",
"\"Pushing supply data: %s\"",
"%",
"tokens",
")",
"bus",
"=",
"self",
".",
"case",
".",
"buses",
"[",
"tokens",
"[",
"\"bus_no\"",
"]",
"-",
"1",
"]",
"n_generators... | 916514255db1ae1661406f0283df756baf960d14 |
train | MATPOWERReader._parse_file | Parses the given file-like object. | pylon/io/matpower.py | def _parse_file(self, file):
""" Parses the given file-like object.
"""
case = Case()
file.seek(0)
line = file.readline().split()
if line[0] != "function":
logger.error("Invalid data file header.")
return case
if line[1] != "mpc":
... | def _parse_file(self, file):
""" Parses the given file-like object.
"""
case = Case()
file.seek(0)
line = file.readline().split()
if line[0] != "function":
logger.error("Invalid data file header.")
return case
if line[1] != "mpc":
... | [
"Parses",
"the",
"given",
"file",
"-",
"like",
"object",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/matpower.py#L95-L125 | [
"def",
"_parse_file",
"(",
"self",
",",
"file",
")",
":",
"case",
"=",
"Case",
"(",
")",
"file",
".",
"seek",
"(",
"0",
")",
"line",
"=",
"file",
".",
"readline",
"(",
")",
".",
"split",
"(",
")",
"if",
"line",
"[",
"0",
"]",
"!=",
"\"function\... | 916514255db1ae1661406f0283df756baf960d14 |
train | MATPOWERWriter.write | Writes case data to file in MATPOWER format. | pylon/io/matpower.py | def write(self, file_or_filename):
""" Writes case data to file in MATPOWER format.
"""
if isinstance(file_or_filename, basestring):
self._fcn_name, _ = splitext(basename(file_or_filename))
else:
self._fcn_name = self.case.name
self._fcn_name = self._fcn_... | def write(self, file_or_filename):
""" Writes case data to file in MATPOWER format.
"""
if isinstance(file_or_filename, basestring):
self._fcn_name, _ = splitext(basename(file_or_filename))
else:
self._fcn_name = self.case.name
self._fcn_name = self._fcn_... | [
"Writes",
"case",
"data",
"to",
"file",
"in",
"MATPOWER",
"format",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/matpower.py#L748-L758 | [
"def",
"write",
"(",
"self",
",",
"file_or_filename",
")",
":",
"if",
"isinstance",
"(",
"file_or_filename",
",",
"basestring",
")",
":",
"self",
".",
"_fcn_name",
",",
"_",
"=",
"splitext",
"(",
"basename",
"(",
"file_or_filename",
")",
")",
"else",
":",
... | 916514255db1ae1661406f0283df756baf960d14 |
train | MATPOWERWriter.write_case_data | Writes the case data in MATPOWER format. | pylon/io/matpower.py | def write_case_data(self, file):
""" Writes the case data in MATPOWER format.
"""
file.write("function mpc = %s\n" % self._fcn_name)
file.write('\n%%%% MATPOWER Case Format : Version %d\n' % 2)
file.write("mpc.version = '%d';\n" % 2)
file.write("\n%%%%----- Power Flow D... | def write_case_data(self, file):
""" Writes the case data in MATPOWER format.
"""
file.write("function mpc = %s\n" % self._fcn_name)
file.write('\n%%%% MATPOWER Case Format : Version %d\n' % 2)
file.write("mpc.version = '%d';\n" % 2)
file.write("\n%%%%----- Power Flow D... | [
"Writes",
"the",
"case",
"data",
"in",
"MATPOWER",
"format",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/matpower.py#L767-L776 | [
"def",
"write_case_data",
"(",
"self",
",",
"file",
")",
":",
"file",
".",
"write",
"(",
"\"function mpc = %s\\n\"",
"%",
"self",
".",
"_fcn_name",
")",
"file",
".",
"write",
"(",
"'\\n%%%% MATPOWER Case Format : Version %d\\n'",
"%",
"2",
")",
"file",
".",
"w... | 916514255db1ae1661406f0283df756baf960d14 |
train | MATPOWERWriter.write_bus_data | Writes bus data in MATPOWER format. | pylon/io/matpower.py | def write_bus_data(self, file):
""" Writes bus data in MATPOWER format.
"""
# labels = ["bus_id", "type", "Pd", "Qd", "Gs", "Bs", "area", "Vm", "Va",
# "baseKV", "Vmax", "Vmin"]
bus_attrs = ["_i", "type", "p_demand", "q_demand", "g_shunt","b_shunt",
"area", "v_magn... | def write_bus_data(self, file):
""" Writes bus data in MATPOWER format.
"""
# labels = ["bus_id", "type", "Pd", "Qd", "Gs", "Bs", "area", "Vm", "Va",
# "baseKV", "Vmax", "Vmin"]
bus_attrs = ["_i", "type", "p_demand", "q_demand", "g_shunt","b_shunt",
"area", "v_magn... | [
"Writes",
"bus",
"data",
"in",
"MATPOWER",
"format",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/matpower.py#L779-L804 | [
"def",
"write_bus_data",
"(",
"self",
",",
"file",
")",
":",
"# labels = [\"bus_id\", \"type\", \"Pd\", \"Qd\", \"Gs\", \"Bs\", \"area\", \"Vm\", \"Va\",",
"# \"baseKV\", \"Vmax\", \"Vmin\"]",
"bus_attrs",
"=",
"[",
"\"_i\"",
",",
"\"type\"",
",",
"\"p_demand\"",
... | 916514255db1ae1661406f0283df756baf960d14 |
train | MATPOWERWriter.write_generator_data | Writes generator data in MATPOWER format. | pylon/io/matpower.py | def write_generator_data(self, file):
""" Writes generator data in MATPOWER format.
"""
gen_attr = ["p", "q", "q_max", "q_min", "v_magnitude",
"base_mva", "online", "p_max", "p_min", "mu_pmax", "mu_pmin",
"mu_qmax", "mu_qmin"]
file.write("\n%%%% generator data\n"... | def write_generator_data(self, file):
""" Writes generator data in MATPOWER format.
"""
gen_attr = ["p", "q", "q_max", "q_min", "v_magnitude",
"base_mva", "online", "p_max", "p_min", "mu_pmax", "mu_pmin",
"mu_qmax", "mu_qmin"]
file.write("\n%%%% generator data\n"... | [
"Writes",
"generator",
"data",
"in",
"MATPOWER",
"format",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/matpower.py#L808-L826 | [
"def",
"write_generator_data",
"(",
"self",
",",
"file",
")",
":",
"gen_attr",
"=",
"[",
"\"p\"",
",",
"\"q\"",
",",
"\"q_max\"",
",",
"\"q_min\"",
",",
"\"v_magnitude\"",
",",
"\"base_mva\"",
",",
"\"online\"",
",",
"\"p_max\"",
",",
"\"p_min\"",
",",
"\"mu... | 916514255db1ae1661406f0283df756baf960d14 |
train | MATPOWERWriter.write_branch_data | Writes branch data to file. | pylon/io/matpower.py | def write_branch_data(self, file):
""" Writes branch data to file.
"""
branch_attr = ["r", "x", "b", "rate_a", "rate_b", "rate_c",
"ratio", "phase_shift", "online", "ang_min", "ang_max", "p_from",
"q_from", "p_to", "q_to", "mu_s_from", "mu_s_to", "mu_angmin",
... | def write_branch_data(self, file):
""" Writes branch data to file.
"""
branch_attr = ["r", "x", "b", "rate_a", "rate_b", "rate_c",
"ratio", "phase_shift", "online", "ang_min", "ang_max", "p_from",
"q_from", "p_to", "q_to", "mu_s_from", "mu_s_to", "mu_angmin",
... | [
"Writes",
"branch",
"data",
"to",
"file",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/matpower.py#L829-L855 | [
"def",
"write_branch_data",
"(",
"self",
",",
"file",
")",
":",
"branch_attr",
"=",
"[",
"\"r\"",
",",
"\"x\"",
",",
"\"b\"",
",",
"\"rate_a\"",
",",
"\"rate_b\"",
",",
"\"rate_c\"",
",",
"\"ratio\"",
",",
"\"phase_shift\"",
",",
"\"online\"",
",",
"\"ang_mi... | 916514255db1ae1661406f0283df756baf960d14 |
train | MATPOWERWriter.write_generator_cost_data | Writes generator cost data to file. | pylon/io/matpower.py | def write_generator_cost_data(self, file):
""" Writes generator cost data to file.
"""
file.write("\n%%%% generator cost data\n")
file.write("%%\t1\tstartup\tshutdown\tn\tx1\ty1\t...\txn\tyn\n")
file.write("%%\t2\tstartup\tshutdown\tn\tc(n-1)\t...\tc0\n")
file.write("%sge... | def write_generator_cost_data(self, file):
""" Writes generator cost data to file.
"""
file.write("\n%%%% generator cost data\n")
file.write("%%\t1\tstartup\tshutdown\tn\tx1\ty1\t...\txn\tyn\n")
file.write("%%\t2\tstartup\tshutdown\tn\tc(n-1)\t...\tc0\n")
file.write("%sge... | [
"Writes",
"generator",
"cost",
"data",
"to",
"file",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/matpower.py#L858-L888 | [
"def",
"write_generator_cost_data",
"(",
"self",
",",
"file",
")",
":",
"file",
".",
"write",
"(",
"\"\\n%%%% generator cost data\\n\"",
")",
"file",
".",
"write",
"(",
"\"%%\\t1\\tstartup\\tshutdown\\tn\\tx1\\ty1\\t...\\txn\\tyn\\n\"",
")",
"file",
".",
"write",
"(",
... | 916514255db1ae1661406f0283df756baf960d14 |
train | MATPOWERWriter.write_area_data | Writes area data to file. | pylon/io/matpower.py | def write_area_data(self, file):
""" Writes area data to file.
"""
file.write("%% area data" + "\n")
file.write("%\tno.\tprice_ref_bus" + "\n")
file.write("areas = [" + "\n")
# TODO: Implement areas
file.write("\t1\t1;" + "\n")
file.write("];" + "\n") | def write_area_data(self, file):
""" Writes area data to file.
"""
file.write("%% area data" + "\n")
file.write("%\tno.\tprice_ref_bus" + "\n")
file.write("areas = [" + "\n")
# TODO: Implement areas
file.write("\t1\t1;" + "\n")
file.write("];" + "\n") | [
"Writes",
"area",
"data",
"to",
"file",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/matpower.py#L906-L915 | [
"def",
"write_area_data",
"(",
"self",
",",
"file",
")",
":",
"file",
".",
"write",
"(",
"\"%% area data\"",
"+",
"\"\\n\"",
")",
"file",
".",
"write",
"(",
"\"%\\tno.\\tprice_ref_bus\"",
"+",
"\"\\n\"",
")",
"file",
".",
"write",
"(",
"\"areas = [\"",
"+",
... | 916514255db1ae1661406f0283df756baf960d14 |
train | MetricBase.process_file | Initiate processing for each token.
Override this if you want tt control the processing of the tokens yourself. | metrics/metricbase.py | def process_file(self, language, key, token_list):
"""
Initiate processing for each token.
Override this if you want tt control the processing of the tokens yourself.
"""
self.language = language
for tok in token_list:
self.process_token(tok) | def process_file(self, language, key, token_list):
"""
Initiate processing for each token.
Override this if you want tt control the processing of the tokens yourself.
"""
self.language = language
for tok in token_list:
self.process_token(tok) | [
"Initiate",
"processing",
"for",
"each",
"token",
"."
] | finklabs/metrics | python | https://github.com/finklabs/metrics/blob/fd9974af498831664b9ae8e8f3834e1ec2e8a699/metrics/metricbase.py#L26-L34 | [
"def",
"process_file",
"(",
"self",
",",
"language",
",",
"key",
",",
"token_list",
")",
":",
"self",
".",
"language",
"=",
"language",
"for",
"tok",
"in",
"token_list",
":",
"self",
".",
"process_token",
"(",
"tok",
")"
] | fd9974af498831664b9ae8e8f3834e1ec2e8a699 |
train | ExperimentRenderer.updateData | Updates the data used by the renderer. | pyreto/renderer.py | def updateData(self, data):
""" Updates the data used by the renderer.
"""
# pylab.ion()
fig = pylab.figure(1)
n_agent = len(data)
idx = 1
for i, adata in enumerate(data):
saxis = fig.add_subplot(3, n_agent, i + 1)
saxis.plot(adata[0])
... | def updateData(self, data):
""" Updates the data used by the renderer.
"""
# pylab.ion()
fig = pylab.figure(1)
n_agent = len(data)
idx = 1
for i, adata in enumerate(data):
saxis = fig.add_subplot(3, n_agent, i + 1)
saxis.plot(adata[0])
... | [
"Updates",
"the",
"data",
"used",
"by",
"the",
"renderer",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pyreto/renderer.py#L53-L75 | [
"def",
"updateData",
"(",
"self",
",",
"data",
")",
":",
"# pylab.ion()",
"fig",
"=",
"pylab",
".",
"figure",
"(",
"1",
")",
"n_agent",
"=",
"len",
"(",
"data",
")",
"idx",
"=",
"1",
"for",
"i",
",",
"adata",
"in",
"enumerate",
"(",
"data",
... | 916514255db1ae1661406f0283df756baf960d14 |
train | ParticipantRenderer.updateData | Updates the data used by the renderer. | pyreto/renderer.py | def updateData(self, state_data, action_data, reward_data):
""" Updates the data used by the renderer.
"""
# self.dataLock.acquire()
self.state_data[:, self.updates] = state_data
self.action_data[:, self.updates] = action_data
self.reward_data[0, self.updates] = reward_da... | def updateData(self, state_data, action_data, reward_data):
""" Updates the data used by the renderer.
"""
# self.dataLock.acquire()
self.state_data[:, self.updates] = state_data
self.action_data[:, self.updates] = action_data
self.reward_data[0, self.updates] = reward_da... | [
"Updates",
"the",
"data",
"used",
"by",
"the",
"renderer",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pyreto/renderer.py#L144-L153 | [
"def",
"updateData",
"(",
"self",
",",
"state_data",
",",
"action_data",
",",
"reward_data",
")",
":",
"# self.dataLock.acquire()",
"self",
".",
"state_data",
"[",
":",
",",
"self",
".",
"updates",
"]",
"=",
"state_data",
"self",
".",
"action_data",
"["... | 916514255db1ae1661406f0283df756baf960d14 |
train | ParticipantRenderer.draw_plot | Initialises plots of the environment. | pyreto/renderer.py | def draw_plot(self):
""" Initialises plots of the environment.
"""
pylab.ion()
fig = pylab.figure(1)
# State plot.
# state_axis = fig.add_subplot(3, 1, 1) # numrows, numcols, fignum
# state_axis.title = 'State'
# state_axis.xlabel = 'Time (hours)'
# s... | def draw_plot(self):
""" Initialises plots of the environment.
"""
pylab.ion()
fig = pylab.figure(1)
# State plot.
# state_axis = fig.add_subplot(3, 1, 1) # numrows, numcols, fignum
# state_axis.title = 'State'
# state_axis.xlabel = 'Time (hours)'
# s... | [
"Initialises",
"plots",
"of",
"the",
"environment",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pyreto/renderer.py#L177-L211 | [
"def",
"draw_plot",
"(",
"self",
")",
":",
"pylab",
".",
"ion",
"(",
")",
"fig",
"=",
"pylab",
".",
"figure",
"(",
"1",
")",
"# State plot.",
"# state_axis = fig.add_subplot(3, 1, 1) # numrows, numcols, fignum",
"# state_axis.title = 'State'",
"# stat... | 916514255db1ae1661406f0283df756baf960d14 |
train | generate | :param ast_tree: AST to generate from
:param model_name: class to generate
:return: sympy source code for model | src/pymoca/backends/xml/generator.py | def generate(ast_tree: ast.Tree, model_name: str):
"""
:param ast_tree: AST to generate from
:param model_name: class to generate
:return: sympy source code for model
"""
component_ref = ast.ComponentRef.from_string(model_name)
ast_tree_new = copy.deepcopy(ast_tree)
ast_walker = TreeWalk... | def generate(ast_tree: ast.Tree, model_name: str):
"""
:param ast_tree: AST to generate from
:param model_name: class to generate
:return: sympy source code for model
"""
component_ref = ast.ComponentRef.from_string(model_name)
ast_tree_new = copy.deepcopy(ast_tree)
ast_walker = TreeWalk... | [
":",
"param",
"ast_tree",
":",
"AST",
"to",
"generate",
"from",
":",
"param",
"model_name",
":",
"class",
"to",
"generate",
":",
"return",
":",
"sympy",
"source",
"code",
"for",
"model"
] | pymoca/pymoca | python | https://github.com/pymoca/pymoca/blob/14b5eb7425e96689de6cc5c10f400895d586a978/src/pymoca/backends/xml/generator.py#L144-L156 | [
"def",
"generate",
"(",
"ast_tree",
":",
"ast",
".",
"Tree",
",",
"model_name",
":",
"str",
")",
":",
"component_ref",
"=",
"ast",
".",
"ComponentRef",
".",
"from_string",
"(",
"model_name",
")",
"ast_tree_new",
"=",
"copy",
".",
"deepcopy",
"(",
"ast_tree... | 14b5eb7425e96689de6cc5c10f400895d586a978 |
train | plot | Plot simulation data.
:data: A dictionary of arrays.
:fields: A list of variables you want to plot (e.g. ['x', y', 'c']) | src/pymoca/backends/xml/analysis.py | def plot(data: Dict[str, np.array], fields: List[str] = None, *args, **kwargs):
"""
Plot simulation data.
:data: A dictionary of arrays.
:fields: A list of variables you want to plot (e.g. ['x', y', 'c'])
"""
if plt is None:
return
if fields is None:
fields = ['x', 'y', 'm',... | def plot(data: Dict[str, np.array], fields: List[str] = None, *args, **kwargs):
"""
Plot simulation data.
:data: A dictionary of arrays.
:fields: A list of variables you want to plot (e.g. ['x', y', 'c'])
"""
if plt is None:
return
if fields is None:
fields = ['x', 'y', 'm',... | [
"Plot",
"simulation",
"data",
".",
":",
"data",
":",
"A",
"dictionary",
"of",
"arrays",
".",
":",
"fields",
":",
"A",
"list",
"of",
"variables",
"you",
"want",
"to",
"plot",
"(",
"e",
".",
"g",
".",
"[",
"x",
"y",
"c",
"]",
")"
] | pymoca/pymoca | python | https://github.com/pymoca/pymoca/blob/14b5eb7425e96689de6cc5c10f400895d586a978/src/pymoca/backends/xml/analysis.py#L17-L37 | [
"def",
"plot",
"(",
"data",
":",
"Dict",
"[",
"str",
",",
"np",
".",
"array",
"]",
",",
"fields",
":",
"List",
"[",
"str",
"]",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"plt",
"is",
"None",
":",
"return",
"if",
... | 14b5eb7425e96689de6cc5c10f400895d586a978 |
train | PSSEReader.read | Returns a case from a version 30 PSS/E raw file.
@param file_or_filename: File name or file like object with PSS/E data
@return: Case object | pylon/io/psse.py | def read(self, file_or_filename):
""" Returns a case from a version 30 PSS/E raw file.
@param file_or_filename: File name or file like object with PSS/E data
@return: Case object
"""
t0 = time.time()
self.init()
if isinstance(file_or_filename, basestring)... | def read(self, file_or_filename):
""" Returns a case from a version 30 PSS/E raw file.
@param file_or_filename: File name or file like object with PSS/E data
@return: Case object
"""
t0 = time.time()
self.init()
if isinstance(file_or_filename, basestring)... | [
"Returns",
"a",
"case",
"from",
"a",
"version",
"30",
"PSS",
"/",
"E",
"raw",
"file",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/psse.py#L58-L86 | [
"def",
"read",
"(",
"self",
",",
"file_or_filename",
")",
":",
"t0",
"=",
"time",
".",
"time",
"(",
")",
"self",
".",
"init",
"(",
")",
"if",
"isinstance",
"(",
"file_or_filename",
",",
"basestring",
")",
":",
"fname",
"=",
"os",
".",
"path",
".",
... | 916514255db1ae1661406f0283df756baf960d14 |
train | PSSEReader._parse_file | Parses the given file. | pylon/io/psse.py | def _parse_file(self, file):
""" Parses the given file.
"""
case = Case()
file.seek(0)
case.base_mva = float(file.next().split(",")[1].split("/")[0])
case.name = "%s %s" % (file.next().strip(), file.next().strip())
bustype_map = {1: "PQ", 2: "PV", 3: "ref... | def _parse_file(self, file):
""" Parses the given file.
"""
case = Case()
file.seek(0)
case.base_mva = float(file.next().split(",")[1].split("/")[0])
case.name = "%s %s" % (file.next().strip(), file.next().strip())
bustype_map = {1: "PQ", 2: "PV", 3: "ref... | [
"Parses",
"the",
"given",
"file",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/psse.py#L89-L370 | [
"def",
"_parse_file",
"(",
"self",
",",
"file",
")",
":",
"case",
"=",
"Case",
"(",
")",
"file",
".",
"seek",
"(",
"0",
")",
"case",
".",
"base_mva",
"=",
"float",
"(",
"file",
".",
"next",
"(",
")",
".",
"split",
"(",
"\",\"",
")",
"[",
"1",
... | 916514255db1ae1661406f0283df756baf960d14 |
train | PSSEWriter.write_case_data | Writes case data to file. | pylon/io/psse.py | def write_case_data(self, file):
""" Writes case data to file.
"""
change_code = 0
s_base = self.case.base_mva
timestr = time.strftime("%Y%m%d%H%M", time.gmtime())
file.write("%d, %8.2f, 30 / PSS(tm)E-30 RAW created by Pylon (%s).\n" %
(change_co... | def write_case_data(self, file):
""" Writes case data to file.
"""
change_code = 0
s_base = self.case.base_mva
timestr = time.strftime("%Y%m%d%H%M", time.gmtime())
file.write("%d, %8.2f, 30 / PSS(tm)E-30 RAW created by Pylon (%s).\n" %
(change_co... | [
"Writes",
"case",
"data",
"to",
"file",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/psse.py#L387-L397 | [
"def",
"write_case_data",
"(",
"self",
",",
"file",
")",
":",
"change_code",
"=",
"0",
"s_base",
"=",
"self",
".",
"case",
".",
"base_mva",
"timestr",
"=",
"time",
".",
"strftime",
"(",
"\"%Y%m%d%H%M\"",
",",
"time",
".",
"gmtime",
"(",
")",
")",
"file... | 916514255db1ae1661406f0283df756baf960d14 |
train | PSSEWriter.write_bus_data | Writes bus data in MATPOWER format. | pylon/io/psse.py | def write_bus_data(self, file):
""" Writes bus data in MATPOWER format.
"""
# I, 'NAME', BASKV, IDE, GL, BL, AREA, ZONE, VM, VA, OWNER
bus_attrs = ["_i", "name", "v_base", "type", "g_shunt", "b_shunt",
"area", "zone",
"v_magnitude", "v_angl... | def write_bus_data(self, file):
""" Writes bus data in MATPOWER format.
"""
# I, 'NAME', BASKV, IDE, GL, BL, AREA, ZONE, VM, VA, OWNER
bus_attrs = ["_i", "name", "v_base", "type", "g_shunt", "b_shunt",
"area", "zone",
"v_magnitude", "v_angl... | [
"Writes",
"bus",
"data",
"in",
"MATPOWER",
"format",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/psse.py#L400-L443 | [
"def",
"write_bus_data",
"(",
"self",
",",
"file",
")",
":",
"# I, 'NAME', BASKV, IDE, GL, BL, AREA, ZONE, VM, VA, OWNER\r",
"bus_attrs",
"=",
"[",
"\"_i\"",
",",
"\"name\"",
",",
"\"v_base\"",
",",
"\"type\"",
",",
"\"g_shunt\"",
",",
"\"b_shunt\"",
",",
"\"area\"",
... | 916514255db1ae1661406f0283df756baf960d14 |
train | PSSEWriter.write_generator_data | Writes generator data in MATPOWER format. | pylon/io/psse.py | def write_generator_data(self, file):
""" Writes generator data in MATPOWER format.
"""
for generator in self.case.generators:
vals = []
vals.append(generator.bus._i) # I
vals.append("1 ") # ID
vals.append(generator.p)
vals.appe... | def write_generator_data(self, file):
""" Writes generator data in MATPOWER format.
"""
for generator in self.case.generators:
vals = []
vals.append(generator.bus._i) # I
vals.append("1 ") # ID
vals.append(generator.p)
vals.appe... | [
"Writes",
"generator",
"data",
"in",
"MATPOWER",
"format",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/psse.py#L446-L470 | [
"def",
"write_generator_data",
"(",
"self",
",",
"file",
")",
":",
"for",
"generator",
"in",
"self",
".",
"case",
".",
"generators",
":",
"vals",
"=",
"[",
"]",
"vals",
".",
"append",
"(",
"generator",
".",
"bus",
".",
"_i",
")",
"# I\r",
"vals",
"."... | 916514255db1ae1661406f0283df756baf960d14 |
train | PSSEWriter.write_branch_data | Writes branch data to file. | pylon/io/psse.py | def write_branch_data(self, file):
""" Writes branch data to file.
"""
# I,J,CKT,R,X,B,RATEA,RATEB,RATEC,GI,BI,GJ,BJ,ST,LEN,O1,F1,...,O4,F4
branch_attr = ["r", "x", "b", "rate_a", "rate_b", "rate_c"]
for branch in self.case.branches:
if feq(branch.ratio, 0.0):... | def write_branch_data(self, file):
""" Writes branch data to file.
"""
# I,J,CKT,R,X,B,RATEA,RATEB,RATEC,GI,BI,GJ,BJ,ST,LEN,O1,F1,...,O4,F4
branch_attr = ["r", "x", "b", "rate_a", "rate_b", "rate_c"]
for branch in self.case.branches:
if feq(branch.ratio, 0.0):... | [
"Writes",
"branch",
"data",
"to",
"file",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/psse.py#L473-L543 | [
"def",
"write_branch_data",
"(",
"self",
",",
"file",
")",
":",
"# I,J,CKT,R,X,B,RATEA,RATEB,RATEC,GI,BI,GJ,BJ,ST,LEN,O1,F1,...,O4,F4\r",
"branch_attr",
"=",
"[",
"\"r\"",
",",
"\"x\"",
",",
"\"b\"",
",",
"\"rate_a\"",
",",
"\"rate_b\"",
",",
"\"rate_c\"",
"]",
"for",... | 916514255db1ae1661406f0283df756baf960d14 |
train | weighted_choice | Makes weighted choices. Accepts a list of tuples with the item and
probability as a pair like:
>>> x = [('one', 0.25), ('two', 0.25), ('three', 0.5)]
>>> y=windex(x) | pyreto/util.py | def weighted_choice(lst):
""" Makes weighted choices. Accepts a list of tuples with the item and
probability as a pair like:
>>> x = [('one', 0.25), ('two', 0.25), ('three', 0.5)]
>>> y=windex(x) """
n = random.uniform(0, 1)
for item, weight in lst:
if n < weight:
break
... | def weighted_choice(lst):
""" Makes weighted choices. Accepts a list of tuples with the item and
probability as a pair like:
>>> x = [('one', 0.25), ('two', 0.25), ('three', 0.5)]
>>> y=windex(x) """
n = random.uniform(0, 1)
for item, weight in lst:
if n < weight:
break
... | [
"Makes",
"weighted",
"choices",
".",
"Accepts",
"a",
"list",
"of",
"tuples",
"with",
"the",
"item",
"and",
"probability",
"as",
"a",
"pair",
"like",
":",
">>>",
"x",
"=",
"[",
"(",
"one",
"0",
".",
"25",
")",
"(",
"two",
"0",
".",
"25",
")",
"(",... | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pyreto/util.py#L96-L106 | [
"def",
"weighted_choice",
"(",
"lst",
")",
":",
"n",
"=",
"random",
".",
"uniform",
"(",
"0",
",",
"1",
")",
"for",
"item",
",",
"weight",
"in",
"lst",
":",
"if",
"n",
"<",
"weight",
":",
"break",
"n",
"=",
"n",
"-",
"weight",
"return",
"item"
] | 916514255db1ae1661406f0283df756baf960d14 |
train | xselections | Takes n elements (not necessarily distinct) from the sequence, order
matters.
@see: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/190465 | pyreto/util.py | def xselections(items, n):
""" Takes n elements (not necessarily distinct) from the sequence, order
matters.
@see: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/190465
"""
if n==0:
yield []
else:
for i in xrange(len(items)):
for ss in xselections(items, n-1... | def xselections(items, n):
""" Takes n elements (not necessarily distinct) from the sequence, order
matters.
@see: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/190465
"""
if n==0:
yield []
else:
for i in xrange(len(items)):
for ss in xselections(items, n-1... | [
"Takes",
"n",
"elements",
"(",
"not",
"necessarily",
"distinct",
")",
"from",
"the",
"sequence",
"order",
"matters",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pyreto/util.py#L112-L123 | [
"def",
"xselections",
"(",
"items",
",",
"n",
")",
":",
"if",
"n",
"==",
"0",
":",
"yield",
"[",
"]",
"else",
":",
"for",
"i",
"in",
"xrange",
"(",
"len",
"(",
"items",
")",
")",
":",
"for",
"ss",
"in",
"xselections",
"(",
"items",
",",
"n",
... | 916514255db1ae1661406f0283df756baf960d14 |
train | plotGenCost | Plots the costs of the given generators. | pyreto/util.py | def plotGenCost(generators):
""" Plots the costs of the given generators.
"""
figure()
plots = []
for generator in generators:
if generator.pcost_model == PW_LINEAR:
x = [x for x, _ in generator.p_cost]
y = [y for _, y in generator.p_cost]
elif generator.pcost... | def plotGenCost(generators):
""" Plots the costs of the given generators.
"""
figure()
plots = []
for generator in generators:
if generator.pcost_model == PW_LINEAR:
x = [x for x, _ in generator.p_cost]
y = [y for _, y in generator.p_cost]
elif generator.pcost... | [
"Plots",
"the",
"costs",
"of",
"the",
"given",
"generators",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pyreto/util.py#L129-L147 | [
"def",
"plotGenCost",
"(",
"generators",
")",
":",
"figure",
"(",
")",
"plots",
"=",
"[",
"]",
"for",
"generator",
"in",
"generators",
":",
"if",
"generator",
".",
"pcost_model",
"==",
"PW_LINEAR",
":",
"x",
"=",
"[",
"x",
"for",
"x",
",",
"_",
"in",... | 916514255db1ae1661406f0283df756baf960d14 |
train | sparklineData | Writes reward and action data for plotting sparklines with PGF/TikZ.
@see: http://www.texample.net/tikz/examples/weather-stations-data/ | pyreto/util.py | def sparklineData(data, filename):
""" Writes reward and action data for plotting sparklines with PGF/TikZ.
@see: http://www.texample.net/tikz/examples/weather-stations-data/
"""
fd = file(filename, "w+b")
for name in data.keys():
action, reward = data[name]
altName = name.lower().... | def sparklineData(data, filename):
""" Writes reward and action data for plotting sparklines with PGF/TikZ.
@see: http://www.texample.net/tikz/examples/weather-stations-data/
"""
fd = file(filename, "w+b")
for name in data.keys():
action, reward = data[name]
altName = name.lower().... | [
"Writes",
"reward",
"and",
"action",
"data",
"for",
"plotting",
"sparklines",
"with",
"PGF",
"/",
"TikZ",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pyreto/util.py#L153-L193 | [
"def",
"sparklineData",
"(",
"data",
",",
"filename",
")",
":",
"fd",
"=",
"file",
"(",
"filename",
",",
"\"w+b\"",
")",
"for",
"name",
"in",
"data",
".",
"keys",
"(",
")",
":",
"action",
",",
"reward",
"=",
"data",
"[",
"name",
"]",
"altName",
"="... | 916514255db1ae1661406f0283df756baf960d14 |
train | ReSTExperimentWriter.write | Writes market experiment data to file in ReStructuredText format. | pyreto/util.py | def write(self, file):
""" Writes market experiment data to file in ReStructuredText format.
"""
# Write environment state data.
file.write("State\n")
file.write( ("-" * 5) + "\n")
self.writeDataTable(file, type="state")
# Write action data.
file.write("A... | def write(self, file):
""" Writes market experiment data to file in ReStructuredText format.
"""
# Write environment state data.
file.write("State\n")
file.write( ("-" * 5) + "\n")
self.writeDataTable(file, type="state")
# Write action data.
file.write("A... | [
"Writes",
"market",
"experiment",
"data",
"to",
"file",
"in",
"ReStructuredText",
"format",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pyreto/util.py#L210-L226 | [
"def",
"write",
"(",
"self",
",",
"file",
")",
":",
"# Write environment state data.",
"file",
".",
"write",
"(",
"\"State\\n\"",
")",
"file",
".",
"write",
"(",
"(",
"\"-\"",
"*",
"5",
")",
"+",
"\"\\n\"",
")",
"self",
".",
"writeDataTable",
"(",
"file"... | 916514255db1ae1661406f0283df756baf960d14 |
train | ReSTExperimentWriter.writeDataTable | Writes agent data to an ReST table. The 'type' argument may
be 'state', 'action' or 'reward'. | pyreto/util.py | def writeDataTable(self, file, type):
""" Writes agent data to an ReST table. The 'type' argument may
be 'state', 'action' or 'reward'.
"""
agents = self.experiment.agents
numAgents = len(self.experiment.agents)
colWidth = 8
idxColWidth = 3
sep = ("=" *... | def writeDataTable(self, file, type):
""" Writes agent data to an ReST table. The 'type' argument may
be 'state', 'action' or 'reward'.
"""
agents = self.experiment.agents
numAgents = len(self.experiment.agents)
colWidth = 8
idxColWidth = 3
sep = ("=" *... | [
"Writes",
"agent",
"data",
"to",
"an",
"ReST",
"table",
".",
"The",
"type",
"argument",
"may",
"be",
"state",
"action",
"or",
"reward",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pyreto/util.py#L229-L269 | [
"def",
"writeDataTable",
"(",
"self",
",",
"file",
",",
"type",
")",
":",
"agents",
"=",
"self",
".",
"experiment",
".",
"agents",
"numAgents",
"=",
"len",
"(",
"self",
".",
"experiment",
".",
"agents",
")",
"colWidth",
"=",
"8",
"idxColWidth",
"=",
"3... | 916514255db1ae1661406f0283df756baf960d14 |
train | ProfitTask.performAction | Execute one action. | pyreto/continuous/task.py | def performAction(self, action):
""" Execute one action.
"""
# print "ACTION:", action
self.t += 1
Task.performAction(self, action)
# self.addReward()
self.samples += 1 | def performAction(self, action):
""" Execute one action.
"""
# print "ACTION:", action
self.t += 1
Task.performAction(self, action)
# self.addReward()
self.samples += 1 | [
"Execute",
"one",
"action",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pyreto/continuous/task.py#L74-L81 | [
"def",
"performAction",
"(",
"self",
",",
"action",
")",
":",
"# print \"ACTION:\", action",
"self",
".",
"t",
"+=",
"1",
"Task",
".",
"performAction",
"(",
"self",
",",
"action",
")",
"# self.addReward()",
"self",
".",
"samples",
"+=",
"1"
] | 916514255db1ae1661406f0283df756baf960d14 |
train | ProfitTask._getActorLimits | Returns a list of 2-tuples, e.g. [(-3.14, 3.14), (-0.001, 0.001)],
one tuple per parameter, giving min and max for that parameter. | pyreto/continuous/task.py | def _getActorLimits(self):
""" Returns a list of 2-tuples, e.g. [(-3.14, 3.14), (-0.001, 0.001)],
one tuple per parameter, giving min and max for that parameter.
"""
actorLimits = []
for _ in range(self.env.numOffbids):
for _ in self.env.generators:
... | def _getActorLimits(self):
""" Returns a list of 2-tuples, e.g. [(-3.14, 3.14), (-0.001, 0.001)],
one tuple per parameter, giving min and max for that parameter.
"""
actorLimits = []
for _ in range(self.env.numOffbids):
for _ in self.env.generators:
... | [
"Returns",
"a",
"list",
"of",
"2",
"-",
"tuples",
"e",
".",
"g",
".",
"[",
"(",
"-",
"3",
".",
"14",
"3",
".",
"14",
")",
"(",
"-",
"0",
".",
"001",
"0",
".",
"001",
")",
"]",
"one",
"tuple",
"per",
"parameter",
"giving",
"min",
"and",
"max... | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pyreto/continuous/task.py#L87-L104 | [
"def",
"_getActorLimits",
"(",
"self",
")",
":",
"actorLimits",
"=",
"[",
"]",
"for",
"_",
"in",
"range",
"(",
"self",
".",
"env",
".",
"numOffbids",
")",
":",
"for",
"_",
"in",
"self",
".",
"env",
".",
"generators",
":",
"actorLimits",
".",
"append"... | 916514255db1ae1661406f0283df756baf960d14 |
train | ProfitTask._getSensorLimits | Returns a list of 2-tuples, e.g. [(-3.14, 3.14), (-0.001, 0.001)],
one tuple per parameter, giving min and max for that parameter. | pyreto/continuous/task.py | def _getSensorLimits(self):
""" Returns a list of 2-tuples, e.g. [(-3.14, 3.14), (-0.001, 0.001)],
one tuple per parameter, giving min and max for that parameter.
"""
limits = []
limits.extend(self._getTotalDemandLimits())
# limits.extend(self._getDemandLimits())
# ... | def _getSensorLimits(self):
""" Returns a list of 2-tuples, e.g. [(-3.14, 3.14), (-0.001, 0.001)],
one tuple per parameter, giving min and max for that parameter.
"""
limits = []
limits.extend(self._getTotalDemandLimits())
# limits.extend(self._getDemandLimits())
# ... | [
"Returns",
"a",
"list",
"of",
"2",
"-",
"tuples",
"e",
".",
"g",
".",
"[",
"(",
"-",
"3",
".",
"14",
"3",
".",
"14",
")",
"(",
"-",
"0",
".",
"001",
"0",
".",
"001",
")",
"]",
"one",
"tuple",
"per",
"parameter",
"giving",
"min",
"and",
"max... | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pyreto/continuous/task.py#L107-L124 | [
"def",
"_getSensorLimits",
"(",
"self",
")",
":",
"limits",
"=",
"[",
"]",
"limits",
".",
"extend",
"(",
"self",
".",
"_getTotalDemandLimits",
"(",
")",
")",
"# limits.extend(self._getDemandLimits())",
"# limits.extend(self._getPriceLimits())",
"# lim... | 916514255db1ae1661406f0283df756baf960d14 |
train | split_dae_alg | Split equations into differential algebraic and algebraic only | src/pymoca/backends/xml/model.py | def split_dae_alg(eqs: SYM, dx: SYM) -> Dict[str, SYM]:
"""Split equations into differential algebraic and algebraic only"""
dae = []
alg = []
for eq in ca.vertsplit(eqs):
if ca.depends_on(eq, dx):
dae.append(eq)
else:
alg.append(eq)
return {
'dae': ca... | def split_dae_alg(eqs: SYM, dx: SYM) -> Dict[str, SYM]:
"""Split equations into differential algebraic and algebraic only"""
dae = []
alg = []
for eq in ca.vertsplit(eqs):
if ca.depends_on(eq, dx):
dae.append(eq)
else:
alg.append(eq)
return {
'dae': ca... | [
"Split",
"equations",
"into",
"differential",
"algebraic",
"and",
"algebraic",
"only"
] | pymoca/pymoca | python | https://github.com/pymoca/pymoca/blob/14b5eb7425e96689de6cc5c10f400895d586a978/src/pymoca/backends/xml/model.py#L174-L186 | [
"def",
"split_dae_alg",
"(",
"eqs",
":",
"SYM",
",",
"dx",
":",
"SYM",
")",
"->",
"Dict",
"[",
"str",
",",
"SYM",
"]",
":",
"dae",
"=",
"[",
"]",
"alg",
"=",
"[",
"]",
"for",
"eq",
"in",
"ca",
".",
"vertsplit",
"(",
"eqs",
")",
":",
"if",
"... | 14b5eb7425e96689de6cc5c10f400895d586a978 |
train | permute | Perumute a vector | src/pymoca/backends/xml/model.py | def permute(x: SYM, perm: List[int]) -> SYM:
"""Perumute a vector"""
x_s = []
for i in perm:
x_s.append(x[i])
return ca.vertcat(*x_s) | def permute(x: SYM, perm: List[int]) -> SYM:
"""Perumute a vector"""
x_s = []
for i in perm:
x_s.append(x[i])
return ca.vertcat(*x_s) | [
"Perumute",
"a",
"vector"
] | pymoca/pymoca | python | https://github.com/pymoca/pymoca/blob/14b5eb7425e96689de6cc5c10f400895d586a978/src/pymoca/backends/xml/model.py#L189-L194 | [
"def",
"permute",
"(",
"x",
":",
"SYM",
",",
"perm",
":",
"List",
"[",
"int",
"]",
")",
"->",
"SYM",
":",
"x_s",
"=",
"[",
"]",
"for",
"i",
"in",
"perm",
":",
"x_s",
".",
"append",
"(",
"x",
"[",
"i",
"]",
")",
"return",
"ca",
".",
"vertcat... | 14b5eb7425e96689de6cc5c10f400895d586a978 |
train | blt | Sort equations by dependence | src/pymoca/backends/xml/model.py | def blt(f: List[SYM], x: List[SYM]) -> Dict[str, Any]:
"""
Sort equations by dependence
"""
J = ca.jacobian(f, x)
nblock, rowperm, colperm, rowblock, colblock, coarserow, coarsecol = J.sparsity().btf()
return {
'J': J,
'nblock': nblock,
'rowperm': rowperm,
'colper... | def blt(f: List[SYM], x: List[SYM]) -> Dict[str, Any]:
"""
Sort equations by dependence
"""
J = ca.jacobian(f, x)
nblock, rowperm, colperm, rowblock, colblock, coarserow, coarsecol = J.sparsity().btf()
return {
'J': J,
'nblock': nblock,
'rowperm': rowperm,
'colper... | [
"Sort",
"equations",
"by",
"dependence"
] | pymoca/pymoca | python | https://github.com/pymoca/pymoca/blob/14b5eb7425e96689de6cc5c10f400895d586a978/src/pymoca/backends/xml/model.py#L198-L213 | [
"def",
"blt",
"(",
"f",
":",
"List",
"[",
"SYM",
"]",
",",
"x",
":",
"List",
"[",
"SYM",
"]",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"J",
"=",
"ca",
".",
"jacobian",
"(",
"f",
",",
"x",
")",
"nblock",
",",
"rowperm",
",",
"c... | 14b5eb7425e96689de6cc5c10f400895d586a978 |
train | tangent_approx | Create a tangent approximation of a non-linear function f(x) about point a
using a block lower triangular solver
0 = f(x) = f(a) + J*x # taylor series about a (if f(x) linear in x, then globally valid)
J*x = -f(a) # solve for x
x = -J^{-1}f(a) # but inverse is slow, so we use solv... | src/pymoca/backends/xml/model.py | def tangent_approx(f: SYM, x: SYM, a: SYM = None, assert_linear: bool = False) -> Dict[str, SYM]:
"""
Create a tangent approximation of a non-linear function f(x) about point a
using a block lower triangular solver
0 = f(x) = f(a) + J*x # taylor series about a (if f(x) linear in x, then globally vali... | def tangent_approx(f: SYM, x: SYM, a: SYM = None, assert_linear: bool = False) -> Dict[str, SYM]:
"""
Create a tangent approximation of a non-linear function f(x) about point a
using a block lower triangular solver
0 = f(x) = f(a) + J*x # taylor series about a (if f(x) linear in x, then globally vali... | [
"Create",
"a",
"tangent",
"approximation",
"of",
"a",
"non",
"-",
"linear",
"function",
"f",
"(",
"x",
")",
"about",
"point",
"a",
"using",
"a",
"block",
"lower",
"triangular",
"solver"
] | pymoca/pymoca | python | https://github.com/pymoca/pymoca/blob/14b5eb7425e96689de6cc5c10f400895d586a978/src/pymoca/backends/xml/model.py#L217-L235 | [
"def",
"tangent_approx",
"(",
"f",
":",
"SYM",
",",
"x",
":",
"SYM",
",",
"a",
":",
"SYM",
"=",
"None",
",",
"assert_linear",
":",
"bool",
"=",
"False",
")",
"->",
"Dict",
"[",
"str",
",",
"SYM",
"]",
":",
"# find f(a)",
"if",
"a",
"is",
"None",
... | 14b5eb7425e96689de6cc5c10f400895d586a978 |
train | HybridOde.create_function_f_c | condition function | src/pymoca/backends/xml/model.py | def create_function_f_c(self):
"""condition function"""
return ca.Function(
'f_c',
[self.t, self.x, self.y, self.m, self.p, self.ng, self.nu],
[self.f_c],
['t', 'x', 'y', 'm', 'p', 'ng', 'nu'], ['c'], self.func_opt) | def create_function_f_c(self):
"""condition function"""
return ca.Function(
'f_c',
[self.t, self.x, self.y, self.m, self.p, self.ng, self.nu],
[self.f_c],
['t', 'x', 'y', 'm', 'p', 'ng', 'nu'], ['c'], self.func_opt) | [
"condition",
"function"
] | pymoca/pymoca | python | https://github.com/pymoca/pymoca/blob/14b5eb7425e96689de6cc5c10f400895d586a978/src/pymoca/backends/xml/model.py#L70-L76 | [
"def",
"create_function_f_c",
"(",
"self",
")",
":",
"return",
"ca",
".",
"Function",
"(",
"'f_c'",
",",
"[",
"self",
".",
"t",
",",
"self",
".",
"x",
",",
"self",
".",
"y",
",",
"self",
".",
"m",
",",
"self",
".",
"p",
",",
"self",
".",
"ng",
... | 14b5eb7425e96689de6cc5c10f400895d586a978 |
train | HybridOde.create_function_f_i | state reinitialization (reset) function | src/pymoca/backends/xml/model.py | def create_function_f_i(self):
"""state reinitialization (reset) function"""
return ca.Function(
'f_i',
[self.t, self.x, self.y, self.m, self.p, self.c, self.pre_c, self.ng, self.nu],
[self.f_i],
['t', 'x', 'y', 'm', 'p', 'c', 'pre_c', 'ng', 'nu'], ['x_n']... | def create_function_f_i(self):
"""state reinitialization (reset) function"""
return ca.Function(
'f_i',
[self.t, self.x, self.y, self.m, self.p, self.c, self.pre_c, self.ng, self.nu],
[self.f_i],
['t', 'x', 'y', 'm', 'p', 'c', 'pre_c', 'ng', 'nu'], ['x_n']... | [
"state",
"reinitialization",
"(",
"reset",
")",
"function"
] | pymoca/pymoca | python | https://github.com/pymoca/pymoca/blob/14b5eb7425e96689de6cc5c10f400895d586a978/src/pymoca/backends/xml/model.py#L78-L84 | [
"def",
"create_function_f_i",
"(",
"self",
")",
":",
"return",
"ca",
".",
"Function",
"(",
"'f_i'",
",",
"[",
"self",
".",
"t",
",",
"self",
".",
"x",
",",
"self",
".",
"y",
",",
"self",
".",
"m",
",",
"self",
".",
"p",
",",
"self",
".",
"c",
... | 14b5eb7425e96689de6cc5c10f400895d586a978 |
train | HybridOde.create_function_f_m | Discrete state dynamics | src/pymoca/backends/xml/model.py | def create_function_f_m(self):
"""Discrete state dynamics"""
return ca.Function(
'f_m',
[self.t, self.x, self.y, self.m, self.p, self.c, self.pre_c, self.ng, self.nu],
[self.f_m],
['t', 'x', 'y', 'm', 'p', 'c', 'pre_c', 'ng', 'nu'], ['m'], self.func_opt) | def create_function_f_m(self):
"""Discrete state dynamics"""
return ca.Function(
'f_m',
[self.t, self.x, self.y, self.m, self.p, self.c, self.pre_c, self.ng, self.nu],
[self.f_m],
['t', 'x', 'y', 'm', 'p', 'c', 'pre_c', 'ng', 'nu'], ['m'], self.func_opt) | [
"Discrete",
"state",
"dynamics"
] | pymoca/pymoca | python | https://github.com/pymoca/pymoca/blob/14b5eb7425e96689de6cc5c10f400895d586a978/src/pymoca/backends/xml/model.py#L94-L100 | [
"def",
"create_function_f_m",
"(",
"self",
")",
":",
"return",
"ca",
".",
"Function",
"(",
"'f_m'",
",",
"[",
"self",
".",
"t",
",",
"self",
".",
"x",
",",
"self",
".",
"y",
",",
"self",
".",
"m",
",",
"self",
".",
"p",
",",
"self",
".",
"c",
... | 14b5eb7425e96689de6cc5c10f400895d586a978 |
train | HybridOde.create_function_f_J | Jacobian for state integration | src/pymoca/backends/xml/model.py | def create_function_f_J(self):
"""Jacobian for state integration"""
return ca.Function(
'J',
[self.t, self.x, self.y, self.m, self.p, self.c, self.ng, self.nu],
[ca.jacobian(self.f_x_rhs, self.x)],
['t', 'x', 'y', 'm', 'p', 'c', 'ng', 'nu'], ['J'], self.fu... | def create_function_f_J(self):
"""Jacobian for state integration"""
return ca.Function(
'J',
[self.t, self.x, self.y, self.m, self.p, self.c, self.ng, self.nu],
[ca.jacobian(self.f_x_rhs, self.x)],
['t', 'x', 'y', 'm', 'p', 'c', 'ng', 'nu'], ['J'], self.fu... | [
"Jacobian",
"for",
"state",
"integration"
] | pymoca/pymoca | python | https://github.com/pymoca/pymoca/blob/14b5eb7425e96689de6cc5c10f400895d586a978/src/pymoca/backends/xml/model.py#L102-L108 | [
"def",
"create_function_f_J",
"(",
"self",
")",
":",
"return",
"ca",
".",
"Function",
"(",
"'J'",
",",
"[",
"self",
".",
"t",
",",
"self",
".",
"x",
",",
"self",
".",
"y",
",",
"self",
".",
"m",
",",
"self",
".",
"p",
",",
"self",
".",
"c",
"... | 14b5eb7425e96689de6cc5c10f400895d586a978 |
train | HybridOde.create_function_f_y | output function | src/pymoca/backends/xml/model.py | def create_function_f_y(self):
"""output function"""
return ca.Function(
'y',
[self.t, self.x, self.m, self.p, self.c, self.ng, self.nu],
[self.y_rhs],
['t', 'x', 'm', 'p', 'c', 'ng', 'nu'], ['y'], self.func_opt) | def create_function_f_y(self):
"""output function"""
return ca.Function(
'y',
[self.t, self.x, self.m, self.p, self.c, self.ng, self.nu],
[self.y_rhs],
['t', 'x', 'm', 'p', 'c', 'ng', 'nu'], ['y'], self.func_opt) | [
"output",
"function"
] | pymoca/pymoca | python | https://github.com/pymoca/pymoca/blob/14b5eb7425e96689de6cc5c10f400895d586a978/src/pymoca/backends/xml/model.py#L110-L116 | [
"def",
"create_function_f_y",
"(",
"self",
")",
":",
"return",
"ca",
".",
"Function",
"(",
"'y'",
",",
"[",
"self",
".",
"t",
",",
"self",
".",
"x",
",",
"self",
".",
"m",
",",
"self",
".",
"p",
",",
"self",
".",
"c",
",",
"self",
".",
"ng",
... | 14b5eb7425e96689de6cc5c10f400895d586a978 |
train | HybridDae.to_ode | Convert to a HybridOde | src/pymoca/backends/xml/model.py | def to_ode(self) -> HybridOde:
"""Convert to a HybridOde"""
res_split = split_dae_alg(self.f_x, self.dx)
alg = res_split['alg']
dae = res_split['dae']
x_rhs = tangent_approx(dae, self.dx, assert_linear=True)
y_rhs = tangent_approx(alg, self.y, assert_linear=True)
... | def to_ode(self) -> HybridOde:
"""Convert to a HybridOde"""
res_split = split_dae_alg(self.f_x, self.dx)
alg = res_split['alg']
dae = res_split['dae']
x_rhs = tangent_approx(dae, self.dx, assert_linear=True)
y_rhs = tangent_approx(alg, self.y, assert_linear=True)
... | [
"Convert",
"to",
"a",
"HybridOde"
] | pymoca/pymoca | python | https://github.com/pymoca/pymoca/blob/14b5eb7425e96689de6cc5c10f400895d586a978/src/pymoca/backends/xml/model.py#L143-L171 | [
"def",
"to_ode",
"(",
"self",
")",
"->",
"HybridOde",
":",
"res_split",
"=",
"split_dae_alg",
"(",
"self",
".",
"f_x",
",",
"self",
".",
"dx",
")",
"alg",
"=",
"res_split",
"[",
"'alg'",
"]",
"dae",
"=",
"res_split",
"[",
"'dae'",
"]",
"x_rhs",
"=",
... | 14b5eb7425e96689de6cc5c10f400895d586a978 |
train | MarketEnvironment.performAction | Performs an action on the world that changes it's internal state.
@param action: an action that should be executed in the Environment
@type action: array: [int] | pyreto/discrete/environment.py | def performAction(self, action):
""" Performs an action on the world that changes it's internal state.
@param action: an action that should be executed in the Environment
@type action: array: [int]
"""
self._lastAction = []
# Markups chosen for each generator.
... | def performAction(self, action):
""" Performs an action on the world that changes it's internal state.
@param action: an action that should be executed in the Environment
@type action: array: [int]
"""
self._lastAction = []
# Markups chosen for each generator.
... | [
"Performs",
"an",
"action",
"on",
"the",
"world",
"that",
"changes",
"it",
"s",
"internal",
"state",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pyreto/discrete/environment.py#L131-L148 | [
"def",
"performAction",
"(",
"self",
",",
"action",
")",
":",
"self",
".",
"_lastAction",
"=",
"[",
"]",
"# Markups chosen for each generator.",
"actions",
"=",
"self",
".",
"_allActions",
"[",
"action",
"]",
"n",
"=",
"self",
".",
"numOffbids",
"*",
"len",
... | 916514255db1ae1661406f0283df756baf960d14 |
train | MarketEnvironment._offbid | Converts arrays of percentage price markups and capacity withholds
into offers/bids and submits them to the marketplace. | pyreto/discrete/environment.py | def _offbid(self, markups, withholds):
""" Converts arrays of percentage price markups and capacity withholds
into offers/bids and submits them to the marketplace.
"""
for i, g in enumerate(self.generators):
ratedPMin = self._g0[g]["p_min"]
ratedPMax = self._g0[g]... | def _offbid(self, markups, withholds):
""" Converts arrays of percentage price markups and capacity withholds
into offers/bids and submits them to the marketplace.
"""
for i, g in enumerate(self.generators):
ratedPMin = self._g0[g]["p_min"]
ratedPMax = self._g0[g]... | [
"Converts",
"arrays",
"of",
"percentage",
"price",
"markups",
"and",
"capacity",
"withholds",
"into",
"offers",
"/",
"bids",
"and",
"submits",
"them",
"to",
"the",
"marketplace",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pyreto/discrete/environment.py#L161-L242 | [
"def",
"_offbid",
"(",
"self",
",",
"markups",
",",
"withholds",
")",
":",
"for",
"i",
",",
"g",
"in",
"enumerate",
"(",
"self",
".",
"generators",
")",
":",
"ratedPMin",
"=",
"self",
".",
"_g0",
"[",
"g",
"]",
"[",
"\"p_min\"",
"]",
"ratedPMax",
"... | 916514255db1ae1661406f0283df756baf960d14 |
train | format_from_extension | Tries to infer a protocol from the file extension. | pylon/util.py | def format_from_extension(fname):
""" Tries to infer a protocol from the file extension."""
_base, ext = os.path.splitext(fname)
if not ext:
return None
try:
format = known_extensions[ext.replace('.', '')]
except KeyError:
format = None
return format | def format_from_extension(fname):
""" Tries to infer a protocol from the file extension."""
_base, ext = os.path.splitext(fname)
if not ext:
return None
try:
format = known_extensions[ext.replace('.', '')]
except KeyError:
format = None
return format | [
"Tries",
"to",
"infer",
"a",
"protocol",
"from",
"the",
"file",
"extension",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/util.py#L159-L168 | [
"def",
"format_from_extension",
"(",
"fname",
")",
":",
"_base",
",",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"fname",
")",
"if",
"not",
"ext",
":",
"return",
"None",
"try",
":",
"format",
"=",
"known_extensions",
"[",
"ext",
".",
"replace... | 916514255db1ae1661406f0283df756baf960d14 |
train | pickle_matpower_cases | Parses the MATPOWER case files at the given paths and pickles the
resulting Case objects to the same directory. | pylon/util.py | def pickle_matpower_cases(case_paths, case_format=2):
""" Parses the MATPOWER case files at the given paths and pickles the
resulting Case objects to the same directory.
"""
import pylon.io
if isinstance(case_paths, basestring):
case_paths = [case_paths]
for case_path in case_paths... | def pickle_matpower_cases(case_paths, case_format=2):
""" Parses the MATPOWER case files at the given paths and pickles the
resulting Case objects to the same directory.
"""
import pylon.io
if isinstance(case_paths, basestring):
case_paths = [case_paths]
for case_path in case_paths... | [
"Parses",
"the",
"MATPOWER",
"case",
"files",
"at",
"the",
"given",
"paths",
"and",
"pickles",
"the",
"resulting",
"Case",
"objects",
"to",
"the",
"same",
"directory",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/util.py#L174-L194 | [
"def",
"pickle_matpower_cases",
"(",
"case_paths",
",",
"case_format",
"=",
"2",
")",
":",
"import",
"pylon",
".",
"io",
"if",
"isinstance",
"(",
"case_paths",
",",
"basestring",
")",
":",
"case_paths",
"=",
"[",
"case_paths",
"]",
"for",
"case_path",
"in",
... | 916514255db1ae1661406f0283df756baf960d14 |
train | fair_max | Takes a single iterable as an argument and returns the same output as
the built-in function max with two output parameters, except that where
the maximum value occurs at more than one position in the vector, the
index is chosen randomly from these positions as opposed to just choosing
the first occuran... | pylon/util.py | def fair_max(x):
""" Takes a single iterable as an argument and returns the same output as
the built-in function max with two output parameters, except that where
the maximum value occurs at more than one position in the vector, the
index is chosen randomly from these positions as opposed to just choos... | def fair_max(x):
""" Takes a single iterable as an argument and returns the same output as
the built-in function max with two output parameters, except that where
the maximum value occurs at more than one position in the vector, the
index is chosen randomly from these positions as opposed to just choos... | [
"Takes",
"a",
"single",
"iterable",
"as",
"an",
"argument",
"and",
"returns",
"the",
"same",
"output",
"as",
"the",
"built",
"-",
"in",
"function",
"max",
"with",
"two",
"output",
"parameters",
"except",
"that",
"where",
"the",
"maximum",
"value",
"occurs",
... | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/util.py#L243-L256 | [
"def",
"fair_max",
"(",
"x",
")",
":",
"value",
"=",
"max",
"(",
"x",
")",
"# List indexes of max value.",
"i",
"=",
"[",
"x",
".",
"index",
"(",
"v",
")",
"for",
"v",
"in",
"x",
"if",
"v",
"==",
"value",
"]",
"# Select index randomly among occurances.",... | 916514255db1ae1661406f0283df756baf960d14 |
train | factorial | Returns the factorial of n. | pylon/util.py | def factorial(n):
""" Returns the factorial of n.
"""
f = 1
while (n > 0):
f = f * n
n = n - 1
return f | def factorial(n):
""" Returns the factorial of n.
"""
f = 1
while (n > 0):
f = f * n
n = n - 1
return f | [
"Returns",
"the",
"factorial",
"of",
"n",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/util.py#L262-L269 | [
"def",
"factorial",
"(",
"n",
")",
":",
"f",
"=",
"1",
"while",
"(",
"n",
">",
"0",
")",
":",
"f",
"=",
"f",
"*",
"n",
"n",
"=",
"n",
"-",
"1",
"return",
"f"
] | 916514255db1ae1661406f0283df756baf960d14 |
train | _Named._get_name | Returns the name, which is generated if it has not been already. | pylon/util.py | def _get_name(self):
""" Returns the name, which is generated if it has not been already.
"""
if self._name is None:
self._name = self._generate_name()
return self._name | def _get_name(self):
""" Returns the name, which is generated if it has not been already.
"""
if self._name is None:
self._name = self._generate_name()
return self._name | [
"Returns",
"the",
"name",
"which",
"is",
"generated",
"if",
"it",
"has",
"not",
"been",
"already",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/util.py#L61-L66 | [
"def",
"_get_name",
"(",
"self",
")",
":",
"if",
"self",
".",
"_name",
"is",
"None",
":",
"self",
".",
"_name",
"=",
"self",
".",
"_generate_name",
"(",
")",
"return",
"self",
".",
"_name"
] | 916514255db1ae1661406f0283df756baf960d14 |
train | _Serializable.save_to_file_object | Save the object to a given file like object in the given format. | pylon/util.py | def save_to_file_object(self, fd, format=None, **kwargs):
""" Save the object to a given file like object in the given format.
"""
format = 'pickle' if format is None else format
save = getattr(self, "save_%s" % format, None)
if save is None:
raise ValueError("Unknown... | def save_to_file_object(self, fd, format=None, **kwargs):
""" Save the object to a given file like object in the given format.
"""
format = 'pickle' if format is None else format
save = getattr(self, "save_%s" % format, None)
if save is None:
raise ValueError("Unknown... | [
"Save",
"the",
"object",
"to",
"a",
"given",
"file",
"like",
"object",
"in",
"the",
"given",
"format",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/util.py#L98-L105 | [
"def",
"save_to_file_object",
"(",
"self",
",",
"fd",
",",
"format",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"format",
"=",
"'pickle'",
"if",
"format",
"is",
"None",
"else",
"format",
"save",
"=",
"getattr",
"(",
"self",
",",
"\"save_%s\"",
"%"... | 916514255db1ae1661406f0283df756baf960d14 |
train | _Serializable.load_from_file_object | Load the object from a given file like object in the given format. | pylon/util.py | def load_from_file_object(cls, fd, format=None):
""" Load the object from a given file like object in the given format.
"""
format = 'pickle' if format is None else format
load = getattr(cls, "load_%s" % format, None)
if load is None:
raise ValueError("Unknown format ... | def load_from_file_object(cls, fd, format=None):
""" Load the object from a given file like object in the given format.
"""
format = 'pickle' if format is None else format
load = getattr(cls, "load_%s" % format, None)
if load is None:
raise ValueError("Unknown format ... | [
"Load",
"the",
"object",
"from",
"a",
"given",
"file",
"like",
"object",
"in",
"the",
"given",
"format",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/util.py#L109-L116 | [
"def",
"load_from_file_object",
"(",
"cls",
",",
"fd",
",",
"format",
"=",
"None",
")",
":",
"format",
"=",
"'pickle'",
"if",
"format",
"is",
"None",
"else",
"format",
"load",
"=",
"getattr",
"(",
"cls",
",",
"\"load_%s\"",
"%",
"format",
",",
"None",
... | 916514255db1ae1661406f0283df756baf960d14 |
train | _Serializable.save | Save the object to file given by filename. | pylon/util.py | def save(self, filename, format=None, **kwargs):
""" Save the object to file given by filename.
"""
if format is None:
# try to derive protocol from file extension
format = format_from_extension(filename)
with file(filename, 'wb') as fp:
self.save_to_f... | def save(self, filename, format=None, **kwargs):
""" Save the object to file given by filename.
"""
if format is None:
# try to derive protocol from file extension
format = format_from_extension(filename)
with file(filename, 'wb') as fp:
self.save_to_f... | [
"Save",
"the",
"object",
"to",
"file",
"given",
"by",
"filename",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/util.py#L119-L126 | [
"def",
"save",
"(",
"self",
",",
"filename",
",",
"format",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"format",
"is",
"None",
":",
"# try to derive protocol from file extension",
"format",
"=",
"format_from_extension",
"(",
"filename",
")",
"with",... | 916514255db1ae1661406f0283df756baf960d14 |
train | _Serializable.load | Return an instance of the class that is saved in the file with the
given filename in the specified format. | pylon/util.py | def load(cls, filename, format=None):
""" Return an instance of the class that is saved in the file with the
given filename in the specified format.
"""
if format is None:
# try to derive protocol from file extension
format = format_from_extension(filename)
... | def load(cls, filename, format=None):
""" Return an instance of the class that is saved in the file with the
given filename in the specified format.
"""
if format is None:
# try to derive protocol from file extension
format = format_from_extension(filename)
... | [
"Return",
"an",
"instance",
"of",
"the",
"class",
"that",
"is",
"saved",
"in",
"the",
"file",
"with",
"the",
"given",
"filename",
"in",
"the",
"specified",
"format",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/util.py#L130-L140 | [
"def",
"load",
"(",
"cls",
",",
"filename",
",",
"format",
"=",
"None",
")",
":",
"if",
"format",
"is",
"None",
":",
"# try to derive protocol from file extension",
"format",
"=",
"format_from_extension",
"(",
"filename",
")",
"with",
"file",
"(",
"filename",
... | 916514255db1ae1661406f0283df756baf960d14 |
train | DCPF.solve | Solves a DC power flow. | pylon/dc_pf.py | def solve(self):
""" Solves a DC power flow.
"""
case = self.case
logger.info("Starting DC power flow [%s]." % case.name)
t0 = time.time()
# Update bus indexes.
self.case.index_buses()
# Find the index of the refence bus.
ref_idx = self._get_refer... | def solve(self):
""" Solves a DC power flow.
"""
case = self.case
logger.info("Starting DC power flow [%s]." % case.name)
t0 = time.time()
# Update bus indexes.
self.case.index_buses()
# Find the index of the refence bus.
ref_idx = self._get_refer... | [
"Solves",
"a",
"DC",
"power",
"flow",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/dc_pf.py#L66-L95 | [
"def",
"solve",
"(",
"self",
")",
":",
"case",
"=",
"self",
".",
"case",
"logger",
".",
"info",
"(",
"\"Starting DC power flow [%s].\"",
"%",
"case",
".",
"name",
")",
"t0",
"=",
"time",
".",
"time",
"(",
")",
"# Update bus indexes.",
"self",
".",
"case"... | 916514255db1ae1661406f0283df756baf960d14 |
train | DCPF._get_reference_index | Returns the index of the reference bus. | pylon/dc_pf.py | def _get_reference_index(self, case):
""" Returns the index of the reference bus.
"""
refs = [bus._i for bus in case.connected_buses if bus.type == REFERENCE]
if len(refs) == 1:
return refs [0]
else:
logger.error("Single swing bus required for DCPF.")
... | def _get_reference_index(self, case):
""" Returns the index of the reference bus.
"""
refs = [bus._i for bus in case.connected_buses if bus.type == REFERENCE]
if len(refs) == 1:
return refs [0]
else:
logger.error("Single swing bus required for DCPF.")
... | [
"Returns",
"the",
"index",
"of",
"the",
"reference",
"bus",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/dc_pf.py#L101-L109 | [
"def",
"_get_reference_index",
"(",
"self",
",",
"case",
")",
":",
"refs",
"=",
"[",
"bus",
".",
"_i",
"for",
"bus",
"in",
"case",
".",
"connected_buses",
"if",
"bus",
".",
"type",
"==",
"REFERENCE",
"]",
"if",
"len",
"(",
"refs",
")",
"==",
"1",
"... | 916514255db1ae1661406f0283df756baf960d14 |
train | DCPF._get_v_angle_guess | Make the vector of voltage phase guesses. | pylon/dc_pf.py | def _get_v_angle_guess(self, case):
""" Make the vector of voltage phase guesses.
"""
v_angle = array([bus.v_angle * (pi / 180.0)
for bus in case.connected_buses])
return v_angle | def _get_v_angle_guess(self, case):
""" Make the vector of voltage phase guesses.
"""
v_angle = array([bus.v_angle * (pi / 180.0)
for bus in case.connected_buses])
return v_angle | [
"Make",
"the",
"vector",
"of",
"voltage",
"phase",
"guesses",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/dc_pf.py#L115-L120 | [
"def",
"_get_v_angle_guess",
"(",
"self",
",",
"case",
")",
":",
"v_angle",
"=",
"array",
"(",
"[",
"bus",
".",
"v_angle",
"*",
"(",
"pi",
"/",
"180.0",
")",
"for",
"bus",
"in",
"case",
".",
"connected_buses",
"]",
")",
"return",
"v_angle"
] | 916514255db1ae1661406f0283df756baf960d14 |
train | DCPF._get_v_angle | Calculates the voltage phase angles. | pylon/dc_pf.py | def _get_v_angle(self, case, B, v_angle_guess, p_businj, iref):
""" Calculates the voltage phase angles.
"""
buses = case.connected_buses
pv_idxs = [bus._i for bus in buses if bus.type == PV]
pq_idxs = [bus._i for bus in buses if bus.type == PQ]
pvpq_idxs = pv_idxs + pq_... | def _get_v_angle(self, case, B, v_angle_guess, p_businj, iref):
""" Calculates the voltage phase angles.
"""
buses = case.connected_buses
pv_idxs = [bus._i for bus in buses if bus.type == PV]
pq_idxs = [bus._i for bus in buses if bus.type == PQ]
pvpq_idxs = pv_idxs + pq_... | [
"Calculates",
"the",
"voltage",
"phase",
"angles",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/dc_pf.py#L126-L159 | [
"def",
"_get_v_angle",
"(",
"self",
",",
"case",
",",
"B",
",",
"v_angle_guess",
",",
"p_businj",
",",
"iref",
")",
":",
"buses",
"=",
"case",
".",
"connected_buses",
"pv_idxs",
"=",
"[",
"bus",
".",
"_i",
"for",
"bus",
"in",
"buses",
"if",
"bus",
".... | 916514255db1ae1661406f0283df756baf960d14 |
train | DCPF._update_model | Updates the case with values computed from the voltage phase
angle solution. | pylon/dc_pf.py | def _update_model(self, case, B, Bsrc, v_angle, p_srcinj, p_ref, ref_idx):
""" Updates the case with values computed from the voltage phase
angle solution.
"""
iref = ref_idx
base_mva = case.base_mva
buses = case.connected_buses
branches = case.online_branches... | def _update_model(self, case, B, Bsrc, v_angle, p_srcinj, p_ref, ref_idx):
""" Updates the case with values computed from the voltage phase
angle solution.
"""
iref = ref_idx
base_mva = case.base_mva
buses = case.connected_buses
branches = case.online_branches... | [
"Updates",
"the",
"case",
"with",
"values",
"computed",
"from",
"the",
"voltage",
"phase",
"angle",
"solution",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/dc_pf.py#L165-L192 | [
"def",
"_update_model",
"(",
"self",
",",
"case",
",",
"B",
",",
"Bsrc",
",",
"v_angle",
",",
"p_srcinj",
",",
"p_ref",
",",
"ref_idx",
")",
":",
"iref",
"=",
"ref_idx",
"base_mva",
"=",
"case",
".",
"base_mva",
"buses",
"=",
"case",
".",
"connected_bu... | 916514255db1ae1661406f0283df756baf960d14 |
train | Bus.reset | Resets the readonly variables. | pylon/case.py | def reset(self):
""" Resets the readonly variables.
"""
self.p_lmbda = 0.0
self.q_lmbda = 0.0
self.mu_vmin = 0.0
self.mu_vmax = 0.0 | def reset(self):
""" Resets the readonly variables.
"""
self.p_lmbda = 0.0
self.q_lmbda = 0.0
self.mu_vmin = 0.0
self.mu_vmax = 0.0 | [
"Resets",
"the",
"readonly",
"variables",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/case.py#L115-L121 | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"p_lmbda",
"=",
"0.0",
"self",
".",
"q_lmbda",
"=",
"0.0",
"self",
".",
"mu_vmin",
"=",
"0.0",
"self",
".",
"mu_vmax",
"=",
"0.0"
] | 916514255db1ae1661406f0283df756baf960d14 |
train | Branch.reset | Resets the readonly variables. | pylon/case.py | def reset(self):
""" Resets the readonly variables.
"""
self.p_from = 0.0
self.p_to = 0.0
self.q_from = 0.0
self.q_to = 0.0
self.mu_s_from = 0.0
self.mu_s_to = 0.0
self.mu_angmin = 0.0
self.mu_angmax = 0.0 | def reset(self):
""" Resets the readonly variables.
"""
self.p_from = 0.0
self.p_to = 0.0
self.q_from = 0.0
self.q_to = 0.0
self.mu_s_from = 0.0
self.mu_s_to = 0.0
self.mu_angmin = 0.0
self.mu_angmax = 0.0 | [
"Resets",
"the",
"readonly",
"variables",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/case.py#L196-L208 | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"p_from",
"=",
"0.0",
"self",
".",
"p_to",
"=",
"0.0",
"self",
".",
"q_from",
"=",
"0.0",
"self",
".",
"q_to",
"=",
"0.0",
"self",
".",
"mu_s_from",
"=",
"0.0",
"self",
".",
"mu_s_to",
"=",
"0.0... | 916514255db1ae1661406f0283df756baf960d14 |
train | Case.getSbus | Returns the net complex bus power injection vector in p.u. | pylon/case.py | def getSbus(self, buses=None):
""" Returns the net complex bus power injection vector in p.u.
"""
bs = self.buses if buses is None else buses
s = array([self.s_surplus(v) / self.base_mva for v in bs])
return s | def getSbus(self, buses=None):
""" Returns the net complex bus power injection vector in p.u.
"""
bs = self.buses if buses is None else buses
s = array([self.s_surplus(v) / self.base_mva for v in bs])
return s | [
"Returns",
"the",
"net",
"complex",
"bus",
"power",
"injection",
"vector",
"in",
"p",
".",
"u",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/case.py#L270-L275 | [
"def",
"getSbus",
"(",
"self",
",",
"buses",
"=",
"None",
")",
":",
"bs",
"=",
"self",
".",
"buses",
"if",
"buses",
"is",
"None",
"else",
"buses",
"s",
"=",
"array",
"(",
"[",
"self",
".",
"s_surplus",
"(",
"v",
")",
"/",
"self",
".",
"base_mva",... | 916514255db1ae1661406f0283df756baf960d14 |
train | Case.sort_generators | Reorders the list of generators according to bus index. | pylon/case.py | def sort_generators(self):
""" Reorders the list of generators according to bus index.
"""
self.generators.sort(key=lambda gn: gn.bus._i) | def sort_generators(self):
""" Reorders the list of generators according to bus index.
"""
self.generators.sort(key=lambda gn: gn.bus._i) | [
"Reorders",
"the",
"list",
"of",
"generators",
"according",
"to",
"bus",
"index",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/case.py#L280-L283 | [
"def",
"sort_generators",
"(",
"self",
")",
":",
"self",
".",
"generators",
".",
"sort",
"(",
"key",
"=",
"lambda",
"gn",
":",
"gn",
".",
"bus",
".",
"_i",
")"
] | 916514255db1ae1661406f0283df756baf960d14 |
train | Case.index_buses | Updates the indices of all buses.
@param start: Starting index, typically 0 or 1.
@type start: int | pylon/case.py | def index_buses(self, buses=None, start=0):
""" Updates the indices of all buses.
@param start: Starting index, typically 0 or 1.
@type start: int
"""
bs = self.connected_buses if buses is None else buses
for i, b in enumerate(bs):
b._i = start + i | def index_buses(self, buses=None, start=0):
""" Updates the indices of all buses.
@param start: Starting index, typically 0 or 1.
@type start: int
"""
bs = self.connected_buses if buses is None else buses
for i, b in enumerate(bs):
b._i = start + i | [
"Updates",
"the",
"indices",
"of",
"all",
"buses",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/case.py#L289-L297 | [
"def",
"index_buses",
"(",
"self",
",",
"buses",
"=",
"None",
",",
"start",
"=",
"0",
")",
":",
"bs",
"=",
"self",
".",
"connected_buses",
"if",
"buses",
"is",
"None",
"else",
"buses",
"for",
"i",
",",
"b",
"in",
"enumerate",
"(",
"bs",
")",
":",
... | 916514255db1ae1661406f0283df756baf960d14 |
train | Case.index_branches | Updates the indices of all branches.
@param start: Starting index, typically 0 or 1.
@type start: int | pylon/case.py | def index_branches(self, branches=None, start=0):
""" Updates the indices of all branches.
@param start: Starting index, typically 0 or 1.
@type start: int
"""
ln = self.online_branches if branches is None else branches
for i, l in enumerate(ln):
l._i = start... | def index_branches(self, branches=None, start=0):
""" Updates the indices of all branches.
@param start: Starting index, typically 0 or 1.
@type start: int
"""
ln = self.online_branches if branches is None else branches
for i, l in enumerate(ln):
l._i = start... | [
"Updates",
"the",
"indices",
"of",
"all",
"branches",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/case.py#L300-L308 | [
"def",
"index_branches",
"(",
"self",
",",
"branches",
"=",
"None",
",",
"start",
"=",
"0",
")",
":",
"ln",
"=",
"self",
".",
"online_branches",
"if",
"branches",
"is",
"None",
"else",
"branches",
"for",
"i",
",",
"l",
"in",
"enumerate",
"(",
"ln",
"... | 916514255db1ae1661406f0283df756baf960d14 |
train | Case.s_supply | Returns the total complex power generation capacity. | pylon/case.py | def s_supply(self, bus):
""" Returns the total complex power generation capacity.
"""
Sg = array([complex(g.p, g.q) for g in self.generators if
(g.bus == bus) and not g.is_load], dtype=complex64)
if len(Sg):
return sum(Sg)
else:
return ... | def s_supply(self, bus):
""" Returns the total complex power generation capacity.
"""
Sg = array([complex(g.p, g.q) for g in self.generators if
(g.bus == bus) and not g.is_load], dtype=complex64)
if len(Sg):
return sum(Sg)
else:
return ... | [
"Returns",
"the",
"total",
"complex",
"power",
"generation",
"capacity",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/case.py#L314-L323 | [
"def",
"s_supply",
"(",
"self",
",",
"bus",
")",
":",
"Sg",
"=",
"array",
"(",
"[",
"complex",
"(",
"g",
".",
"p",
",",
"g",
".",
"q",
")",
"for",
"g",
"in",
"self",
".",
"generators",
"if",
"(",
"g",
".",
"bus",
"==",
"bus",
")",
"and",
"n... | 916514255db1ae1661406f0283df756baf960d14 |
train | Case.s_demand | Returns the total complex power demand. | pylon/case.py | def s_demand(self, bus):
""" Returns the total complex power demand.
"""
Svl = array([complex(g.p, g.q) for g in self.generators if
(g.bus == bus) and g.is_load], dtype=complex64)
Sd = complex(bus.p_demand, bus.q_demand)
return -sum(Svl) + Sd | def s_demand(self, bus):
""" Returns the total complex power demand.
"""
Svl = array([complex(g.p, g.q) for g in self.generators if
(g.bus == bus) and g.is_load], dtype=complex64)
Sd = complex(bus.p_demand, bus.q_demand)
return -sum(Svl) + Sd | [
"Returns",
"the",
"total",
"complex",
"power",
"demand",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/case.py#L326-L334 | [
"def",
"s_demand",
"(",
"self",
",",
"bus",
")",
":",
"Svl",
"=",
"array",
"(",
"[",
"complex",
"(",
"g",
".",
"p",
",",
"g",
".",
"q",
")",
"for",
"g",
"in",
"self",
".",
"generators",
"if",
"(",
"g",
".",
"bus",
"==",
"bus",
")",
"and",
"... | 916514255db1ae1661406f0283df756baf960d14 |
train | Case.getYbus | Based on makeYbus.m from MATPOWER by Ray Zimmerman, developed at
PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for more
information.
@rtype: tuple
@return: A triple consisting of the bus admittance matrix (i.e. for all
buses) and the matrices Yf and Yt which, when... | pylon/case.py | def getYbus(self, buses=None, branches=None):
""" Based on makeYbus.m from MATPOWER by Ray Zimmerman, developed at
PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for more
information.
@rtype: tuple
@return: A triple consisting of the bus admittance matrix (i.e. for... | def getYbus(self, buses=None, branches=None):
""" Based on makeYbus.m from MATPOWER by Ray Zimmerman, developed at
PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for more
information.
@rtype: tuple
@return: A triple consisting of the bus admittance matrix (i.e. for... | [
"Based",
"on",
"makeYbus",
".",
"m",
"from",
"MATPOWER",
"by",
"Ray",
"Zimmerman",
"developed",
"at",
"PSERC",
"Cornell",
".",
"See",
"U",
"{",
"http",
":",
"//",
"www",
".",
"pserc",
".",
"cornell",
".",
"edu",
"/",
"matpower",
"/",
"}",
"for",
"mor... | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/case.py#L346-L423 | [
"def",
"getYbus",
"(",
"self",
",",
"buses",
"=",
"None",
",",
"branches",
"=",
"None",
")",
":",
"buses",
"=",
"self",
".",
"buses",
"if",
"buses",
"is",
"None",
"else",
"buses",
"branches",
"=",
"self",
".",
"branches",
"if",
"branches",
"is",
"Non... | 916514255db1ae1661406f0283df756baf960d14 |
train | Case.makeB | Based on makeB.m from MATPOWER by Ray Zimmerman, developed at
PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for more
information.
@param method: Specify "XB" or "BX" method.
@type method: string
@rtype: tuple
@return: Two matrices, B prime and B double pr... | pylon/case.py | def makeB(self, buses=None, branches=None, method="XB"):
""" Based on makeB.m from MATPOWER by Ray Zimmerman, developed at
PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for more
information.
@param method: Specify "XB" or "BX" method.
@type method: string
... | def makeB(self, buses=None, branches=None, method="XB"):
""" Based on makeB.m from MATPOWER by Ray Zimmerman, developed at
PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for more
information.
@param method: Specify "XB" or "BX" method.
@type method: string
... | [
"Based",
"on",
"makeB",
".",
"m",
"from",
"MATPOWER",
"by",
"Ray",
"Zimmerman",
"developed",
"at",
"PSERC",
"Cornell",
".",
"See",
"U",
"{",
"http",
":",
"//",
"www",
".",
"pserc",
".",
"cornell",
".",
"edu",
"/",
"matpower",
"/",
"}",
"for",
"more",... | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/case.py#L431-L470 | [
"def",
"makeB",
"(",
"self",
",",
"buses",
"=",
"None",
",",
"branches",
"=",
"None",
",",
"method",
"=",
"\"XB\"",
")",
":",
"buses",
"=",
"self",
".",
"connected_buses",
"if",
"buses",
"is",
"None",
"else",
"buses",
"branches",
"=",
"self",
".",
"o... | 916514255db1ae1661406f0283df756baf960d14 |
train | Case.makeBdc | The bus real power injections are related to bus voltage angles
by::
P = Bbus * Va + Pbusinj
The real power flows at the from end the lines are related to the bus
voltage angles by::
Pf = Bf * Va + Pfinj
| Pf | | Bff Bft | | Vaf | | Pfinj... | pylon/case.py | def makeBdc(self, buses=None, branches=None):
""" The bus real power injections are related to bus voltage angles
by::
P = Bbus * Va + Pbusinj
The real power flows at the from end the lines are related to the bus
voltage angles by::
Pf = Bf * Va + Pfinj
... | def makeBdc(self, buses=None, branches=None):
""" The bus real power injections are related to bus voltage angles
by::
P = Bbus * Va + Pbusinj
The real power flows at the from end the lines are related to the bus
voltage angles by::
Pf = Bf * Va + Pfinj
... | [
"The",
"bus",
"real",
"power",
"injections",
"are",
"related",
"to",
"bus",
"voltage",
"angles",
"by",
"::",
"P",
"=",
"Bbus",
"*",
"Va",
"+",
"Pbusinj"
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/case.py#L476-L540 | [
"def",
"makeBdc",
"(",
"self",
",",
"buses",
"=",
"None",
",",
"branches",
"=",
"None",
")",
":",
"buses",
"=",
"self",
".",
"connected_buses",
"if",
"buses",
"is",
"None",
"else",
"buses",
"branches",
"=",
"self",
".",
"online_branches",
"if",
"branches... | 916514255db1ae1661406f0283df756baf960d14 |
train | Case.dSbus_dV | Based on dSbus_dV.m from MATPOWER by Ray Zimmerman, developed at
PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for more
information.
@return: The partial derivatives of power injection w.r.t. voltage
magnitude and voltage angle.
@rtype: tuple | pylon/case.py | def dSbus_dV(self, Y, V):
""" Based on dSbus_dV.m from MATPOWER by Ray Zimmerman, developed at
PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for more
information.
@return: The partial derivatives of power injection w.r.t. voltage
magnitude and voltage ang... | def dSbus_dV(self, Y, V):
""" Based on dSbus_dV.m from MATPOWER by Ray Zimmerman, developed at
PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for more
information.
@return: The partial derivatives of power injection w.r.t. voltage
magnitude and voltage ang... | [
"Based",
"on",
"dSbus_dV",
".",
"m",
"from",
"MATPOWER",
"by",
"Ray",
"Zimmerman",
"developed",
"at",
"PSERC",
"Cornell",
".",
"See",
"U",
"{",
"http",
":",
"//",
"www",
".",
"pserc",
".",
"cornell",
".",
"edu",
"/",
"matpower",
"/",
"}",
"for",
"mor... | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/case.py#L548-L569 | [
"def",
"dSbus_dV",
"(",
"self",
",",
"Y",
",",
"V",
")",
":",
"ib",
"=",
"range",
"(",
"len",
"(",
"V",
")",
")",
"I",
"=",
"Y",
"*",
"V",
"diagV",
"=",
"csr_matrix",
"(",
"(",
"V",
",",
"(",
"ib",
",",
"ib",
")",
")",
")",
"diagIbus",
"=... | 916514255db1ae1661406f0283df756baf960d14 |
train | Case.dIbr_dV | Based on dIbr_dV.m from MATPOWER by Ray Zimmerman, developed at
PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for more
information.
@return: The partial derivatives of branch currents w.r.t. voltage
magnitude and voltage angle.
@rtype: tuple | pylon/case.py | def dIbr_dV(self, Yf, Yt, V):
""" Based on dIbr_dV.m from MATPOWER by Ray Zimmerman, developed at
PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for more
information.
@return: The partial derivatives of branch currents w.r.t. voltage
magnitude and voltage ... | def dIbr_dV(self, Yf, Yt, V):
""" Based on dIbr_dV.m from MATPOWER by Ray Zimmerman, developed at
PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for more
information.
@return: The partial derivatives of branch currents w.r.t. voltage
magnitude and voltage ... | [
"Based",
"on",
"dIbr_dV",
".",
"m",
"from",
"MATPOWER",
"by",
"Ray",
"Zimmerman",
"developed",
"at",
"PSERC",
"Cornell",
".",
"See",
"U",
"{",
"http",
":",
"//",
"www",
".",
"pserc",
".",
"cornell",
".",
"edu",
"/",
"matpower",
"/",
"}",
"for",
"more... | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/case.py#L575-L598 | [
"def",
"dIbr_dV",
"(",
"self",
",",
"Yf",
",",
"Yt",
",",
"V",
")",
":",
"i",
"=",
"range",
"(",
"len",
"(",
"V",
")",
")",
"Vnorm",
"=",
"V",
"/",
"abs",
"(",
"V",
")",
"diagV",
"=",
"csr_matrix",
"(",
"(",
"V",
",",
"(",
"i",
",",
"i",
... | 916514255db1ae1661406f0283df756baf960d14 |
train | Case.dSbr_dV | Based on dSbr_dV.m from MATPOWER by Ray Zimmerman, developed at
PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for more
information.
@return: The branch power flow vectors and the partial derivatives of
branch power flow w.r.t voltage magnitude and voltage angle.
... | pylon/case.py | def dSbr_dV(self, Yf, Yt, V, buses=None, branches=None):
""" Based on dSbr_dV.m from MATPOWER by Ray Zimmerman, developed at
PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for more
information.
@return: The branch power flow vectors and the partial derivatives of
... | def dSbr_dV(self, Yf, Yt, V, buses=None, branches=None):
""" Based on dSbr_dV.m from MATPOWER by Ray Zimmerman, developed at
PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for more
information.
@return: The branch power flow vectors and the partial derivatives of
... | [
"Based",
"on",
"dSbr_dV",
".",
"m",
"from",
"MATPOWER",
"by",
"Ray",
"Zimmerman",
"developed",
"at",
"PSERC",
"Cornell",
".",
"See",
"U",
"{",
"http",
":",
"//",
"www",
".",
"pserc",
".",
"cornell",
".",
"edu",
"/",
"matpower",
"/",
"}",
"for",
"more... | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/case.py#L604-L656 | [
"def",
"dSbr_dV",
"(",
"self",
",",
"Yf",
",",
"Yt",
",",
"V",
",",
"buses",
"=",
"None",
",",
"branches",
"=",
"None",
")",
":",
"buses",
"=",
"self",
".",
"buses",
"if",
"buses",
"is",
"None",
"else",
"buses",
"branches",
"=",
"self",
".",
"bra... | 916514255db1ae1661406f0283df756baf960d14 |
train | Case.dAbr_dV | Based on dAbr_dV.m from MATPOWER by Ray Zimmerman, developed at
PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for more
information.
@rtype: tuple
@return: The partial derivatives of the squared flow magnitudes w.r.t
voltage magnitude and voltage angle giv... | pylon/case.py | def dAbr_dV(self, dSf_dVa, dSf_dVm, dSt_dVa, dSt_dVm, Sf, St):
""" Based on dAbr_dV.m from MATPOWER by Ray Zimmerman, developed at
PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for more
information.
@rtype: tuple
@return: The partial derivatives of the squared flo... | def dAbr_dV(self, dSf_dVa, dSf_dVm, dSt_dVa, dSt_dVm, Sf, St):
""" Based on dAbr_dV.m from MATPOWER by Ray Zimmerman, developed at
PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for more
information.
@rtype: tuple
@return: The partial derivatives of the squared flo... | [
"Based",
"on",
"dAbr_dV",
".",
"m",
"from",
"MATPOWER",
"by",
"Ray",
"Zimmerman",
"developed",
"at",
"PSERC",
"Cornell",
".",
"See",
"U",
"{",
"http",
":",
"//",
"www",
".",
"pserc",
".",
"cornell",
".",
"edu",
"/",
"matpower",
"/",
"}",
"for",
"more... | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/case.py#L662-L689 | [
"def",
"dAbr_dV",
"(",
"self",
",",
"dSf_dVa",
",",
"dSf_dVm",
",",
"dSt_dVa",
",",
"dSt_dVm",
",",
"Sf",
",",
"St",
")",
":",
"il",
"=",
"range",
"(",
"len",
"(",
"Sf",
")",
")",
"dAf_dPf",
"=",
"csr_matrix",
"(",
"(",
"2",
"*",
"Sf",
".",
"re... | 916514255db1ae1661406f0283df756baf960d14 |
train | Case.d2Sbus_dV2 | Based on d2Sbus_dV2.m from MATPOWER by Ray Zimmerman, developed
at PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for
more information.
@rtype: tuple
@return: The 2nd derivatives of power injection w.r.t. voltage. | pylon/case.py | def d2Sbus_dV2(self, Ybus, V, lam):
""" Based on d2Sbus_dV2.m from MATPOWER by Ray Zimmerman, developed
at PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for
more information.
@rtype: tuple
@return: The 2nd derivatives of power injection w.r.t. voltage.
"""... | def d2Sbus_dV2(self, Ybus, V, lam):
""" Based on d2Sbus_dV2.m from MATPOWER by Ray Zimmerman, developed
at PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for
more information.
@rtype: tuple
@return: The 2nd derivatives of power injection w.r.t. voltage.
"""... | [
"Based",
"on",
"d2Sbus_dV2",
".",
"m",
"from",
"MATPOWER",
"by",
"Ray",
"Zimmerman",
"developed",
"at",
"PSERC",
"Cornell",
".",
"See",
"U",
"{",
"http",
":",
"//",
"www",
".",
"pserc",
".",
"cornell",
".",
"edu",
"/",
"matpower",
"/",
"}",
"for",
"m... | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/case.py#L695-L722 | [
"def",
"d2Sbus_dV2",
"(",
"self",
",",
"Ybus",
",",
"V",
",",
"lam",
")",
":",
"nb",
"=",
"len",
"(",
"V",
")",
"ib",
"=",
"range",
"(",
"nb",
")",
"Ibus",
"=",
"Ybus",
"*",
"V",
"diaglam",
"=",
"csr_matrix",
"(",
"(",
"lam",
",",
"(",
"ib",
... | 916514255db1ae1661406f0283df756baf960d14 |
train | Case.d2Ibr_dV2 | Based on d2Ibr_dV2.m from MATPOWER by Ray Zimmerman, developed
at PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for
more information.
@rtype: tuple
@return: The 2nd derivatives of complex branch current w.r.t. voltage. | pylon/case.py | def d2Ibr_dV2(self, Ybr, V, lam):
""" Based on d2Ibr_dV2.m from MATPOWER by Ray Zimmerman, developed
at PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for
more information.
@rtype: tuple
@return: The 2nd derivatives of complex branch current w.r.t. voltage.
... | def d2Ibr_dV2(self, Ybr, V, lam):
""" Based on d2Ibr_dV2.m from MATPOWER by Ray Zimmerman, developed
at PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for
more information.
@rtype: tuple
@return: The 2nd derivatives of complex branch current w.r.t. voltage.
... | [
"Based",
"on",
"d2Ibr_dV2",
".",
"m",
"from",
"MATPOWER",
"by",
"Ray",
"Zimmerman",
"developed",
"at",
"PSERC",
"Cornell",
".",
"See",
"U",
"{",
"http",
":",
"//",
"www",
".",
"pserc",
".",
"cornell",
".",
"edu",
"/",
"matpower",
"/",
"}",
"for",
"mo... | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/case.py#L728-L745 | [
"def",
"d2Ibr_dV2",
"(",
"self",
",",
"Ybr",
",",
"V",
",",
"lam",
")",
":",
"nb",
"=",
"len",
"(",
"V",
")",
"ib",
"=",
"range",
"(",
"nb",
")",
"diaginvVm",
"=",
"csr_matrix",
"(",
"(",
"ones",
"(",
"nb",
")",
"/",
"abs",
"(",
"V",
")",
"... | 916514255db1ae1661406f0283df756baf960d14 |
train | Case.d2Sbr_dV2 | Based on d2Sbr_dV2.m from MATPOWER by Ray Zimmerman, developed
at PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for
more information.
@rtype: tuple
@return: The 2nd derivatives of complex power flow w.r.t. voltage. | pylon/case.py | def d2Sbr_dV2(self, Cbr, Ybr, V, lam):
""" Based on d2Sbr_dV2.m from MATPOWER by Ray Zimmerman, developed
at PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for
more information.
@rtype: tuple
@return: The 2nd derivatives of complex power flow w.r.t. voltage.
... | def d2Sbr_dV2(self, Cbr, Ybr, V, lam):
""" Based on d2Sbr_dV2.m from MATPOWER by Ray Zimmerman, developed
at PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for
more information.
@rtype: tuple
@return: The 2nd derivatives of complex power flow w.r.t. voltage.
... | [
"Based",
"on",
"d2Sbr_dV2",
".",
"m",
"from",
"MATPOWER",
"by",
"Ray",
"Zimmerman",
"developed",
"at",
"PSERC",
"Cornell",
".",
"See",
"U",
"{",
"http",
":",
"//",
"www",
".",
"pserc",
".",
"cornell",
".",
"edu",
"/",
"matpower",
"/",
"}",
"for",
"mo... | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/case.py#L751-L779 | [
"def",
"d2Sbr_dV2",
"(",
"self",
",",
"Cbr",
",",
"Ybr",
",",
"V",
",",
"lam",
")",
":",
"nb",
"=",
"len",
"(",
"V",
")",
"nl",
"=",
"len",
"(",
"lam",
")",
"ib",
"=",
"range",
"(",
"nb",
")",
"il",
"=",
"range",
"(",
"nl",
")",
"diaglam",
... | 916514255db1ae1661406f0283df756baf960d14 |
train | Case.d2ASbr_dV2 | Based on d2ASbr_dV2.m from MATPOWER by Ray Zimmerman, developed
at PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for
more information.
@rtype: tuple
@return: The 2nd derivatives of |complex power flow|**2 w.r.t. V. | pylon/case.py | def d2ASbr_dV2(self, dSbr_dVa, dSbr_dVm, Sbr, Cbr, Ybr, V, lam):
""" Based on d2ASbr_dV2.m from MATPOWER by Ray Zimmerman, developed
at PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for
more information.
@rtype: tuple
@return: The 2nd derivatives of |complex power... | def d2ASbr_dV2(self, dSbr_dVa, dSbr_dVm, Sbr, Cbr, Ybr, V, lam):
""" Based on d2ASbr_dV2.m from MATPOWER by Ray Zimmerman, developed
at PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for
more information.
@rtype: tuple
@return: The 2nd derivatives of |complex power... | [
"Based",
"on",
"d2ASbr_dV2",
".",
"m",
"from",
"MATPOWER",
"by",
"Ray",
"Zimmerman",
"developed",
"at",
"PSERC",
"Cornell",
".",
"See",
"U",
"{",
"http",
":",
"//",
"www",
".",
"pserc",
".",
"cornell",
".",
"edu",
"/",
"matpower",
"/",
"}",
"for",
"m... | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/case.py#L785-L805 | [
"def",
"d2ASbr_dV2",
"(",
"self",
",",
"dSbr_dVa",
",",
"dSbr_dVm",
",",
"Sbr",
",",
"Cbr",
",",
"Ybr",
",",
"V",
",",
"lam",
")",
":",
"il",
"=",
"range",
"(",
"len",
"(",
"lam",
")",
")",
"diaglam",
"=",
"csr_matrix",
"(",
"(",
"lam",
",",
"(... | 916514255db1ae1661406f0283df756baf960d14 |
train | Case.d2AIbr_dV2 | Based on d2AIbr_dV2.m from MATPOWER by Ray Zimmerman, developed
at PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for
more information.
@rtype: tuple
@return: The 2nd derivatives of |complex current|**2 w.r.t. V. | pylon/case.py | def d2AIbr_dV2(self, dIbr_dVa, dIbr_dVm, Ibr, Ybr, V, lam):
""" Based on d2AIbr_dV2.m from MATPOWER by Ray Zimmerman, developed
at PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for
more information.
@rtype: tuple
@return: The 2nd derivatives of |complex current|**... | def d2AIbr_dV2(self, dIbr_dVa, dIbr_dVm, Ibr, Ybr, V, lam):
""" Based on d2AIbr_dV2.m from MATPOWER by Ray Zimmerman, developed
at PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for
more information.
@rtype: tuple
@return: The 2nd derivatives of |complex current|**... | [
"Based",
"on",
"d2AIbr_dV2",
".",
"m",
"from",
"MATPOWER",
"by",
"Ray",
"Zimmerman",
"developed",
"at",
"PSERC",
"Cornell",
".",
"See",
"U",
"{",
"http",
":",
"//",
"www",
".",
"pserc",
".",
"cornell",
".",
"edu",
"/",
"matpower",
"/",
"}",
"for",
"m... | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/case.py#L811-L831 | [
"def",
"d2AIbr_dV2",
"(",
"self",
",",
"dIbr_dVa",
",",
"dIbr_dVm",
",",
"Ibr",
",",
"Ybr",
",",
"V",
",",
"lam",
")",
":",
"il",
"=",
"range",
"(",
"len",
"(",
"lam",
")",
")",
"diaglam",
"=",
"csr_matrix",
"(",
"(",
"lam",
",",
"(",
"il",
","... | 916514255db1ae1661406f0283df756baf960d14 |
train | Case.pf_solution | Based on pfsoln.m from MATPOWER by Ray Zimmerman, developed
at PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for
more information.
Updates buses, generators and branches to match a power flow solution. | pylon/case.py | def pf_solution(self, Ybus, Yf, Yt, V):
""" Based on pfsoln.m from MATPOWER by Ray Zimmerman, developed
at PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for
more information.
Updates buses, generators and branches to match a power flow solution.
"""
buses ... | def pf_solution(self, Ybus, Yf, Yt, V):
""" Based on pfsoln.m from MATPOWER by Ray Zimmerman, developed
at PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for
more information.
Updates buses, generators and branches to match a power flow solution.
"""
buses ... | [
"Based",
"on",
"pfsoln",
".",
"m",
"from",
"MATPOWER",
"by",
"Ray",
"Zimmerman",
"developed",
"at",
"PSERC",
"Cornell",
".",
"See",
"U",
"{",
"http",
":",
"//",
"www",
".",
"pserc",
".",
"cornell",
".",
"edu",
"/",
"matpower",
"/",
"}",
"for",
"more"... | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/case.py#L837-L905 | [
"def",
"pf_solution",
"(",
"self",
",",
"Ybus",
",",
"Yf",
",",
"Yt",
",",
"V",
")",
":",
"buses",
"=",
"self",
".",
"connected_buses",
"branches",
"=",
"self",
".",
"online_branches",
"generators",
"=",
"self",
".",
"online_generators",
"self",
".",
"re... | 916514255db1ae1661406f0283df756baf960d14 |
train | Case.reset | Resets the readonly variables for all of the case components. | pylon/case.py | def reset(self):
""" Resets the readonly variables for all of the case components.
"""
for bus in self.buses:
bus.reset()
for branch in self.branches:
branch.reset()
for generator in self.generators:
generator.reset() | def reset(self):
""" Resets the readonly variables for all of the case components.
"""
for bus in self.buses:
bus.reset()
for branch in self.branches:
branch.reset()
for generator in self.generators:
generator.reset() | [
"Resets",
"the",
"readonly",
"variables",
"for",
"all",
"of",
"the",
"case",
"components",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/case.py#L911-L919 | [
"def",
"reset",
"(",
"self",
")",
":",
"for",
"bus",
"in",
"self",
".",
"buses",
":",
"bus",
".",
"reset",
"(",
")",
"for",
"branch",
"in",
"self",
".",
"branches",
":",
"branch",
".",
"reset",
"(",
")",
"for",
"generator",
"in",
"self",
".",
"ge... | 916514255db1ae1661406f0283df756baf960d14 |
train | Case.save_matpower | Serialize the case as a MATPOWER data file. | pylon/case.py | def save_matpower(self, fd):
""" Serialize the case as a MATPOWER data file.
"""
from pylon.io import MATPOWERWriter
MATPOWERWriter(self).write(fd) | def save_matpower(self, fd):
""" Serialize the case as a MATPOWER data file.
"""
from pylon.io import MATPOWERWriter
MATPOWERWriter(self).write(fd) | [
"Serialize",
"the",
"case",
"as",
"a",
"MATPOWER",
"data",
"file",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/case.py#L925-L929 | [
"def",
"save_matpower",
"(",
"self",
",",
"fd",
")",
":",
"from",
"pylon",
".",
"io",
"import",
"MATPOWERWriter",
"MATPOWERWriter",
"(",
"self",
")",
".",
"write",
"(",
"fd",
")"
] | 916514255db1ae1661406f0283df756baf960d14 |
train | Case.save_psse | Serialize the case as a PSS/E data file. | pylon/case.py | def save_psse(self, fd):
""" Serialize the case as a PSS/E data file.
"""
from pylon.io import PSSEWriter
return PSSEWriter(self).write(fd) | def save_psse(self, fd):
""" Serialize the case as a PSS/E data file.
"""
from pylon.io import PSSEWriter
return PSSEWriter(self).write(fd) | [
"Serialize",
"the",
"case",
"as",
"a",
"PSS",
"/",
"E",
"data",
"file",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/case.py#L940-L944 | [
"def",
"save_psse",
"(",
"self",
",",
"fd",
")",
":",
"from",
"pylon",
".",
"io",
"import",
"PSSEWriter",
"return",
"PSSEWriter",
"(",
"self",
")",
".",
"write",
"(",
"fd",
")"
] | 916514255db1ae1661406f0283df756baf960d14 |
train | Case.load_psat | Returns a case object from the given PSAT data file. | pylon/case.py | def load_psat(cls, fd):
""" Returns a case object from the given PSAT data file.
"""
from pylon.io.psat import PSATReader
return PSATReader().read(fd) | def load_psat(cls, fd):
""" Returns a case object from the given PSAT data file.
"""
from pylon.io.psat import PSATReader
return PSATReader().read(fd) | [
"Returns",
"a",
"case",
"object",
"from",
"the",
"given",
"PSAT",
"data",
"file",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/case.py#L960-L964 | [
"def",
"load_psat",
"(",
"cls",
",",
"fd",
")",
":",
"from",
"pylon",
".",
"io",
".",
"psat",
"import",
"PSATReader",
"return",
"PSATReader",
"(",
")",
".",
"read",
"(",
"fd",
")"
] | 916514255db1ae1661406f0283df756baf960d14 |
train | Case.save_rst | Save a reStructuredText representation of the case. | pylon/case.py | def save_rst(self, fd):
""" Save a reStructuredText representation of the case.
"""
from pylon.io import ReSTWriter
ReSTWriter(self).write(fd) | def save_rst(self, fd):
""" Save a reStructuredText representation of the case.
"""
from pylon.io import ReSTWriter
ReSTWriter(self).write(fd) | [
"Save",
"a",
"reStructuredText",
"representation",
"of",
"the",
"case",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/case.py#L967-L971 | [
"def",
"save_rst",
"(",
"self",
",",
"fd",
")",
":",
"from",
"pylon",
".",
"io",
"import",
"ReSTWriter",
"ReSTWriter",
"(",
"self",
")",
".",
"write",
"(",
"fd",
")"
] | 916514255db1ae1661406f0283df756baf960d14 |
train | Case.save_csv | Saves the case as a series of Comma-Separated Values. | pylon/case.py | def save_csv(self, fd):
""" Saves the case as a series of Comma-Separated Values.
"""
from pylon.io.excel import CSVWriter
CSVWriter(self).write(fd) | def save_csv(self, fd):
""" Saves the case as a series of Comma-Separated Values.
"""
from pylon.io.excel import CSVWriter
CSVWriter(self).write(fd) | [
"Saves",
"the",
"case",
"as",
"a",
"series",
"of",
"Comma",
"-",
"Separated",
"Values",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/case.py#L974-L978 | [
"def",
"save_csv",
"(",
"self",
",",
"fd",
")",
":",
"from",
"pylon",
".",
"io",
".",
"excel",
"import",
"CSVWriter",
"CSVWriter",
"(",
"self",
")",
".",
"write",
"(",
"fd",
")"
] | 916514255db1ae1661406f0283df756baf960d14 |
train | Case.save_excel | Saves the case as an Excel spreadsheet. | pylon/case.py | def save_excel(self, fd):
""" Saves the case as an Excel spreadsheet.
"""
from pylon.io.excel import ExcelWriter
ExcelWriter(self).write(fd) | def save_excel(self, fd):
""" Saves the case as an Excel spreadsheet.
"""
from pylon.io.excel import ExcelWriter
ExcelWriter(self).write(fd) | [
"Saves",
"the",
"case",
"as",
"an",
"Excel",
"spreadsheet",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/case.py#L981-L985 | [
"def",
"save_excel",
"(",
"self",
",",
"fd",
")",
":",
"from",
"pylon",
".",
"io",
".",
"excel",
"import",
"ExcelWriter",
"ExcelWriter",
"(",
"self",
")",
".",
"write",
"(",
"fd",
")"
] | 916514255db1ae1661406f0283df756baf960d14 |
train | Case.save_dot | Saves a representation of the case in the Graphviz DOT language. | pylon/case.py | def save_dot(self, fd):
""" Saves a representation of the case in the Graphviz DOT language.
"""
from pylon.io import DotWriter
DotWriter(self).write(fd) | def save_dot(self, fd):
""" Saves a representation of the case in the Graphviz DOT language.
"""
from pylon.io import DotWriter
DotWriter(self).write(fd) | [
"Saves",
"a",
"representation",
"of",
"the",
"case",
"in",
"the",
"Graphviz",
"DOT",
"language",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/case.py#L988-L992 | [
"def",
"save_dot",
"(",
"self",
",",
"fd",
")",
":",
"from",
"pylon",
".",
"io",
"import",
"DotWriter",
"DotWriter",
"(",
"self",
")",
".",
"write",
"(",
"fd",
")"
] | 916514255db1ae1661406f0283df756baf960d14 |
train | save_model | Saves a CasADi model to disk.
:param model_folder: Folder where the precompiled CasADi model will be stored.
:param model_name: Name of the model.
:param model: Model instance.
:param compiler_options: Dictionary of compiler options. | src/pymoca/backends/casadi/api.py | def save_model(model_folder: str, model_name: str, model: Model,
compiler_options: Dict[str, str]) -> None:
"""
Saves a CasADi model to disk.
:param model_folder: Folder where the precompiled CasADi model will be stored.
:param model_name: Name of the model.
:param model: Model insta... | def save_model(model_folder: str, model_name: str, model: Model,
compiler_options: Dict[str, str]) -> None:
"""
Saves a CasADi model to disk.
:param model_folder: Folder where the precompiled CasADi model will be stored.
:param model_name: Name of the model.
:param model: Model insta... | [
"Saves",
"a",
"CasADi",
"model",
"to",
"disk",
"."
] | pymoca/pymoca | python | https://github.com/pymoca/pymoca/blob/14b5eb7425e96689de6cc5c10f400895d586a978/src/pymoca/backends/casadi/api.py#L159-L244 | [
"def",
"save_model",
"(",
"model_folder",
":",
"str",
",",
"model_name",
":",
"str",
",",
"model",
":",
"Model",
",",
"compiler_options",
":",
"Dict",
"[",
"str",
",",
"str",
"]",
")",
"->",
"None",
":",
"objects",
"=",
"{",
"'dae_residual'",
":",
"Non... | 14b5eb7425e96689de6cc5c10f400895d586a978 |
train | load_model | Loads a precompiled CasADi model into a CachedModel instance.
:param model_folder: Folder where the precompiled CasADi model is located.
:param model_name: Name of the model.
:param compiler_options: Dictionary of compiler options.
:returns: CachedModel instance. | src/pymoca/backends/casadi/api.py | def load_model(model_folder: str, model_name: str, compiler_options: Dict[str, str]) -> CachedModel:
"""
Loads a precompiled CasADi model into a CachedModel instance.
:param model_folder: Folder where the precompiled CasADi model is located.
:param model_name: Name of the model.
:param compiler_opt... | def load_model(model_folder: str, model_name: str, compiler_options: Dict[str, str]) -> CachedModel:
"""
Loads a precompiled CasADi model into a CachedModel instance.
:param model_folder: Folder where the precompiled CasADi model is located.
:param model_name: Name of the model.
:param compiler_opt... | [
"Loads",
"a",
"precompiled",
"CasADi",
"model",
"into",
"a",
"CachedModel",
"instance",
"."
] | pymoca/pymoca | python | https://github.com/pymoca/pymoca/blob/14b5eb7425e96689de6cc5c10f400895d586a978/src/pymoca/backends/casadi/api.py#L246-L416 | [
"def",
"load_model",
"(",
"model_folder",
":",
"str",
",",
"model_name",
":",
"str",
",",
"compiler_options",
":",
"Dict",
"[",
"str",
",",
"str",
"]",
")",
"->",
"CachedModel",
":",
"db_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"model_folder",
... | 14b5eb7425e96689de6cc5c10f400895d586a978 |
train | IPOPFSolver.solve | Solves AC optimal power flow. | contrib/ipopf.py | def solve(self):
""" Solves AC optimal power flow.
"""
case = self.om.case
base_mva = case.base_mva
# TODO: Explain this value.
self.opt["cost_mult"] = 1e-4
# Unpack the OPF model.
bs, ln, gn, _ = self._unpack_model(self.om)
# Compute problem dime... | def solve(self):
""" Solves AC optimal power flow.
"""
case = self.om.case
base_mva = case.base_mva
# TODO: Explain this value.
self.opt["cost_mult"] = 1e-4
# Unpack the OPF model.
bs, ln, gn, _ = self._unpack_model(self.om)
# Compute problem dime... | [
"Solves",
"AC",
"optimal",
"power",
"flow",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/contrib/ipopf.py#L66-L441 | [
"def",
"solve",
"(",
"self",
")",
":",
"case",
"=",
"self",
".",
"om",
".",
"case",
"base_mva",
"=",
"case",
".",
"base_mva",
"# TODO: Explain this value.",
"self",
".",
"opt",
"[",
"\"cost_mult\"",
"]",
"=",
"1e-4",
"# Unpack the OPF model.",
"bs",
",",
"... | 916514255db1ae1661406f0283df756baf960d14 |
train | _ACPF.solve | Runs a power flow
@rtype: dict
@return: Solution dictionary with the following keys:
- C{V} - final complex voltages
- C{converged} - boolean value indicating if the solver
converged or not
- C{iterations} - the number of ite... | pylon/ac_pf.py | def solve(self):
""" Runs a power flow
@rtype: dict
@return: Solution dictionary with the following keys:
- C{V} - final complex voltages
- C{converged} - boolean value indicating if the solver
converged or not
- C{it... | def solve(self):
""" Runs a power flow
@rtype: dict
@return: Solution dictionary with the following keys:
- C{V} - final complex voltages
- C{converged} - boolean value indicating if the solver
converged or not
- C{it... | [
"Runs",
"a",
"power",
"flow"
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/ac_pf.py#L94-L166 | [
"def",
"solve",
"(",
"self",
")",
":",
"# Zero result attributes.",
"self",
".",
"case",
".",
"reset",
"(",
")",
"# Retrieve the contents of the case.",
"b",
",",
"l",
",",
"g",
",",
"_",
",",
"_",
",",
"_",
",",
"_",
"=",
"self",
".",
"_unpack_case",
... | 916514255db1ae1661406f0283df756baf960d14 |
train | _ACPF._unpack_case | Returns the contents of the case to be used in the OPF. | pylon/ac_pf.py | def _unpack_case(self, case):
""" Returns the contents of the case to be used in the OPF.
"""
base_mva = case.base_mva
b = case.connected_buses
l = case.online_branches
g = case.online_generators
nb = len(b)
nl = len(l)
ng = len(g)
return ... | def _unpack_case(self, case):
""" Returns the contents of the case to be used in the OPF.
"""
base_mva = case.base_mva
b = case.connected_buses
l = case.online_branches
g = case.online_generators
nb = len(b)
nl = len(l)
ng = len(g)
return ... | [
"Returns",
"the",
"contents",
"of",
"the",
"case",
"to",
"be",
"used",
"in",
"the",
"OPF",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/ac_pf.py#L169-L180 | [
"def",
"_unpack_case",
"(",
"self",
",",
"case",
")",
":",
"base_mva",
"=",
"case",
".",
"base_mva",
"b",
"=",
"case",
".",
"connected_buses",
"l",
"=",
"case",
".",
"online_branches",
"g",
"=",
"case",
".",
"online_generators",
"nb",
"=",
"len",
"(",
... | 916514255db1ae1661406f0283df756baf960d14 |
train | _ACPF._index_buses | Set up indexing for updating v. | pylon/ac_pf.py | def _index_buses(self, buses):
""" Set up indexing for updating v.
"""
refs = [bus._i for bus in buses if bus.type == REFERENCE]
# if len(refs) != 1:
# raise SlackBusError
pv = [bus._i for bus in buses if bus.type == PV]
pq = [bus._i for bus in buses if bus.type... | def _index_buses(self, buses):
""" Set up indexing for updating v.
"""
refs = [bus._i for bus in buses if bus.type == REFERENCE]
# if len(refs) != 1:
# raise SlackBusError
pv = [bus._i for bus in buses if bus.type == PV]
pq = [bus._i for bus in buses if bus.type... | [
"Set",
"up",
"indexing",
"for",
"updating",
"v",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/ac_pf.py#L183-L193 | [
"def",
"_index_buses",
"(",
"self",
",",
"buses",
")",
":",
"refs",
"=",
"[",
"bus",
".",
"_i",
"for",
"bus",
"in",
"buses",
"if",
"bus",
".",
"type",
"==",
"REFERENCE",
"]",
"# if len(refs) != 1:",
"# raise SlackBusError",
"pv",
"=",
"[",
... | 916514255db1ae1661406f0283df756baf960d14 |
train | _ACPF._initial_voltage | Returns the initial vector of complex bus voltages.
The bus voltage vector contains the set point for generator
(including ref bus) buses, and the reference angle of the swing
bus, as well as an initial guess for remaining magnitudes and
angles. | pylon/ac_pf.py | def _initial_voltage(self, buses, generators):
""" Returns the initial vector of complex bus voltages.
The bus voltage vector contains the set point for generator
(including ref bus) buses, and the reference angle of the swing
bus, as well as an initial guess for remaining magnitudes an... | def _initial_voltage(self, buses, generators):
""" Returns the initial vector of complex bus voltages.
The bus voltage vector contains the set point for generator
(including ref bus) buses, and the reference angle of the swing
bus, as well as an initial guess for remaining magnitudes an... | [
"Returns",
"the",
"initial",
"vector",
"of",
"complex",
"bus",
"voltages",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/ac_pf.py#L196-L216 | [
"def",
"_initial_voltage",
"(",
"self",
",",
"buses",
",",
"generators",
")",
":",
"Vm",
"=",
"array",
"(",
"[",
"bus",
".",
"v_magnitude",
"for",
"bus",
"in",
"buses",
"]",
")",
"# Initial bus voltage angles in radians.",
"Va",
"=",
"array",
"(",
"[",
"bu... | 916514255db1ae1661406f0283df756baf960d14 |
train | NewtonPF._run_power_flow | Solves the power flow using a full Newton's method. | pylon/ac_pf.py | def _run_power_flow(self, Ybus, Sbus, V, pv, pq, pvpq, **kw_args):
""" Solves the power flow using a full Newton's method.
"""
Va = angle(V)
Vm = abs(V)
# Initial evaluation of F(x0)...
F = self._evaluate_function(Ybus, V, Sbus, pv, pq)
# ...and convergency check... | def _run_power_flow(self, Ybus, Sbus, V, pv, pq, pvpq, **kw_args):
""" Solves the power flow using a full Newton's method.
"""
Va = angle(V)
Vm = abs(V)
# Initial evaluation of F(x0)...
F = self._evaluate_function(Ybus, V, Sbus, pv, pq)
# ...and convergency check... | [
"Solves",
"the",
"power",
"flow",
"using",
"a",
"full",
"Newton",
"s",
"method",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/ac_pf.py#L235-L262 | [
"def",
"_run_power_flow",
"(",
"self",
",",
"Ybus",
",",
"Sbus",
",",
"V",
",",
"pv",
",",
"pq",
",",
"pvpq",
",",
"*",
"*",
"kw_args",
")",
":",
"Va",
"=",
"angle",
"(",
"V",
")",
"Vm",
"=",
"abs",
"(",
"V",
")",
"# Initial evaluation of F(x0)..."... | 916514255db1ae1661406f0283df756baf960d14 |
train | NewtonPF._one_iteration | Performs one Newton iteration. | pylon/ac_pf.py | def _one_iteration(self, F, Ybus, V, Vm, Va, pv, pq, pvpq):
""" Performs one Newton iteration.
"""
J = self._build_jacobian(Ybus, V, pv, pq, pvpq)
# Update step.
dx = -1 * spsolve(J, F)
# dx = -1 * linalg.lstsq(J.todense(), F)[0]
# Update voltage vector.
... | def _one_iteration(self, F, Ybus, V, Vm, Va, pv, pq, pvpq):
""" Performs one Newton iteration.
"""
J = self._build_jacobian(Ybus, V, pv, pq, pvpq)
# Update step.
dx = -1 * spsolve(J, F)
# dx = -1 * linalg.lstsq(J.todense(), F)[0]
# Update voltage vector.
... | [
"Performs",
"one",
"Newton",
"iteration",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/ac_pf.py#L265-L287 | [
"def",
"_one_iteration",
"(",
"self",
",",
"F",
",",
"Ybus",
",",
"V",
",",
"Vm",
",",
"Va",
",",
"pv",
",",
"pq",
",",
"pvpq",
")",
":",
"J",
"=",
"self",
".",
"_build_jacobian",
"(",
"Ybus",
",",
"V",
",",
"pv",
",",
"pq",
",",
"pvpq",
")",... | 916514255db1ae1661406f0283df756baf960d14 |
train | NewtonPF._evaluate_function | Evaluates F(x). | pylon/ac_pf.py | def _evaluate_function(self, Ybus, V, Sbus, pv, pq):
""" Evaluates F(x).
"""
mis = multiply(V, conj(Ybus * V)) - Sbus
F = r_[mis[pv].real, mis[pq].real, mis[pq].imag]
return F | def _evaluate_function(self, Ybus, V, Sbus, pv, pq):
""" Evaluates F(x).
"""
mis = multiply(V, conj(Ybus * V)) - Sbus
F = r_[mis[pv].real, mis[pq].real, mis[pq].imag]
return F | [
"Evaluates",
"F",
"(",
"x",
")",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/ac_pf.py#L293-L300 | [
"def",
"_evaluate_function",
"(",
"self",
",",
"Ybus",
",",
"V",
",",
"Sbus",
",",
"pv",
",",
"pq",
")",
":",
"mis",
"=",
"multiply",
"(",
"V",
",",
"conj",
"(",
"Ybus",
"*",
"V",
")",
")",
"-",
"Sbus",
"F",
"=",
"r_",
"[",
"mis",
"[",
"pv",
... | 916514255db1ae1661406f0283df756baf960d14 |
train | NewtonPF._check_convergence | Checks if the solution has converged to within the specified
tolerance. | pylon/ac_pf.py | def _check_convergence(self, F):
""" Checks if the solution has converged to within the specified
tolerance.
"""
normF = linalg.norm(F, Inf)
if normF < self.tolerance:
converged = True
else:
converged = False
if self.verbose:
... | def _check_convergence(self, F):
""" Checks if the solution has converged to within the specified
tolerance.
"""
normF = linalg.norm(F, Inf)
if normF < self.tolerance:
converged = True
else:
converged = False
if self.verbose:
... | [
"Checks",
"if",
"the",
"solution",
"has",
"converged",
"to",
"within",
"the",
"specified",
"tolerance",
"."
] | rwl/pylon | python | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/ac_pf.py#L306-L319 | [
"def",
"_check_convergence",
"(",
"self",
",",
"F",
")",
":",
"normF",
"=",
"linalg",
".",
"norm",
"(",
"F",
",",
"Inf",
")",
"if",
"normF",
"<",
"self",
".",
"tolerance",
":",
"converged",
"=",
"True",
"else",
":",
"converged",
"=",
"False",
"if",
... | 916514255db1ae1661406f0283df756baf960d14 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.