exporting to mongo is now even better then befor

This commit is contained in:
2023-01-20 08:21:24 +01:00
parent 8c36302edc
commit a137f37603
5 changed files with 23 additions and 15 deletions
BIN
View File
Binary file not shown.
+10 -3
View File
@@ -38,10 +38,17 @@ class MongoExporter():
for transaction in step:
transaction["step"]=i
c[cmt].insert_one(transaction)
#c[cma].insert_many(market.asks)
# c[cmb].insert_many(market.bids)
for com,asks in market.asks.items():
for ask in asks:
ask["commodity"]=com
c[cma].insert_one(ask)
for com,bids in market.bids.items():
for bid in bids:
bid["commodity"]=com
c[cmb].insert_one(bid)
+7 -5
View File
@@ -41,11 +41,11 @@ env_config = {
# (1) Building houses
('Craft', {'skill_dist': "pareto", 'commodities': ["Gem"],'max_skill_amount_benefit':1.5}),
# (2) Trading collectible resources
('ContinuousDoubleAuction', {'max_num_orders': 10}),
('ContinuousDoubleAuction', {'max_num_orders': 10,'max_bid_ask':100}),
# (3) Movement and resource collection
('SimpleGather', {}),
('ExternalMarket',{'market_demand':{
'Gem': 11
'Gem': 65
}}),
],
@@ -57,7 +57,7 @@ env_config = {
# ===== STANDARD ARGUMENTS ======
# kwargs that are used by every Scenario class (i.e. defined in BaseEnvironment)
'agent_composition': {"BasicMobileAgent": 10,"TradingAgent":10}, # Number of non-planner agents (must be > 1)
'agent_composition': {"BasicMobileAgent": 10,"TradingAgent":2}, # Number of non-planner agents (must be > 1)
'world_size': [5, 5], # [Height, Width] of the env world
'episode_length': 256, # Number of timesteps per episode
'isoelastic_eta':0.001,
@@ -97,7 +97,7 @@ eval_env_config = {
# (1) Building houses
('Craft', {'skill_dist': "pareto", 'commodities': ["Gem"],'max_skill_amount_benefit':1.5}),
# (2) Trading collectible resources
('ContinuousDoubleAuction', {'max_num_orders': 10}),
('ContinuousDoubleAuction', {'max_num_orders': 10,'max_bid_ask':100}),
# (3) Movement and resource collection
('SimpleGather', {}),
('ExternalMarket',{'market_demand':{
@@ -113,7 +113,7 @@ eval_env_config = {
# ===== STANDARD ARGUMENTS ======
# kwargs that are used by every Scenario class (i.e. defined in BaseEnvironment)
'agent_composition': {"BasicMobileAgent": 20,"TradingAgent":5}, # Number of non-planner agents (must be > 1)
'agent_composition': {"BasicMobileAgent": 10,"TradingAgent":10}, # Number of non-planner agents (must be > 1)
'world_size': [1, 1], # [Height, Width] of the env world
'episode_length': 256, # Number of timesteps per episode
'allow_observation_scaling': True,
@@ -295,6 +295,8 @@ model_db=[None,None] # object for storing model
model = MaskablePPO("MlpPolicy",n_steps=int(env_config['episode_length']*2),ent_coef=0.001, vf_coef=0.5 ,gamma=0.99, learning_rate=4e-4,env=stackenv_basic, seed=500,verbose=1,device="cuda",tensorboard_log="./log")
model_trade=MaskablePPO("MlpPolicy",n_steps=int(env_config['episode_length']*2),ent_coef=0.001, vf_coef=0.5 ,gamma=0.99, learning_rate=4e-4,env=stackenv_traid, seed=500,verbose=1,device="cuda",tensorboard_log="./log")
model=model.load("basic.ai",stackenv_basic)
model_trade=model_trade.load("trade.ai",stackenv_traid)
n_agents=econ.n_agents
+6 -7
View File
@@ -40,13 +40,13 @@ env_config = {
# The order in which components reset, step, and generate obs follows their listed order below.
'components': [
# (1) Building houses
('Craft', {'skill_dist': "pareto", 'commodities': ["Gem"],'max_skill_amount_benefit':2}),
('Craft', {'skill_dist': "pareto", 'commodities': ["Gem"],'max_skill_amount_benefit':1.5}),
# (2) Trading collectible resources
('ContinuousDoubleAuction', {'max_num_orders': 10}),
('ContinuousDoubleAuction', {'max_num_orders': 10,'max_bid_ask':100}),
# (3) Movement and resource collection
('SimpleGather', {}),
('ExternalMarket',{'market_demand':{
'Gem': 15
'Gem': 90
}}),
],
@@ -58,14 +58,14 @@ env_config = {
# ===== STANDARD ARGUMENTS ======
# kwargs that are used by every Scenario class (i.e. defined in BaseEnvironment)
'agent_composition': {"BasicMobileAgent": 5,"TradingAgent":10}, # Number of non-planner agents (must be > 1)
'agent_composition': {"BasicMobileAgent": 2,"TradingAgent":5}, # Number of non-planner agents (must be > 1)
'world_size': [5, 5], # [Height, Width] of the env world
'episode_length': 256, # Number of timesteps per episode
'isoelastic_eta':0.001,
'allow_observation_scaling': True,
'dense_log_frequency': 100,
'world_dense_log_frequency':1,
'energy_cost':0,
'energy_cost':0.2,
'energy_warmup_method': "auto",
'energy_warmup_constant': 4000,
@@ -82,7 +82,6 @@ env_config = {
'flatten_masks': True,
}
num_frames=1
CONNECTION_STRING = "mongodb://root:econ@localhost:27017/"
class TensorboardCallback(BaseCallback):
@@ -255,7 +254,7 @@ while True:
# trades=market.get_dense_log()
build=craft.get_dense_log()
met=econ.previous_episode_metrics
printReplay(econ,5)
#printReplay(econ,5)
#printMarket(trades)
#printBuilds(builds=build)
print("social/productivity: {}".format(met["social/productivity"]))
BIN
View File
Binary file not shown.