11#!/usr/bin/env python
22"""
3- Use spaces instead of tabs, or configure your editor to transform tab to 4
4- spaces.
3+ Changelog:
4+ v1.0 - Changelog created. <08/03/2017>
5+
6+ Maintainer: Arthur Zachow Coelho ([email protected] ) 7+ Created (changelog): 08/03/2017
8+
9+ This module contains the Experiment class, which is the experiment or simulation itself.
10+
11+ Warning: Use spaces instead of tabs, or configure your editor to transform tab to 4 spaces.
512"""
613
714#Standard modules
@@ -21,7 +28,6 @@ class Experiment(object):
2128 '''
2229 Sets up an experiment.
2330 '''
24-
2531 def __init__ (self , k , net_file , group_size , net_name , table_fill_file = None ,
2632 flow = 0 , p_travel_time = False , p_drivers_link = False , p_od_pair = False , p_interval = 1 ,
2733 epsilon = 1.0 , p_drivers_route = False , TABLE_INITIAL_STATE = 'fixed' ,
@@ -48,31 +54,13 @@ def __init__(self, k, net_file, group_size, net_name, table_fill_file=None,
4854 self .mini = MINI
4955 self .maxi = MAXI
5056 self .fixed = fixed
51- #Init_network_data is to be erased
52- self .init_network_data (self .k , net_file , self .group_size , self .flow )
53-
54- if TABLE_INITIAL_STATE == 'coupling' :
55- self .TABLE_FILL = generate_table_fill (table_fill_file )
56-
57- def init_network_data (self , k , network_file , group_size , flow ):
58- '''
59- Initialize the network data.
60-
61- Inputs:
62- k: integer = Number of KSP routes to generate
63- network_file: file = .net file
64- group_size: integer = Size of the grouping
6557
66- This method set some of the attributes of the experiment but doesn't help much because
67- there are some attributes being set ''outside'' the class contructor method.
68- Needs to be changed in the future.
69- '''
7058 self .ODlist = []
7159 self .ODL = []
7260 self .ODheader = ""
7361
74- funtest = dec_test ( generateGraph )
75- self . Vo , self . Eo , odInputo = funtest ( network_file , flow = flow )
62+ self . Vo , self . Eo , odInputo = read_infos ( net_file , flow = flow )
63+
7664 for tup_od in odInputo :
7765 if round (tup_od [2 ]) % self .group_size != 0 :
7866 print tup_od [2 ]
@@ -110,6 +98,9 @@ def init_network_data(self, k, network_file, group_size, flow):
11098 for i in range (int (round (od_pair .numTravels ))):
11199 self .drivers .append (Driver (od_pair ))
112100
101+ if TABLE_INITIAL_STATE == 'coupling' :
102+ self .TABLE_FILL = generate_table_fill (table_fill_file )
103+
113104 def __repr__ (self ):
114105 """
115106 __repr__ method override.
@@ -347,6 +338,7 @@ def run_ql(self, num_episodes, alpha, decay):
347338 self .outputFile .write (headerstr + '\n ' )
348339
349340 for episode in range (num_episodes ):
341+ print_progress (episode + 1 , num_episodes )
350342 (instance , value ) = self .ql .runEpisode ()
351343 self .__print_step (episode , instance , qlTT = value )
352344
@@ -437,6 +429,7 @@ def travelTimeByOD(self, string_actions):
437429 for edge in path :
438430 traveltime += edgesTravelTimes [edge ]
439431 odTravelTimeDict [self .drivers [driverIdx ].od_s ()].append (traveltime )
432+
440433 return odTravelTimeDict
441434
442435 def calculateIndividualTravelTime (self , string_actions ):
0 commit comments