def __init__(self, data_path, od_pair_data): self.Param, self.Links, self.LinkNum, self.NodeSet, self.From, self.To = getParam( data_path) self.od_pair_demand, self.od_pair_list, self.Origin_set, self.Destination_set, self.qrs = getDemand( od_pair_data) self.bc = Param['B'] / Param['Capacity (veh/h)']**4 self.Create_Model()
def service(): param = getParam() if isinstance(param, str): return param a, b = param if (abs(float(execute_microservice(b, int(b), minus))) > 0): return "<b> not Integer" return mult(a, b)
from pyomo.environ import * from pyomo.opt import SolverFactory from pyomo.opt import SolverStatus, TerminationCondition from scipy import sparse from getParam import getParam from getDemand import getDemand ### SETTING UP the DATA PATH and Directories curdir = os.getcwd() data_path = curdir + "\\Data\\SiouxFalls_net.txt" partition_network_path = curdir + "\\Data\\SFOutfile.csv" node_pos_path = curdir + "\\Data\\SiouxFalls_Nodes_Pos.txt" od_pair_data = curdir + "\\Data\\SiouxFalls_OD.txt" ### GETTING LINK and TRAVELTIME DATA Param, Links, LinkNum, NodeSet, From, To = getParam(data_path) od_pair_demand, od_pair_list, Origin_set, Destination_set, qrs = getDemand( od_pair_data) ### DEFINING the CAP RATIO in BPR FUNCT bc = Param['B'] / Param['Capacity (veh/h)']**4 ###DEFING the FLOW ORIGINATED FROM EVERY NODE: model = ConcreteModel() model.nodes = Set(initialize=NodeSet) model.arcs = Set(initialize=Links) model.origins = Set(initialize=Origin_set) model.destinations = Set(initialize=Destination_set) model.x = Var(model.arcs * model.origins, within=NonNegativeReals)
for c in range(1,clust_num+1): for ee in cbl[c]: for oo in os: la[ee,oo,c] = 1 x[ee,oo] = 1000 total_link_flow = {} bl_set = set() for c in range(1,clust_num+1): bl_set.update(cbl[c]) param, L, l2, l3, l4,l5 = getParam(data_path) A, B, C, D, E = getDemand(od_pair_data) bc =param['B']/param['Capacity (veh/h)']**4 tstt = [] xx = [] etta = 0.001 tstt_ = 10000000000 for iteration in range(1,400): # if iteration>1: # etta = 0.00755 # 0.008-3*iteration/100000 print("etta is " , etta) ADMM_Instance=Pricing(clust_num,x,la,etta) ADMM_Instance.updating_lagrangian_price()
def service(): param = getParam() if isinstance(param, str): return param a, b = param if (b == 0): return "cannot divide by zero" return div(a, b)
def service(): param = getParam() if isinstance(param, str): return param a,b = param return minus(a,b)
from scipy import sparse from sys import getsizeof # In[2]: #Homemade functions from getParam import getParam from getDemand import getDemand from objRule import objRule from flowBalRule import flowBalRule from flowLinkRule import flowLinkRule from costLinkRule import costLinkRule filenameNet = "Data/Anaheim/Anaheim_net.tntp" param, A, M, N, L = getParam(filenameNet) filenameTrip = "Data/Anaheim/Anaheim_trips.tntp" d, OD_pair = getDemand(filenameTrip, L) # # Model definitions # In[3]: model = ConcreteModel() model.links = RangeSet(0, len(A) - 1, 1) #Set of links model.od = RangeSet(0, M.shape[1] - 1, 1) #Set of OD pairs model.nodes = RangeSet(0, M.shape[0] - 1, 1) #Set of Nodes model.f = Var(model.links, within=NonNegativeReals) #set of link flows
def service(): param = getParam() if isinstance(param, str): return param a,b = param if(b==0): return "cannot modulo by zero" return modulo(a,b)