protected override void Context() { base.Context(); _parentClassification = new Classification { ClassificationType = ClassificationType.Simulation, Name = "parent" }; _childEmptyClassification = new Classification { ClassificationType = ClassificationType.Simulation, Name = "childEmpty", Parent = _parentClassification }; _childClassification = new Classification { ClassificationType = ClassificationType.Simulation, Name = "child", Parent = _parentClassification }; _simulation = new ClassifiableSimulation { Subject = new IndividualSimulation() }; sut.AddClassificationsToTree(new[] { _childEmptyClassification, _parentClassification, _childClassification }); //do that after so that real node and node fakes are created when adding the classificaiton to the tree _project.AddClassification(_childEmptyClassification); _project.AddClassification(_parentClassification); _project.AddClassification(_childClassification); _childEmptyClassificationNode = _classificationNodesCache[_childEmptyClassification]; _childClassificationNode = _classificationNodesCache[_childClassification]; _parentClassificationNode = _childClassificationNode.ParentNode.DowncastTo <ITreeNode <IClassification> >(); _simulationNode = new SimulationNode(_simulation); _childClassificationNode.AddChild(_simulationNode); _parentClassificationNode = _childClassificationNode.ParentNode.DowncastTo <ITreeNode <IClassification> >(); A.CallTo(() => _explorerPresenter.NodeFor(_childEmptyClassification)).Returns(_childEmptyClassificationNode); A.CallTo(() => _explorerPresenter.NodeFor(_childClassification)).Returns(_childClassificationNode); A.CallTo(() => _explorerPresenter.NodeFor(_parentClassification)).Returns(_parentClassificationNode); }
protected override void Context() { base.Context(); _parentClassification = new Classification { ClassificationType = ClassificationType.Simulation, Name = "parent" }; _childClassification = new Classification { ClassificationType = ClassificationType.Simulation, Name = "child", Parent = _parentClassification }; sut.AddClassificationsToTree(new[] { _childClassification, _parentClassification }); //do that after so that real node and node fakes are created when adding the classificaiton to the tree _project.AddClassification(_childClassification); _project.AddClassification(_parentClassification); _simulation = new ClassifiableSimulation { Parent = _childClassification, Subject = A.Fake <ISimulation>().WithId("Sim") }; _childClassificationNode = _classificationNodesCache[_childClassification]; _simulationNode = new SimulationNode(_simulation); _childClassificationNode.AddChild(_simulationNode); _parentClassificationNode = _childClassificationNode.ParentNode.DowncastTo <ITreeNode <IClassification> >(); }
protected override void Context() { base.Context(); _individualSimulationComparison = new IndividualSimulationComparison(); _individualSimulationComparison.Curves.Add(new Curve("TOTO")); sut.InitializeAnalysis(_individualSimulationComparison); _simulation = A.Fake <IndividualSimulation>(); A.CallTo(() => _simulation.HasResults).Returns(true); var simulationNode = new SimulationNode(new ClassifiableSimulation { Subject = _simulation }); _dropEventArgs = new DragEventArgs(new DataObject(new DragDropInfo(new List <SimulationNode> { simulationNode })), 0, 0, 0, DragDropEffects.All, DragDropEffects.All); }
protected override void Context() { base.Context(); //create the following tree //human => oral=>S1 //oral=>S2 _humanClassification = new Classification { ClassificationType = ClassificationType.Simulation, Name = "human" }; _humanOralClassification = new Classification { ClassificationType = ClassificationType.Simulation, Name = "oral", Parent = _humanClassification }; _oralClassification = new Classification { ClassificationType = ClassificationType.Simulation, Name = "oral" }; sut.AddClassificationsToTree(new[] { _humanOralClassification, _humanClassification, _oralClassification }); _project.AddClassification(_humanOralClassification); _project.AddClassification(_humanClassification); _project.AddClassification(_oralClassification); _simulation1 = new ClassifiableSimulation { Parent = _humanOralClassification, Subject = new IndividualSimulation { Name = "S1" } }; _simulation2 = new ClassifiableSimulation { Parent = _oralClassification, Subject = new IndividualSimulation { Name = "S2" } }; _humanOralClassificationNode = _classificationNodesCache[_humanOralClassification]; _oralClassificationNode = _classificationNodesCache[_oralClassification]; _simulation1Node = new SimulationNode(_simulation1).Under(_humanOralClassificationNode); _simulation2Node = new SimulationNode(_simulation2).Under(_oralClassificationNode); _humanClassificationNode = _humanOralClassificationNode.ParentNode.DowncastTo <ITreeNode <IClassification> >(); A.CallTo(() => _explorerPresenter.NodeFor(_humanOralClassification)).Returns(_humanOralClassificationNode); A.CallTo(() => _explorerPresenter.NodeFor(_oralClassification)).Returns(_oralClassificationNode); A.CallTo(() => _explorerPresenter.NodeFor(_humanClassification)).Returns(_humanClassificationNode); }
protected override void Context() { base.Context(); _simulation1 = new ClassifiableSimulation { Subject = new IndividualSimulation { Id = "1" } }; _simulation2 = new ClassifiableSimulation { Subject = new IndividualSimulation { Id = "2" } }; var parentClassification = new Classification { ClassificationType = ClassificationType.Simulation }; _simulation3WithParent = new ClassifiableSimulation { Subject = new IndividualSimulation { Id = "3" }, Parent = parentClassification }; _observedData = new ClassifiableObservedData { Subject = new DataRepository() }; _project.AddClassifiable(_simulation1); _project.AddClassifiable(_simulation2); _project.AddClassifiable(_simulation3WithParent); _project.AddClassifiable(_observedData); var simulationNode1 = new SimulationNode(_simulation1); A.CallTo(() => _explorerPresenter.NodeFor(_simulation1)).Returns(simulationNode1); var simulationNode2 = new SimulationNode(_simulation2); A.CallTo(() => _explorerPresenter.NodeFor(_simulation2)).Returns(simulationNode2); A.CallTo(() => _explorerPresenter.NodeFor(_simulation3WithParent)).Returns(new SimulationNode(_simulation3WithParent)); A.CallTo(() => _explorerPresenter.NodeFor(_observedData)).Returns(new ObservedDataNode(_observedData)); var parentClassificationNode = new ClassificationNode(parentClassification); A.CallTo(() => _explorerPresenter.NodeFor(parentClassification)).Returns(parentClassificationNode); _simulationFolderNode.AddChild(simulationNode1); _simulationFolderNode.AddChild(simulationNode2); _simulationFolderNode.AddChild(parentClassificationNode); }
protected override void Context() { base.Context(); _originalClassification = new Classification { ClassificationType = ClassificationType.Simulation, Name = "Original" }; _targetClassification = new Classification { ClassificationType = ClassificationType.Simulation, Name = "Target" }; _simulation = new ClassifiableSimulation { Parent = _originalClassification, Subject = A.Fake <ISimulation>().WithName("S1") }; sut.AddClassificationsToTree(new[] { _originalClassification, _targetClassification }); _project.AddClassification(_originalClassification); _project.AddClassification(_targetClassification); _originalClassificationNode = _classificationNodesCache[_originalClassification]; _targetClassificationNode = _classificationNodesCache[_targetClassification]; _simulationNode = new SimulationNode(_simulation).Under(_originalClassificationNode); }
///<summary>Computes coefficients of linearized network eqns.</summary> private void NewCoeffs() { _lsv.Clear(); foreach (SimulationLink link in _links) { link.SimInvHeadLoss = 0; link.SimFlowCorrection = 0; } SimulationLink.ComputeMatrixCoeffs( net, _pHlModel, _links, _curves, _smat, _lsv); // Compute link coeffs. SimulationNode.ComputeEmitterCoeffs(net, _junctions, _smat, _lsv); // Compute emitter coeffs. SimulationNode.ComputeNodeCoeffs(_junctions, _smat, _lsv); // Compute node coeffs. SimulationValve.ComputeMatrixCoeffs(net, _lsv, _smat, _valves); // Compute valve coeffs. }
protected override void Context() { base.Context(); _dimensionFactory = A.Fake <IDimensionFactory>(); _individualSimulationComparison = new IndividualSimulationComparison(); var dataRepository = DomainHelperForSpecs.ObservedData(); var curve = new Curve(); curve.SetxData(dataRepository.BaseGrid, _dimensionFactory); curve.SetyData(dataRepository.FirstDataColumn(), _dimensionFactory); _individualSimulationComparison.AddCurve(curve); sut.InitializeAnalysis(_individualSimulationComparison); _simulation = A.Fake <IndividualSimulation>(); A.CallTo(() => _simulation.HasResults).Returns(true); var simulationNode = new SimulationNode(new ClassifiableSimulation { Subject = _simulation }); _dropEventArgs = new DragEventArgs(new DataObject(new DragDropInfo(new List <SimulationNode> { simulationNode })), 0, 0, 0, DragDropEffects.All, DragDropEffects.All); }
protected override void Context() { _buildingBlockIconRetriever = A.Fake <IBuildingBlockIconRetriever>(); _view = A.Fake <ISimulationExplorerView>(); A.CallTo(() => _view.TreeView).Returns(A.Fake <IUxTreeView>()); _treeNodeFactory = A.Fake <ITreeNodeFactory>(); _contextMenuFactory = A.Fake <ITreeNodeContextMenuFactory>(); _regionResolver = A.Fake <IRegionResolver>(); _buildingBlockInSimulationManager = A.Fake <IBuildingBlockInSimulationManager>(); _buildingBlockTask = A.Fake <IBuildingBlockTask>(); _toolTipNodeCreator = A.Fake <IToolTipPartCreator>(); _projectRetriever = A.Fake <IProjectRetriever>(); _multipleTreeNodeContextMenuFactory = A.Fake <IMultipleTreeNodeContextMenuFactory>(); _parameterAnalysablesInExplorerPresenter = A.Fake <IParameterAnalysablesInExplorerPresenter>(); _simulationComparisonTask = A.Fake <ISimulationComparisonTask>(); _simulationFolderNode = new RootNode(RootNodeTypes.SimulationFolder); _comparisonFolderNode = new RootNode(RootNodeTypes.ComparisonFolder); _project = new PKSimProject(); _usedObservedData = new UsedObservedData { Id = "UsedData" }; _simulation = new IndividualSimulation().WithName("individualSimulation").WithId("individualSimulation"); _populationSimulation = new PopulationSimulation().WithName("populationSimulation").WithId("populationSimulation"); _importedSimulaton = A.Fake <Simulation>().WithName("ImportedSimulation").WithId("ImportedSimulation"); A.CallTo(() => _importedSimulaton.IsImported).Returns(true); _simulation.Properties = new SimulationProperties(); _simulation.ModelProperties = new ModelProperties(); _simulation.ModelConfiguration = A.Fake <ModelConfiguration>(); _populationSimulation.Properties = new SimulationProperties(); _populationSimulation.ModelProperties = new ModelProperties(); _populationSimulation.ModelConfiguration = A.Fake <ModelConfiguration>(); _classificationPresenter = A.Fake <IClassificationPresenter>(); _project.AddBuildingBlock(_simulation); _project.AddBuildingBlock(_populationSimulation); var classifiableIndividualSimulation = new ClassifiableSimulation { Subject = _simulation }; var classfiablePopulationSimulation = new ClassifiableSimulation { Subject = _populationSimulation }; var classifiableImportSimulation = new ClassifiableSimulation { Subject = _importedSimulaton }; _project.AddClassifiable(classifiableIndividualSimulation); _project.AddClassifiable(classfiablePopulationSimulation); _individualSimulationNode = new SimulationNode(classifiableIndividualSimulation); _populationSimulationNode = new SimulationNode(classfiablePopulationSimulation); _importedSimulationNode = new SimulationNode(classifiableImportSimulation); _usedObservedDataNode = A.Fake <ITreeNode>(); A.CallTo(() => _treeNodeFactory.CreateFor(classifiableIndividualSimulation)).Returns(_individualSimulationNode); A.CallTo(() => _treeNodeFactory.CreateFor(classfiablePopulationSimulation)).Returns(_populationSimulationNode); A.CallTo(() => _treeNodeFactory.CreateFor(classifiableImportSimulation)).Returns(_importedSimulationNode); A.CallTo(() => _treeNodeFactory.CreateFor(_usedObservedData)).Returns(_usedObservedDataNode); _project.AddBuildingBlock(_importedSimulaton); var simulationComparison = A.Fake <ISimulationComparison>().WithId("SimComp_Id"); var classifiableComparison = new ClassifiableComparison { Subject = simulationComparison }; _comparisonNode = new ComparisonNode(classifiableComparison); _project.AddSimulationComparison(simulationComparison); A.CallTo(() => _treeNodeFactory.CreateFor(classifiableComparison)).Returns(_comparisonNode); _usedCompoundBuildingBlock = new UsedBuildingBlock("toto", PKSimBuildingBlockType.Compound) { Id = "usedBB" }; _simulation.AddUsedBuildingBlock(_usedCompoundBuildingBlock); _simulation.AddUsedObservedData(_usedObservedData); _project.AddClassifiable(classifiableComparison); _templageCompoundBuildingBlock = A.Fake <IPKSimBuildingBlock>(); _usedBuildingBlockNode = new UsedBuildingBlockInSimulationNode(_simulation, _usedCompoundBuildingBlock, _templageCompoundBuildingBlock); A.CallTo(() => _treeNodeFactory.CreateFor(_simulation, _usedCompoundBuildingBlock)).Returns(_usedBuildingBlockNode); A.CallTo(() => _buildingBlockIconRetriever.IconFor(_simulation)).Returns(ApplicationIcons.SimulationGreen); A.CallTo(() => _buildingBlockIconRetriever.IconFor(_populationSimulation)).Returns(ApplicationIcons.SimulationGreen); A.CallTo(() => _buildingBlockIconRetriever.IconFor(_usedCompoundBuildingBlock)).Returns(ApplicationIcons.CompoundRed); A.CallTo(() => _view.TreeView.NodeById(_simulation.Id)).Returns(_individualSimulationNode); A.CallTo(() => _view.TreeView.NodeById(_usedCompoundBuildingBlock.Id)).Returns(_usedBuildingBlockNode); A.CallTo(() => _view.TreeView.NodeById(RootNodeTypes.SimulationFolder.Id)).Returns(_simulationFolderNode); A.CallTo(() => _view.TreeView.NodeById(RootNodeTypes.ComparisonFolder.Id)).Returns(_comparisonFolderNode); _observedDataInSimulationManager = A.Fake <IObservedDataInSimulationManager>(); sut = new SimulationExplorerPresenter( _view, _treeNodeFactory, _contextMenuFactory, _multipleTreeNodeContextMenuFactory, _buildingBlockIconRetriever, _regionResolver, _buildingBlockTask, _buildingBlockInSimulationManager, _toolTipNodeCreator, _projectRetriever, _classificationPresenter, _parameterAnalysablesInExplorerPresenter, _observedDataInSimulationManager, _simulationComparisonTask); A.CallTo(() => _projectRetriever.CurrentProject).Returns(_project); }
protected override void Context() { _view = A.Fake <IBuildingBlockExplorerView>(); A.CallTo(() => _view.TreeView).Returns(A.Fake <IUxTreeView>()); _regionResolver = A.Fake <IRegionResolver>(); _region = A.Fake <IRegion>(); A.CallTo(() => _regionResolver.RegionWithName(RegionNames.BuildingBlockExplorer)).Returns(_region); _project = new PKSimProject(); var compound = new Compound().WithName("compound"); _individual = new Individual().WithName("individual"); _individual.OriginData = new OriginData { Species = new Species() }; _project.AddBuildingBlock(_individual); _project.AddBuildingBlock(compound); _observedDataInExplorerPresenter = A.Fake <IObservedDataInExplorerPresenter>(); _buildingBlockIconRetriever = A.Fake <IBuildingBlockIconRetriever>(); _treeNodeFactory = A.Fake <ITreeNodeFactory>(); _contextMenuFactory = A.Fake <ITreeNodeContextMenuFactory>(); _buildingBlockTask = A.Fake <IBuildingBlockTask>(); _toolTipCreator = A.Fake <IToolTipPartCreator>(); _projectRetriever = A.Fake <IProjectRetriever>(); _classificationPresenter = A.Fake <IClassificationPresenter>(); _multipleTreeNodeContextMenuFactory = A.Fake <IMultipleTreeNodeContextMenuFactory>(); sut = new BuildingBlockExplorerPresenter(_view, _treeNodeFactory, _contextMenuFactory, _multipleTreeNodeContextMenuFactory, _buildingBlockIconRetriever, _regionResolver, _buildingBlockTask, _toolTipCreator, _projectRetriever, _classificationPresenter, _observedDataInExplorerPresenter); _compoundFolderNode = new RootNode(PKSimRootNodeTypes.CompoundFolder); _individualFolderNode = new RootNode(PKSimRootNodeTypes.IndividualFolder); _formulationFolderNode = new RootNode(PKSimRootNodeTypes.FormulationFolder); _protocolFolderNode = new RootNode(PKSimRootNodeTypes.ProtocolFolder); _observersFolderNode = new RootNode(PKSimRootNodeTypes.ObserverSetFolder); _populationFolderNode = new RootNode(PKSimRootNodeTypes.PopulationFolder); _eventRootNode = new RootNode(PKSimRootNodeTypes.EventFolder); _simulationNode = new SimulationNode(new ClassifiableSimulation { Subject = new IndividualSimulation { Id = "1" } }); _compoundNode = new ObjectWithIdAndNameNode <Compound>(compound); _individualNode = new ObjectWithIdAndNameNode <Individual>(_individual); _observationRootNode = new RootNode(RootNodeTypes.ObservedDataFolder); A.CallTo(() => _treeNodeFactory.CreateFor(PKSimRootNodeTypes.CompoundFolder)).Returns(_compoundFolderNode); A.CallTo(() => _treeNodeFactory.CreateFor(PKSimRootNodeTypes.IndividualFolder)).Returns(_individualFolderNode); A.CallTo(() => _treeNodeFactory.CreateFor(PKSimRootNodeTypes.ProtocolFolder)).Returns(_protocolFolderNode); A.CallTo(() => _treeNodeFactory.CreateFor(PKSimRootNodeTypes.ObserverSetFolder)).Returns(_observersFolderNode); A.CallTo(() => _treeNodeFactory.CreateFor(PKSimRootNodeTypes.FormulationFolder)).Returns(_formulationFolderNode); A.CallTo(() => _treeNodeFactory.CreateFor(PKSimRootNodeTypes.PopulationFolder)).Returns(_populationFolderNode); A.CallTo(() => _treeNodeFactory.CreateFor(RootNodeTypes.ObservedDataFolder)).Returns(_observationRootNode); A.CallTo(() => _treeNodeFactory.CreateFor(PKSimRootNodeTypes.EventFolder)).Returns(_eventRootNode); A.CallTo(() => _treeNodeFactory.CreateFor(_individual)).Returns(_individualNode); A.CallTo(() => _treeNodeFactory.CreateFor(compound)).Returns(_compoundNode); A.CallTo(() => _view.TreeView.NodeById(PKSimRootNodeTypes.CompoundFolder.Id)).Returns(_compoundFolderNode); A.CallTo(() => _view.TreeView.NodeById(PKSimRootNodeTypes.IndividualFolder.Id)).Returns(_individualFolderNode); A.CallTo(() => _view.TreeView.NodeById(PKSimRootNodeTypes.ProtocolFolder.Id)).Returns(_protocolFolderNode); A.CallTo(() => _view.TreeView.NodeById(PKSimRootNodeTypes.ObserverSetFolder.Id)).Returns(_observersFolderNode); A.CallTo(() => _view.TreeView.NodeById(PKSimRootNodeTypes.FormulationFolder.Id)).Returns(_formulationFolderNode); A.CallTo(() => _view.TreeView.NodeById(PKSimRootNodeTypes.PopulationFolder.Id)).Returns(_populationFolderNode); A.CallTo(() => _view.TreeView.NodeById(RootNodeTypes.ObservedDataFolder.Id)).Returns(_observationRootNode); A.CallTo(() => _view.TreeView.NodeById(PKSimRootNodeTypes.EventFolder.Id)).Returns(_eventRootNode); A.CallTo(() => _view.AddNode(A <ITreeNode> ._)).ReturnsLazily(s => s.Arguments[0].DowncastTo <ITreeNode>()); }
///<summary>Init hydraulic simulation, preparing the linear solver and the hydraulic structures wrappers.</summary> /// <param name="net">Hydraulic network reference.</param> /// <param name="log">Logger reference.</param> public HydraulicSim(EpanetNetwork net, TraceSource log) { _running = false; _logger = log; // this.CreateSimulationNetwork(net); _nodes = new SimulationNode[net.Nodes.Count]; _links = new SimulationLink[net.Links.Count]; _pumps = new List <SimulationPump>(); _tanks = new List <SimulationTank>(); _junctions = new List <SimulationNode>(); _valves = new List <SimulationValve>(); var nodesById = new Dictionary <string, SimulationNode>(net.Nodes.Count); for (int i = 0; i < net.Nodes.Count; i++) { SimulationNode node; var networkNode = net.Nodes[i]; if (networkNode.Type == NodeType.JUNC) { node = new SimulationNode(networkNode, i); _junctions.Add(node); } else { node = new SimulationTank(networkNode, i); _tanks.Add((SimulationTank)node); } _nodes[i] = node; nodesById[node.Id] = node; } for (int i = 0; i < net.Links.Count; i++) { SimulationLink link; var networkLink = net.Links[i]; if (networkLink is Valve) { var valve = new SimulationValve(nodesById, networkLink, i); _valves.Add(valve); link = valve; } else if (networkLink is Pump) { var pump = new SimulationPump(nodesById, networkLink, i); _pumps.Add(pump); link = pump; } else { link = new SimulationLink(nodesById, networkLink, i); } _links[i] = link; } _rules = net.Rules.Select(r => new SimulationRule(r, _links, _nodes)).ToArray(); _curves = net.Curves.ToArray(); _controls = net.Controls.Select(x => new SimulationControl(_nodes, _links, x)).ToArray(); this.net = net; _epat = net.GetPattern(this.net.EPatId); _smat = new SparseMatrix(_nodes, _links, _junctions.Count); _lsv = new LsVariables(_nodes.Length, _smat.CoeffsCount); Htime = 0; switch (this.net.FormFlag) { case FormType.HW: _pHlModel = PipeHeadModelCalculators.HwModelCalculator; break; case FormType.DW: _pHlModel = PipeHeadModelCalculators.DwModelCalculator; break; case FormType.CM: _pHlModel = PipeHeadModelCalculators.CmModelCalculator; break; } foreach (SimulationLink link in _links) { link.InitLinkFlow(); } foreach (SimulationNode node in _junctions) { if (node.Ke > 0.0) { node.SimEmitter = 1.0; } } foreach (SimulationLink link in _links) { if ((link.Type == LinkType.PRV || link.Type == LinkType.PSV || link.Type == LinkType.FCV) && !double.IsNaN(link.Roughness)) { link.SimStatus = StatType.ACTIVE; } if (link.SimStatus <= StatType.CLOSED) { link.SimFlow = Constants.QZERO; } else if (Math.Abs(link.SimFlow) <= Constants.QZERO) { link.InitLinkFlow(link.SimStatus, link.SimSetting); } link.SimOldStatus = link.SimStatus; } Htime = 0; Rtime = this.net.RStep; }
///<summary>Updates link flows after new nodal heads computed.</summary> private double NewFlows(double relaxFactor) { foreach (SimulationTank node in _tanks) { node.SimDemand = 0; } double qsum = 0.0; double dqsum = 0.0; foreach (SimulationLink link in _links) { SimulationNode n1 = link.First; SimulationNode n2 = link.Second; double dh = n1.SimHead - n2.SimHead; double dq = link.SimFlowCorrection - link.SimInvHeadLoss * dh; dq *= relaxFactor; var pump = link as SimulationPump; if (pump != null) { if (pump.Ptype == PumpType.CONST_HP && dq > pump.SimFlow) { dq = pump.SimFlow / 2.0; } } link.SimFlow = link.SimFlow - dq; qsum += Math.Abs(link.SimFlow); dqsum += Math.Abs(dq); if (link.SimStatus > StatType.CLOSED) { if (n1 is SimulationTank) { n1.SimDemand = n1.SimDemand - link.SimFlow; } if (n2 is SimulationTank) { n2.SimDemand = n2.SimDemand + link.SimFlow; } } } foreach (SimulationNode node in _junctions) { if (node.Ke == 0.0) { continue; } double dq = node.EmitFlowChange(net); node.SimEmitter = node.SimEmitter - dq; qsum += Math.Abs(node.SimEmitter); dqsum += Math.Abs(dq); } return(qsum > net.HAcc ? dqsum / qsum : dqsum); }
static private void SaveToFile(string test, int time, SimulationNode simulationNode) { string filename = test + "_" + time.ToString() + ".json"; FileSaver(filename, simulationNode); }
static private float RunTest(Test test) { Stopwatch sw = new Stopwatch(); sw.Start(); DayTime dt = new DayTime(); Console.WriteLine("Updating Configuration for {0}", test.Name); Configuration.Initialize(test); //Console.WriteLine("{0}: Creating Customer and Enterprise", test.Name); Customer customer = new Customer(); Enterprise ent = new Enterprise(customer); BigData bigData = new BigData(); //Console.WriteLine("{0}: Generating Plants", test.Name); List <Plant> plants = SimulationSetup.GeneratePlants(); foreach (Plant plant in plants) { ent.Add(plant); foreach (var wc in plant.Workcenters) { if (wc.Name == "Shipping Dock" || wc.Name == "Stage") { continue; } bigData.AddWorkcenter(wc.Name); ((Core.Workcenters.Workcenter)wc).AddBigData(bigData); } } ent.Add(bigData); //Console.WriteLine("{0}: Generating Transport Routes", test.Name); var routes = SimulationSetup.GenerateRoutes(plants); Transport transport = new Transport(ent, routes); ent.Add(transport); //Console.WriteLine("{0}: Generating Simulation Node", test.Name); SimulationNode sn = new SimulationNode(dt, ent); //Console.WriteLine("{0}: Loading Workorders", test.Name); int woCounter = 0; while (woCounter < Configuration.InitialNumberOfWorkorders) { Workorder.PoType type = SimulationSetup.SelectWoPoType(woCounter); DayTime due = SimulationSetup.SelectWoDueDate(dt, woCounter); int initialOp = SimulationSetup.SelectWoInitialOp(woCounter, Workorder.GetMaxOps(type) - 1); customer.CreateOrder(type, due, initialOp); woCounter++; } customer.Work(dt); // Load Workorders into Enterprise //SaveToFile(Configuration.Instance.TestFilename, 0, sn); Console.WriteLine("{0}: Starting Simulation", test.Name); for (int i = 1; i < Configuration.MinutesForProgramToTest; i++) { dt.Next(); ent.Work(dt); customer.Work(dt); var next = bigData.GetNextOrder(i); if (next.HasValue) { customer.CreateOrder(next.Value.Item1, new DayTime((int)next.Value.Item2, 800)); } if (i % 500 == 0) { Console.Write("."); } //SaveToFile(Configuration.Instance.TestFilename, i, sn); } Console.WriteLine("."); //Console.WriteLine("Finished with Test {0}", test.Name); sw.Stop(); Console.WriteLine("Time to Complete: {0}", sw.Elapsed); sw.Reset(); var result = customer.Result(); Console.WriteLine("Result: {0}", result.ToString()); return(result); }