Skip to content

Commit

Permalink
ran black
Browse files Browse the repository at this point in the history
  • Loading branch information
zacharybinger committed Jan 8, 2024
1 parent 0ba045e commit c0d0c27
Showing 1 changed file with 20 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def build(self):
units=pyunits.kWh,
doc="annual energy produced by the plant in kWh",
)

self.land_req = Var(
initialize=7e7,
units=pyunits.acre,
Expand All @@ -77,12 +77,13 @@ def build(self):

self.electricity_constraint = Constraint(
expr=self.annual_energy
== -1 * self.electricity
== -1
* self.electricity
* pyunits.convert(1 * pyunits.year, to_units=pyunits.hour)
)

def load_surrogate(self):
print('Loading surrogate file...')
print("Loading surrogate file...")
self.surrogate_file = os.path.join(
os.path.dirname(__file__), "pv_surrogate.json"
)
Expand All @@ -107,21 +108,21 @@ def get_training_validation(self):
self.dataset_filename = os.path.join(
os.path.dirname(__file__), "data/dataset.pkl"
)
print('Loading Training Data...\n')
print("Loading Training Data...\n")
time_start = time.process_time()
pkl_data = pd.read_pickle(self.dataset_filename)
data = pkl_data.sample(n=int(len(pkl_data))) #FIX default this to 100% of data
data = pkl_data.sample(n=int(len(pkl_data))) # FIX default this to 100% of data
self.data_training, self.data_validation = split_training_validation(
data, self.training_fraction, seed=len(data)
)
time_stop = time.process_time()
print("Data Loading Time:", time_stop - time_start, "\n")

def create_surrogate(
self,
save=False,
):
self.sample_fraction = 0.1 # fraction of the generated data to train with. More flexible than n_samples.
self,
save=False,
):
self.sample_fraction = 0.1 # fraction of the generated data to train with. More flexible than n_samples.
self.training_fraction = 0.8

self.get_training_validation()
Expand Down Expand Up @@ -156,13 +157,16 @@ def create_surrogate(
# Create callable surrogate object
xmin, xmax = [self.design_size.bounds[0]], [self.design_size.bounds[1]]
input_bounds = {
self.input_labels[i]: (xmin[i], xmax[i]) for i in range(len(self.input_labels))
self.input_labels[i]: (xmin[i], xmax[i])
for i in range(len(self.input_labels))
}
rbf_surr = PysmoSurrogate(rbf_train, self.input_labels, self.output_labels, input_bounds)

rbf_surr = PysmoSurrogate(
rbf_train, self.input_labels, self.output_labels, input_bounds
)

# Save model to JSON
if (self.surrogate_file is not None) and (save is True):
print(f'Writing surrogate model to {self.surrogate_file}')
print(f"Writing surrogate model to {self.surrogate_file}")
model = rbf_surr.save_to_file(self.surrogate_file, overwrite=True)

# Revert back to standard output
Expand All @@ -172,7 +176,7 @@ def create_surrogate(
print("Model Training Time:", time_stop - time_start, "\n")

return rbf_surr


if __name__ == "__main__":
m = ConcreteModel()
Expand All @@ -185,4 +189,4 @@ def create_surrogate(
results = m.fs.pv.surrogate.evaluate_surrogate(
m.fs.pv.data_validation[m.fs.pv.input_labels]
)
print(results)
print(results)

0 comments on commit c0d0c27

Please sign in to comment.