Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

noinst fix #31

Merged
merged 6 commits into from Oct 2, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 8 additions & 14 deletions d3ploy/no_inst.py
Expand Up @@ -177,19 +177,19 @@ def tock(self):
out_text += " demand " + str(self.commodity_demand[commod][time-1]) + "\n"
with open(commod +".txt", 'a') as f:
f.write(out_text)





def deploy_solver(self, commod, diff):
""" This function optimizes prototypes to deploy to minimize over
deployment of prototypes.

Paramters:
----------
commod: str
commodity driving deployment
diff: float
lack in supply

Returns:
--------
deploy_dict: dict
Expand All @@ -199,13 +199,13 @@ def deploy_solver(self, commod, diff):
diff = -1.0 * diff
proto_commod = self.commodity_dict[commod]
min_cap = min(proto_commod.values())
key_list = self.get_asc_key_list(self, proto_commod)
key_list = self.get_asc_key_list(proto_commod)

remainder = diff
deploy_dict = {}
for proto in key_list:
# if diff still smaller than the proto capacity,
if remainder >= proto_commod[proto]:

# get one
deploy_dict[proto] = 1
# see what the diff is now
Expand All @@ -215,7 +215,7 @@ def deploy_solver(self, commod, diff):
deploy_dict[proto] += 1
remainder -= proto_commod[proto]
return deploy_dict


def get_asc_key_list(self, dicti):
key_list = [' '] * len(dicti.values())
Expand Down Expand Up @@ -272,7 +272,6 @@ def extract_supply(self, agent, time, value, commod):
"""
Gather information on the available supply of a commodity over the
lifetime of the simulation.

Parameters
----------
agent : cyclus agent
Expand All @@ -292,7 +291,6 @@ def extract_demand(self, agent, time, value, commod):
"""
Gather information on the demand of a commodity over the
lifetime of the simulation.

Parameters
----------
agent : cyclus agent
Expand All @@ -310,7 +308,6 @@ def extract_demand(self, agent, time, value, commod):
def demand_calc(self, time):
"""
Calculate the electrical demand at a given timestep (time).

Parameters
----------
time : int
Expand All @@ -328,7 +325,6 @@ def moving_avg(self, ts, steps=1, std_dev = 0, back_steps=5):
Calculates the moving average of a previous [order] entries in
timeseries [ts]. It will automatically reduce the order if the
length of ts is shorter than the order.

Parameters:
-----------
ts : Array of doubles
Expand All @@ -352,7 +348,6 @@ def predict_arma(self, ts, steps=2, std_dev = 0, back_steps=5):
Predict the value of supply or demand at a given time step using the
currently available time series data. This method impliments an ARMA
calculation to perform the prediciton.

Parameters:
-----------
ts : Array of doubles
Expand Down Expand Up @@ -383,5 +378,4 @@ def predict_arch(self, ts, steps=2, std_dev = 0, back_steps=10):
step = 'h.' + str(steps)
x = forecast.mean.get(step)[len(v)-steps]
sd = math.sqrt(forecast.variance.get(step)[len(v)-steps]) * std_dev
return x+sd

return x+sd