-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathProgram.cs
79 lines (68 loc) · 2.78 KB
/
Program.cs
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
76
77
78
79
using System;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading;
using Mars.Common.Core.Logging;
using Mars.Components.Layers;
using Mars.Components.Starter;
using Mars.Core.Simulation;
using Mars.Interfaces;
using Mars.Interfaces.Model;
using SOHModel.Bicycle.Model;
using SOHModel.Bicycle.Parking;
using SOHModel.Bicycle.Rental;
using SOHModel.Car.Model;
using SOHModel.Car.Parking;
using SOHModel.Car.Rental;
using SOHModel.Domain.Graph;
using SOHModel.Multimodal.Model;
namespace SOHKellinghusenBox;
/// <summary>
/// This pre-defined starter program runs the the
/// <value>Kellinghusen scenario</value>
/// with outside passed arguments or
/// a default simulation inputConfiguration with CSV output and trips.
/// </summary>
internal static class Program
{
public static void Main(string[] args)
{
Thread.CurrentThread.CurrentCulture = new CultureInfo("EN-US");
LoggerFactory.SetLogLevel(LogLevel.Off);
var description = new ModelDescription();
description.AddLayer<SpatialGraphMediatorLayer>(new[] { typeof(ISpatialGraphLayer) });
description.AddLayer<BicycleParkingLayer>(new[] { typeof(IBicycleParkingLayer) });
description.AddLayer<BicycleRentalLayer>(new[] { typeof(IBicycleRentalLayer) });
description.AddLayer<CarParkingLayer>(new[] { typeof(ICarParkingLayer) });
description.AddLayer<CarRentalLayer>(new[] { typeof(ICarRentalLayer) });
description.AddLayer<HumanTravelerLayer>();
description.AddLayer<AgentSchedulerLayer<HumanTraveler, HumanTravelerLayer>>(
"HumanTravelerSchedulerLayer");
description.AddAgent<HumanTraveler, HumanTravelerLayer>();
description.AddEntity<Bicycle>();
description.AddEntity<RentalBicycle>();
description.AddEntity<Car>();
description.AddEntity<RentalCar>();
ISimulationContainer application;
if (args != null && args.Length != 0)
{
var container = CommandParser.ParseAndEvaluateArguments(description, args);
var config = container.SimulationConfig;
application = SimulationStarter.BuildApplication(description, config);
}
else
{
var file = File.ReadAllText("config_dammtor.json");
var simConfig = SimulationConfig.Deserialize(file);
application = SimulationStarter.BuildApplication(description, simConfig);
}
var simulation = application.Resolve<ISimulation>();
var watch = Stopwatch.StartNew();
var state = simulation.StartSimulation();
watch.Stop();
Console.WriteLine($"Executed iterations {state.Iterations} lasted {watch.Elapsed}");
application.Dispose();
}
}