Skip to content

Commit

Permalink
sims running, need csv write
Browse files Browse the repository at this point in the history
  • Loading branch information
akirillo committed Sep 2, 2021
1 parent 68253b4 commit a34a3a8
Show file tree
Hide file tree
Showing 127 changed files with 17,348 additions and 1,435 deletions.
199 changes: 0 additions & 199 deletions experiments/dutch_auctions/#dutch_auctions_neutral_sim.py#

This file was deleted.

12 changes: 7 additions & 5 deletions experiments/dutch_auctions/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from copy import deepcopy
import matplotlib.pyplot as plt

from pydss.pymaker.numeric import Wad, Rad, Ray
from pydss.util import RequireException
from experiments.experiment import Experiment

Expand Down Expand Up @@ -143,6 +144,10 @@ def run(self, sim_name):

historical_stats.append(deepcopy(state["stats"]))

self.write(
f"/bab-stablesims/experiments/dutch_auctions/results/{sim_name}_state.json", state, t
)

_, axs = plt.subplots(4)
time_range = list(range(self.parameters["timesteps"]))
plt.title(f"Chip: {float(state['clippers']['WETH'].chip)}, Tip: {float(state['clippers']['WETH'].tip)}")
Expand All @@ -151,16 +156,13 @@ def run(self, sim_name):
axs[2].plot(time_range, [stats["num_unsafe_vaults"] for stats in historical_stats])
axs[3].plot(time_range, [stats["incentive_amount"] for stats in historical_stats])
plt.savefig(f"/bab-stablesims/experiments/dutch_auctions/results/{sim_name}.png")
self.write(
f"/bab-stablesims/experiments/dutch_auctions/results/{sim_name}_state.json", state
)

def format_data(self, state, full_state=True):
data = state if full_state else state["stats"]
data = deepcopy(data)
for key, value in data.items():
if isinstance(value, (Ray, Rad, Wad)):
data[key] = float(data[value])
data[key] = float(value)
elif isinstance(value, dict):
data[key] = self.format_data(value)
elif hasattr(value, "__iter__"):
Expand All @@ -172,4 +174,4 @@ def write(self, filename, data, t):
with open(filename, "a") as f:
f.write("==================\n")
f.write("Timestep: {}".format(t))
f.write(self.format_data(data) + "\n")
f.write(str(self.format_data(data, False)) + "\n")
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit a34a3a8

Please sign in to comment.