Reputation: 881
I'm scheduling tasks for agents (factories) to do over the next X times periods. For each task I am recording an Amount_To_Produce and an OrderID. I'm using a series of lists, two per day. For three time periods, it looks something like this.
TimePeriod 1
Amount_To_Produce, OrderID
5,100
6,101
2,102
TimePeriod 2
Amount_To_Produce, OrderID
10,103
5,101
20,104
TimePeriod 3
Amount_To_Produce, OrderID
5,100
5,105
This works OK: I'm processing each day one at a time with:
(foreach list1 ... command)
but if I want to extend it to more days it's a pain.
Plus I need to relate it to another two lists that store the agent that's buying the goods along with the OrderID (notice above that one order can spill over multiple days). But that bit is OK - it's really the need for lists for each day that is the problem.
I'll know how many days into the future the agents are planning, so it doesn't have to be created dynamically. The only other idea I have is:
Day, Amount_To_Produce, OrderID
1,5,100
1,6,101
1,2,102
2,10,103
2,5,101
2,20,104
3,5,100
3,5,105
The problem with this that foreach will process Day 1's orders three times, not once.
Anyway: does Netlogo have a better data structure for managing this sort of thing?
What I'd really like is for each agent to have its own database, a series of tables that the agent can query with an SQL type command (any chance we could get this in NL7.0?)
In the meantime, how would you store these data please?
Upvotes: 0
Views: 295
Reputation: 9620
extensions [table]
globals [tbl1 tbl2 listOfTables]
to test
set tbl1 table:make
set tbl2 table:make
set listOfTables (list tbl1 tbl2)
table:put tbl1 1 [[5 100] [6 101] [2 102]]
show listOfTAbles
end
Upvotes: 3