public Model.Simulation CreateModelLessSimulationWith(SimulationConstruction simulationConstruction)
        {
            var sim = _simulationFactory.CreateFrom(simulationConstruction.SimulationSubject, simulationConstruction.TemplateCompounds, simulationConstruction.ModelProperties);

            sim.Name = simulationConstruction.SimulationName;

            for (int index = 0; index < simulationConstruction.TemplateCompounds.Count; index++)
            {
                var compoundProperties = sim.CompoundPropertiesList[index];
                var compound           = compoundProperties.Compound;

                //for now: only simple protocol
                var simpleProtocol = simulationConstruction.TemplateProtocols[index] as SimpleProtocol;
                if (simpleProtocol != null && simpleProtocol.ApplicationType.NeedsFormulation && simulationConstruction.TemplateFormulation != null)
                {
                    simpleProtocol.FormulationKey = simulationConstruction.TemplateFormulation.Name;
                    compoundProperties.ProtocolProperties.AddFormulationMapping(new FormulationMapping {
                        FormulationKey = simulationConstruction.TemplateFormulation.Name, TemplateFormulationId = simulationConstruction.TemplateFormulation.Id
                    });
                }

                var processes = compoundProperties.Processes;

                //add all systemic processes
                addSystemicProcesses(compound, processes.MetabolizationSelection, SystemicProcessTypes.Hepatic);
                addSystemicProcesses(compound, processes.TransportAndExcretionSelection, SystemicProcessTypes.GFR);
                addSystemicProcesses(compound, processes.TransportAndExcretionSelection, SystemicProcessTypes.Renal);
                addSystemicProcesses(compound, processes.TransportAndExcretionSelection, SystemicProcessTypes.Biliary);

                //add all partial processes
                var individual = simulationConstruction.SimulationSubject as Model.Individual ?? simulationConstruction.SimulationSubject.DowncastTo <Population>().FirstIndividual;

                addPartialProcesses <EnzymaticProcess, IndividualEnzyme, EnzymaticProcessSelection>(compound, individual, processes.MetabolizationSelection);
                addPartialProcesses <TransportPartialProcess, IndividualTransporter, ProcessSelection>(compound, individual, processes.TransportAndExcretionSelection);
                addPartialProcesses <SpecificBindingPartialProcess, IndividualMolecule, ProcessSelection>(compound, individual, processes.SpecificBindingSelection);

                _buildingBlockUpdater.UpdateMultipleUsedBuildingBlockInSimulationFromTemplate(sim, simulationConstruction.TemplateProtocols.Where(p => p != null), PKSimBuildingBlockType.Protocol);

                var templateProtocol = simulationConstruction.TemplateProtocols[index];
                if (templateProtocol != null)
                {
                    compoundProperties.ProtocolProperties.Protocol = sim.AllBuildingBlocks <Protocol>().FindByName(templateProtocol.Name);
                }

                if (simulationConstruction.TemplateFormulation != null)
                {
                    _buildingBlockUpdater.UpdateMultipleUsedBuildingBlockInSimulationFromTemplate(sim, new[] { simulationConstruction.TemplateFormulation }, PKSimBuildingBlockType.Formulation);
                }
            }

            simulationConstruction.Interactions.Each(sim.InteractionProperties.AddInteraction);
            sim.AllowAging = simulationConstruction.AllowAging;
            return(sim);
        }
        public Model.Simulation CreateSimulation(SimulationConstruction simulationConstruction, Action <Model.Simulation> preModelCreationAction = null)
        {
            var sim = CreateModelLessSimulationWith(simulationConstruction);

            if (preModelCreationAction != null)
            {
                preModelCreationAction(sim);
            }

            AddModelToSimulation(sim);
            return(sim);
        }