Open jose-moran opened 1 year ago
In your code, you have lots of things that do computations as loops, for example https://github.com/devetak-m/rewiring-economy/blob/b9d325caca60d297249803a87e0ef25eedd5c5c7/src/firms.py#LL122C5-L127C5
Instead, you could use numpy to its full potential (and massively speed up your code) by using vectors, as
C = np.log(1/self.z* self.b ** (-self.b) * V**(1 - self.b) * h**(self.a * self.b))
this is much faster! There are other examples in your code where this can be arranged.
Very cool For time_for_simulation, it went from 120s to 26s. I am looking at more sophisticated vectorization methods(at least for me) when we deal with expectations and limited knowledge.
In your code, you have lots of things that do computations as loops, for example https://github.com/devetak-m/rewiring-economy/blob/b9d325caca60d297249803a87e0ef25eedd5c5c7/src/firms.py#LL122C5-L127C5
Instead, you could use numpy to its full potential (and massively speed up your code) by using vectors, as
this is much faster! There are other examples in your code where this can be arranged.