Hi all, Very new to this so please excuse my errors.
I want to create an agent based model using the mesa package (Python 3.6.3) to model solar generation, electricity use and grid exports. Ultimately I would like agents (households) to interact (ie trading energy between homes). For the first iteration of the model I want to show outcomes **without** interaction between agents, using a sample of real consumption and generation data. I.e. for each step (i), each household (j) will generate/use electricity based on the real world data series, i.e., indexing the corresponding consumption and generation values for that particular household at time period i. Here is a snippet of the dataframes with consumption and generation data (gen values are all zero because time periods are at night): >>con Customer 1 2 0 1 0.287 1.207 1 2 0.278 0.193 2 3 0.051 0.063 >>gen Customer Capacity 1 2 3 0 1 3.78 0.0 0.0 0.0 1 2 1.62 0.0 0.0 0.0 2 3 1.00 0.0 0.0 0.0 Column headings refer to time periods (t=1, t=2, etc). Capacity = battery capacity (which I will ignore for the moment). How do I define a 'step' such that for each customer number (unique id) and time period, the model indexes the appropriate consumption and generation values for that time period, and adds them to that agent? The correct row will always be the customer's unique id - 1, but the column will change with each step (i.e. for customer 1, at t=1 the consumption value should be 0.287, at t=2 it should be 1.207 and so on. Here is a sample of my code so far: class PowerAgent(Agent): def __init__(self, unique_id, model): super().__init__(unique_id, model) self.use = 0 self.gen = 0 def step(self): self.use += con.iloc[unique_id-1, <<code to show that for the ith step, we should index column i +2 >>] self.gen += gen.iloc[unique_id-1, <<code to show that for the ith step, we should index column i +1 >> ] Would appreciate pointers. I'm new to Python and mesa so all help is welcomed with much gratitude. _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor