-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path00_One_Echelon.R
More file actions
75 lines (53 loc) · 2.97 KB
/
Copy path00_One_Echelon.R
File metadata and controls
75 lines (53 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#Rscript C:/LEAD_MODELS/NEW/2echelon-main/00_One_Echelon.R C:/LEAD_MODELS/NEW/2echelon-main/
#--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#Description:
# Script for executing scenarios.json:
# direct shipments from the branch in San Fernando to the consumers using a non-electric vehicle defined in args[3]
# it creates the inputs and the dependencies for wrapping function that connects to the next model (COPERT)
# args[1] = the location of the folder that contains the scripts, the INPUT, OUTPUT, SHAPEFILES folder to run the scenario
#
#
#---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#reading the parameters from the console
args= commandArgs(trailingOnly = TRUE)
if (length(args)==0) {
#stop("One arguments need to be supplied", call.=FALSE)
path_in = "C:/LEAD_MODELS/NEW/GITHUB_220930/2echelon-main"
} else if (length(args)==1) {
# # default output file
print("hola")
path_in =args[1]
}
#sourcing the libraries
setwd(path_in)
source("TwoEchelonModel_script.R")
source("TwoEchelonModel_IO.R")
source("Shapefile_to_Zone.R")
#predefined parameters
two_echelon_output_filename="output_two_echelon.json" #name of the output file with the results and all the information of the scenario
#read file with the scenarios
config = read_config(path_in)
facility = read_facility(path_in,1,config[3])
vehicle = read_vehicle(path_in,1,config[5])
zone=read_deliveryZone(path_in,1,F,NULL)
#initialization (vehicle, facility, NULL, NULL, config)
output = calculateSolutionLeg(zone,vehicle, facility, config,1)
dfOutput = data.frame('echelon'=1,
'zone_name'=c(zone[1]),
'zone_avg_size'=c(zone[2]),
'zone_area_km2'=c(zone[3]),
'zone_total_services'=c(zone[6]),
'zone_latitude'=c(zone[4]),
'zone_longitude'=c(zone[5]),
'facility_name' = c(facility[1]),
'facility_handling_time' = c(facility[2]),
'facility_latitude'=c(facility[3]),
'facility_longitude'=c(facility[4]),
'vehicle_name'= c(vehicle[1]),
'vehicle_capacity'= c(vehicle[2]),
'vehicle_velocicty_km.s'= c(vehicle[3]),
'vehicle_velocicty_stop_time'= c(vehicle[4]),
'total_distance_km' = c(output[1]),
'total_time_hours' = c(output[2]),
'number_vehicles' = c(output[3]))
write_outputJSON(path_in,dfOutput,two_echelon_output_filename)