public IHM5OutputContext Create( ICalculationsAbstractFactory calculationsAbstractFactory, IDependenciesAbstractFactory dependenciesAbstractFactory, IResultElementsAbstractFactory resultElementsAbstractFactory, IResultsAbstractFactory resultsAbstractFactory, IHM5Model HM5Model, Solution solution) { IHM5OutputContext context = null; try { context = new HM5OutputContext( calculationsAbstractFactory, dependenciesAbstractFactory, resultElementsAbstractFactory, resultsAbstractFactory, HM5Model, solution); } catch (Exception exception) { this.Log.Error("Exception message: " + exception.Message + " and stacktrace " + exception.StackTrace); } return(context); }
public IHM4OutputContext Create( ICalculationsAbstractFactory calculationsAbstractFactory, IDependenciesAbstractFactory dependenciesAbstractFactory, IResultElementsAbstractFactory resultElementsAbstractFactory, IResultsAbstractFactory resultsAbstractFactory, IHM4Model HM4Model, Solution solution) { IHM4OutputContext context = null; try { context = new HM4OutputContext( calculationsAbstractFactory, dependenciesAbstractFactory, resultElementsAbstractFactory, resultsAbstractFactory, HM4Model, solution); } catch (Exception exception) { this.Log.Error( exception.Message, exception); } return(context); }
public HM1BOutputContext( ICalculationsAbstractFactory calculationsAbstractFactory, IDependenciesAbstractFactory dependenciesAbstractFactory, IResultElementsAbstractFactory resultElementsAbstractFactory, IResultsAbstractFactory resultsAbstractFactory, IHM1BModel HM1BModel, Solution solution) { // BestBound this.BestBound = resultsAbstractFactory.CreateBestBoundFactory().Create( (decimal)solution.BestBound) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // Gap this.Gap = resultsAbstractFactory.CreateGapFactory().Create( (decimal)solution.Gap) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // NumberOfExploredNodes this.NumberOfExploredNodes = resultsAbstractFactory.CreateNumberOfExploredNodesFactory().Create( solution.NumberOfExploredNodes) .GetValueForOutputContext(); // ObjectiveValue this.ObjectiveValue = resultsAbstractFactory.CreateObjectiveValueFactory().Create( (decimal)solution.ObjectiveValues.SingleOrDefault().Value) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // OverallWallTime this.OverallWallTime = resultsAbstractFactory.CreateOverallWallTimeFactory().Create( solution.OverallWallTime) .GetValueForOutputContext(); // B(s) HM.HM1B.A.E.O.Interfaces.Results.SurgeonNumberAssignedTimeBlocks.IB Bs = HM1BModel.B.GetElementsAt( resultElementsAbstractFactory.CreateBsResultElementFactory(), resultsAbstractFactory.CreateBsFactory(), HM1BModel.s); this.SurgeonNumberAssignedTimeBlocks = Bs.GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // BBar(j) this.SurgicalSpecialtyNumberAssignedTimeBlocks = calculationsAbstractFactory.CreateBCalculationFactory().Create().Calculate( calculationsAbstractFactory.CreateBResultElementCalculationFactory(), resultElementsAbstractFactory.CreateBBarResultElementFactory(), resultsAbstractFactory.CreateBBarFactory(), HM1BModel.Δ, Bs) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); }
public ICalculationsAbstractFactory CreateCalculationsAbstractFactory() { ICalculationsAbstractFactory abstractFactory = null; try { abstractFactory = new CalculationsAbstractFactory(); } catch (Exception exception) { this.Log.Error("Exception message: " + exception.Message + " and stacktrace " + exception.StackTrace); } return(abstractFactory); }
public ICalculationsAbstractFactory CreateCalculationsAbstractFactory() { ICalculationsAbstractFactory abstractFactory = null; try { abstractFactory = new CalculationsAbstractFactory(); } catch (Exception exception) { this.Log.Error( exception.Message, exception); } return(abstractFactory); }
public IHM4Model Create( ICalculationsAbstractFactory calculationsAbstractFactory, IConstraintElementsAbstractFactory constraintElementsAbstractFactory, IConstraintsAbstractFactory constraintsAbstractFactory, ICrossJoinElementsAbstractFactory crossJoinElementsAbstractFactory, ICrossJoinsAbstractFactory crossJoinsAbstractFactory, IDependenciesAbstractFactory dependenciesAbstractFactory, IIndexElementsAbstractFactory indexElementsAbstractFactory, IIndicesAbstractFactory indicesAbstractFactory, IObjectiveFunctionsAbstractFactory objectiveFunctionsAbstractFactory, IParameterElementsAbstractFactory parameterElementsAbstractFactory, IParametersAbstractFactory parametersAbstractFactory, IVariablesAbstractFactory variablesAbstractFactory, IHM4InputContext HM4InputContext) { IHM4Model model = null; try { model = new HM4Model( calculationsAbstractFactory, constraintElementsAbstractFactory, constraintsAbstractFactory, crossJoinElementsAbstractFactory, crossJoinsAbstractFactory, dependenciesAbstractFactory, indexElementsAbstractFactory, indicesAbstractFactory, objectiveFunctionsAbstractFactory, parameterElementsAbstractFactory, parametersAbstractFactory, variablesAbstractFactory, HM4InputContext); } catch (Exception exception) { this.Log.Error( exception.Message, exception); } return(model); }
public HM4Model( ICalculationsAbstractFactory calculationsAbstractFactory, IConstraintElementsAbstractFactory constraintElementsAbstractFactory, IConstraintsAbstractFactory constraintsAbstractFactory, ICrossJoinElementsAbstractFactory crossJoinElementsAbstractFactory, ICrossJoinsAbstractFactory crossJoinsAbstractFactory, IDependenciesAbstractFactory dependenciesAbstractFactory, IIndexElementsAbstractFactory indexElementsAbstractFactory, IIndicesAbstractFactory indicesAbstractFactory, IObjectiveFunctionsAbstractFactory objectiveFunctionsAbstractFactory, IParameterElementsAbstractFactory parameterElementsAbstractFactory, IParametersAbstractFactory parametersAbstractFactory, IVariablesAbstractFactory variablesAbstractFactory, IHM4InputContext HM4InputContext) { this.Context = HM4InputContext; this.Model = dependenciesAbstractFactory.CreateModelFactory().Create(); // Indices // d this.d = indicesAbstractFactory.CreatedFactory().Create( this.Context.Weekdays .Select(x => indexElementsAbstractFactory.CreatedIndexElementFactory().Create((PositiveInt)x)) .ToImmutableList()); // j this.j = indicesAbstractFactory.CreatejFactory().Create( this.Context.SurgicalSpecialties .Select(x => x.Item1) .Select(x => indexElementsAbstractFactory.CreatejIndexElementFactory().Create(x)) .ToImmutableList()); // l this.l = indicesAbstractFactory.CreatelFactory().Create( this.Context.LengthOfStayDays .Select(x => indexElementsAbstractFactory.CreatelIndexElementFactory().Create((PositiveInt)x)) .ToImmutableList()); // r this.r = indicesAbstractFactory.CreaterFactory().Create( this.Context.OperatingRooms .Entry .Where(x => x.Resource is Location) .Select(x => indexElementsAbstractFactory.CreaterIndexElementFactory().Create((Location)x.Resource)) .ToImmutableList()); // s this.s = indicesAbstractFactory.CreatesFactory().Create( this.Context.Surgeons .Entry .Where(x => x.Resource is Organization) .Select(x => indexElementsAbstractFactory.CreatesIndexElementFactory().Create((Organization)x.Resource)) .ToImmutableList()); // t this.t = indicesAbstractFactory.CreatetFactory().Create( this.Context.PlanningHorizon .Select(x => indexElementsAbstractFactory.CreatetIndexElementFactory().Create( x.Key.Value.Value, x.Value)) .ToImmutableList()); // Λ this.Λ = indicesAbstractFactory.CreateΛFactory().Create( this.Context.Scenarios .Select(x => indexElementsAbstractFactory.CreateΛIndexElementFactory().Create((PositiveInt)x)) .ToImmutableList()); // Cross joins // dt this.dt = crossJoinsAbstractFactory.CreatedtFactory().Create( this.d.Value .SelectMany(b => this.t.Value, (a, b) => crossJoinElementsAbstractFactory.CreatedtCrossJoinElementFactory().Create(a, b)) .ToImmutableList()); // rt this.rt = crossJoinsAbstractFactory.CreatertFactory().Create( this.r.Value .SelectMany(b => this.t.Value, (a, b) => crossJoinElementsAbstractFactory.CreatertCrossJoinElementFactory().Create(a, b)) .ToImmutableList()); // slΛ this.slΛ = crossJoinsAbstractFactory.CreateslΛFactory().Create( this.s.Value .SelectMany(b => this.l.Value, (a, b) => crossJoinElementsAbstractFactory.CreateslCrossJoinElementFactory().Create(a, b)) .SelectMany(b => this.Λ.Value, (a, b) => crossJoinElementsAbstractFactory.CreateslΛCrossJoinElementFactory().Create(a.sIndexElement, a.lIndexElement, b)) .ToImmutableList()); // sr this.sr = crossJoinsAbstractFactory.CreatesrFactory().Create( this.s.Value .SelectMany(b => this.r.Value, (a, b) => crossJoinElementsAbstractFactory.CreatesrCrossJoinElementFactory().Create(a, b)) .ToImmutableList()); // srd this.srd = crossJoinsAbstractFactory.CreatesrdFactory().Create( this.s.Value .SelectMany(b => this.r.Value, (a, b) => crossJoinElementsAbstractFactory.CreatesrCrossJoinElementFactory().Create(a, b)) .SelectMany(b => this.d.Value, (a, b) => crossJoinElementsAbstractFactory.CreatesrdCrossJoinElementFactory().Create(a.sIndexElement, a.rIndexElement, b)) .ToImmutableList()); // srt this.srt = crossJoinsAbstractFactory.CreatesrtFactory().Create( this.s.Value .SelectMany(b => this.r.Value, (a, b) => crossJoinElementsAbstractFactory.CreatesrCrossJoinElementFactory().Create(a, b)) .SelectMany(b => this.t.Value, (a, b) => crossJoinElementsAbstractFactory.CreatesrtCrossJoinElementFactory().Create(a.sIndexElement, a.rIndexElement, b)) .ToImmutableList()); // st this.st = crossJoinsAbstractFactory.CreatestFactory().Create( this.s.Value .SelectMany(b => this.t.Value, (a, b) => crossJoinElementsAbstractFactory.CreatestCrossJoinElementFactory().Create(a, b)) .ToImmutableList()); // sΛ this.sΛ = crossJoinsAbstractFactory.CreatesΛFactory().Create( this.s.Value .SelectMany(b => this.Λ.Value, (a, b) => crossJoinElementsAbstractFactory.CreatesΛCrossJoinElementFactory().Create(a, b)) .ToImmutableList()); // tΛ this.tΛ = crossJoinsAbstractFactory.CreatetΛFactory().Create( this.t.Value .SelectMany(b => this.Λ.Value, (a, b) => crossJoinElementsAbstractFactory.CreatetΛCrossJoinElementFactory().Create(a, b)) .ToImmutableList()); // Parameters // H this.H = parametersAbstractFactory.CreateHFactory().Create( this.Context.TimeBlockLength); // h(s, Λ) this.h = parametersAbstractFactory.CreatehFactory().Create( this.Context.SurgeonScenarioWeightedAverageSurgicalDurations .Select(x => parameterElementsAbstractFactory.CreatehParameterElementFactory().Create( this.s.GetElementAt(x.Item1), this.Λ.GetElementAt((PositiveInt)x.Item2), x.Item3)) .ToImmutableList()); // L(s) this.L = parametersAbstractFactory.CreateLFactory().Create( this.Context.SurgeonLengthOfStayMaximums .Select(x => parameterElementsAbstractFactory.CreateLParameterElementFactory().Create( this.s.GetElementAt(x.Key), (PositiveInt)x.Value)) .ToImmutableList()); // n(s, Λ) this.n = parametersAbstractFactory.CreatenFactory().Create( this.Context.SurgeonScenarioMaximumNumberPatients .Select(x => parameterElementsAbstractFactory.CreatenParameterElementFactory().Create( this.s.GetElementAt(x.Item1), this.Λ.GetElementAt((PositiveInt)x.Item2), (PositiveInt)x.Item3)) .ToImmutableList()); // p(s, l, Λ) this.p = parametersAbstractFactory.CreatepFactory().Create( this.Context.SurgeonDayScenarioLengthOfStayProbabilities .Select(x => parameterElementsAbstractFactory.CreatepParameterElementFactory().Create( this.s.GetElementAt(x.Item1), this.l.GetElementAt((PositiveInt)x.Item2), this.Λ.GetElementAt((PositiveInt)x.Item3), (FhirDecimal)x.Item4)) .ToImmutableList()); // W this.W = parametersAbstractFactory.CreateWFactory().Create( (PositiveInt)this.Context.NumberDaysPerWeek); // y(s, r) this.y = parametersAbstractFactory.CreateyFactory().Create( this.Context.SurgeonOperatingRoomAssignments .Select(x => parameterElementsAbstractFactory.CreateyParameterElementFactory().Create( this.s.GetElementAt(x.Item1), this.r.GetElementAt(x.Item2), (FhirBoolean)x.Item3)) .ToImmutableList()); // β(s, r, d) this.β = parametersAbstractFactory.CreateβFactory().Create( this.Context.SurgeonOperatingRoomDayNumberAssignedTimeBlocks .Select(x => parameterElementsAbstractFactory.CreateβParameterElementFactory().Create( this.s.GetElementAt(x.Item1), this.r.GetElementAt(x.Item2), this.d.GetElementAt((PositiveInt)x.Item3), (PositiveInt)x.Item4)) .ToImmutableList()); // γ(r, t) this.γ = parametersAbstractFactory.CreateγFactory().Create( this.Context.OperatingRoomDayAssignedAvailabilities .Select(x => parameterElementsAbstractFactory.CreateγParameterElementFactory().Create( this.r.GetElementAt(x.Item1), this.t.GetElementAt(x.Item2), (FhirBoolean)x.Item3)) .ToImmutableList()); // Δ(j) this.Δ = parametersAbstractFactory.CreateΔFactory().Create( this.Context.SurgicalSpecialties .Select(x => parameterElementsAbstractFactory.CreateΔParameterElementFactory().Create( this.j.GetElementAt(x.Item1), x.Item2.Select(i => this.s.GetElementAt(i)).ToImmutableList())) .ToImmutableList()); // δ1(s, r, d) this.δ1 = calculationsAbstractFactory.Createδ1CalculationFactory().Create().Calculate( parameterElementsAbstractFactory.Createδ1ParameterElementFactory(), parametersAbstractFactory.Createδ1Factory(), calculationsAbstractFactory.Createδ1ParameterElementCalculationFactory().Create(), this.srd, this.t, this.W, this.β, this.γ); // δ2(s, r, d) this.δ2 = calculationsAbstractFactory.Createδ2CalculationFactory().Create().Calculate( parameterElementsAbstractFactory.Createδ2ParameterElementFactory(), parametersAbstractFactory.Createδ2Factory(), calculationsAbstractFactory.Createδ2ParameterElementCalculationFactory().Create(), this.srd, this.t, this.W, this.β, this.γ); // δ3(s, r, d) this.δ3 = calculationsAbstractFactory.Createδ3CalculationFactory().Create().Calculate( parameterElementsAbstractFactory.Createδ3ParameterElementFactory(), parametersAbstractFactory.Createδ3Factory(), calculationsAbstractFactory.Createδ3ParameterElementCalculationFactory().Create(), this.srd, this.t, this.W, this.β, this.γ); // δ4(s, r, d, t) this.δ4 = calculationsAbstractFactory.Createδ4CalculationFactory().Create().Calculate( parameterElementsAbstractFactory.Createδ4ParameterElementFactory(), parametersAbstractFactory.Createδ4Factory(), calculationsAbstractFactory.Createδ4ParameterElementCalculationFactory().Create(), this.srd, this.t, this.W, this.δ3, this.γ); // μ(s, Λ) this.μ = parametersAbstractFactory.CreateμFactory().Create( this.Context.SurgeonScenarioMaximumNumberPatientMeans .Select(x => parameterElementsAbstractFactory.CreateμParameterElementFactory().Create( this.s.GetElementAt(x.Item1), this.Λ.GetElementAt((PositiveInt)x.Item2), (FhirDecimal)x.Item3)) .ToImmutableList()); // Ρ(Λ) this.Ρ = parametersAbstractFactory.CreateΡFactory().Create( this.Context.ScenarioProbabilities .Select(x => parameterElementsAbstractFactory.CreateΡParameterElementFactory().Create( this.Λ.GetElementAt((PositiveInt)x.Key), (FhirDecimal)x.Value)) .ToImmutableList()); // σ(s, Λ) this.σ = parametersAbstractFactory.CreateσFactory().Create( this.Context.SurgeonScenarioMaximumNumberPatientStandardDeviations .Select(x => parameterElementsAbstractFactory.CreateσParameterElementFactory().Create( this.s.GetElementAt(x.Item1), this.Λ.GetElementAt((PositiveInt)x.Item2), (FhirDecimal)x.Item3)) .ToImmutableList()); // ΦHat(s, l, Λ) this.ΦHat = parametersAbstractFactory.CreateΦHatFactory().Create( this.Context.SurgeonDayScenarioCumulativeNumberPatients .Select(x => parameterElementsAbstractFactory.CreateΦHatParameterElementFactory().Create( this.s.GetElementAt(x.Item1), this.l.GetElementAt((PositiveInt)x.Item2), this.Λ.GetElementAt((PositiveInt)x.Item3), (FhirDecimal)x.Item4)) .ToImmutableList()); // Ω this.Ω = parametersAbstractFactory.CreateΩFactory().Create( (PositiveInt)this.Context.MaximumNumberRecoveryWardBeds); // Variables // IHat(t, Λ) this.IHat = variablesAbstractFactory.CreateIHatFactory().Create( dependenciesAbstractFactory.CreateVariableCollectionFactory().Create( model: this.Model, indexSet1: this.t.Value, indexSet2: this.Λ.Value, lowerBoundGenerator: (a, b) => 0, upperBoundGenerator: (a, b) => double.MaxValue, variableTypeGenerator: (a, b) => VariableType.Continuous)); // x(s, r, t) this.x = variablesAbstractFactory.CreatexFactory().Create( dependenciesAbstractFactory.CreateVariableCollectionFactory().CreateBinary( model: this.Model, indexSet1: this.s.Value, indexSet2: this.r.Value, indexSet3: this.t.Value)); // z(s, t) this.z = variablesAbstractFactory.CreatezFactory().Create( dependenciesAbstractFactory.CreateVariableCollectionFactory().CreateBinary( model: this.Model, indexSet1: this.s.Value, indexSet2: this.t.Value)); // Constraints // Constraints 1 this.Model.AddConstraints( this.srd.Value .Select( x => constraintElementsAbstractFactory.CreateConstraints1ConstraintElementFactory().Create( x.dIndexElement, x.rIndexElement, x.sIndexElement, this.t, this.W, this.β, this.x) .Value)); // Constraints 2 this.Model.AddConstraints( this.st.Value .Select( x => constraintElementsAbstractFactory.CreateConstraints2ConstraintElementFactory().Create( x.sIndexElement, x.tIndexElement, this.r, this.x, this.z) .Value)); // Constraints 3 this.Model.AddConstraints( this.rt.Value .Select( x => constraintElementsAbstractFactory.CreateConstraints3ConstraintElementFactory().Create( x.rIndexElement, x.tIndexElement, this.s, this.γ, this.x) .Value)); // Constraints 4 this.Model.AddConstraints( this.srt.Value .Select( x => constraintElementsAbstractFactory.CreateConstraints4ConstraintElementFactory().Create( x.rIndexElement, x.sIndexElement, x.tIndexElement, this.y, this.x) .Value)); // Constraints 5L this.Model.AddConstraints( this.srd.Value .SelectMany(b => this.t.GetNthElementsAt( b.dIndexElement.Value.Value.Value, this.t.GetT() - this.W.Value.Value.Value + b.dIndexElement.Value.Value.Value, this.W.Value.Value.Value), (a, b) => Tuple.Create(a.sIndexElement, a.rIndexElement, a.dIndexElement, b)) .Select( x => constraintElementsAbstractFactory.CreateConstraints5LConstraintElementFactory().Create( x.Item3, x.Item2, x.Item1, x.Item4, this.t, this.W, this.δ1, this.δ4, this.x) .Value)); // Constraints 5U this.Model.AddConstraints( this.srd.Value .SelectMany(b => this.t.GetNthElementsAt( b.dIndexElement.Value.Value.Value, this.t.GetT() - this.W.Value.Value.Value + b.dIndexElement.Value.Value.Value, this.W.Value.Value.Value), (a, b) => Tuple.Create(a.sIndexElement, a.rIndexElement, a.dIndexElement, b)) .Select( x => constraintElementsAbstractFactory.CreateConstraints5UConstraintElementFactory().Create( x.Item3, x.Item2, x.Item1, x.Item4, this.t, this.W, this.δ2, this.δ4, this.x) .Value)); // Constraints 6 this.Model.AddConstraints( this.tΛ.Value .Select( x => constraintElementsAbstractFactory.CreateConstraints6ConstraintElementFactory().Create( x.tIndexElement, x.ΛIndexElement, this.l, this.t, this.st, this.ΦHat, this.IHat, this.z) .Value)); // Objective function this.Model.AddObjective( objectiveFunctionsAbstractFactory.CreateObjectiveFunctionFactory().Create( dependenciesAbstractFactory.CreateObjectiveFactory(), this.t, this.Λ, this.Ρ, this.IHat) .Value); }
public SPOutputContext( ICalculationsAbstractFactory calculationsAbstractFactory, IDependenciesAbstractFactory dependenciesAbstractFactory, IResultElementsAbstractFactory resultElementsAbstractFactory, IResultsAbstractFactory resultsAbstractFactory, ISPModel SPModel, Solution solution) { // BestBound this.BestBound = resultsAbstractFactory.CreateBestBoundFactory().Create( (decimal)solution.BestBound) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // Gap this.Gap = resultsAbstractFactory.CreateGapFactory().Create( (decimal)solution.Gap) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // NumberOfExploredNodes this.NumberOfExploredNodes = resultsAbstractFactory.CreateNumberOfExploredNodesFactory().Create( solution.NumberOfExploredNodes) .GetValueForOutputContext(); // ObjectiveValue this.ObjectiveValue = resultsAbstractFactory.CreateObjectiveValueFactory().Create( (decimal)solution.ObjectiveValues.SingleOrDefault().Value) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // OverallWallTime this.OverallWallTime = resultsAbstractFactory.CreateOverallWallTimeFactory().Create( solution.OverallWallTime) .GetValueForOutputContext(); // TotalFinancialContribution this.TotalFinancialContribution = calculationsAbstractFactory.CreateTotalFinancialContributionCalculationFactory().Create() .Calculate( resultsAbstractFactory.CreateTotalFinancialContributionFactory(), SPModel.pa, SPModel.r, SPModel.x) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // x(p, a) this.PatientGroupActiveDayNumberPatientAssignments = SPModel.x.GetElementsAt( resultElementsAbstractFactory.CreateSPxResultElementFactory(), resultsAbstractFactory.CreateSPxFactory(), SPModel.pa) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // y(w) this.WardNumberBedAssignments = SPModel.y.GetElementsAt( resultElementsAbstractFactory.CreateSPyResultElementFactory(), resultsAbstractFactory.CreateSPyFactory(), SPModel.w) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // z(s, a) this.SurgeonGroupActiveDayNumberBlockAssignments = SPModel.z.GetElementsAt( resultElementsAbstractFactory.CreateSPzResultElementFactory(), resultsAbstractFactory.CreateSPzFactory(), SPModel.sa) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); }
public Task <IHM5OutputContext> Solve( ICalculationsAbstractFactory calculationsAbstractFactory, IConstraintElementsAbstractFactory constraintElementsAbstractFactory, IConstraintsAbstractFactory constraintsAbstractFactory, IContextsAbstractFactory contextsAbstractFactory, ICrossJoinElementsAbstractFactory crossJoinElementsAbstractFactory, ICrossJoinsAbstractFactory crossJoinsAbstractFactory, IDependenciesAbstractFactory dependenciesAbstractFactory, IIndexElementsAbstractFactory indexElementsAbstractFactory, IIndicesAbstractFactory indicesAbstractFactory, IModelsAbstractFactory modelsAbstractFactory, IObjectiveFunctionsAbstractFactory objectiveFunctionsAbstractFactory, IParameterElementsAbstractFactory parameterElementsAbstractFactory, IParametersAbstractFactory parametersAbstractFactory, IResultElementsAbstractFactory resultElementsAbstractFactory, IResultsAbstractFactory resultsAbstractFactory, IVariablesAbstractFactory variablesAbstractFactory, IHM5Configuration HM5Configuration, IHM5InputContext HM5InputContext, ISolverConfiguration solverConfiguration) { IHM5OutputContext HM5OutputContext = null; return(Task.Run(() => { using (ModelScope modelScope = dependenciesAbstractFactory.CreateModelScopeFactory().Create(HM5Configuration.Value)) { IHM5Model model = modelsAbstractFactory.CreateHM5ModelFactory().Create( calculationsAbstractFactory, constraintElementsAbstractFactory, constraintsAbstractFactory, crossJoinElementsAbstractFactory, crossJoinsAbstractFactory, dependenciesAbstractFactory, indexElementsAbstractFactory, indicesAbstractFactory, objectiveFunctionsAbstractFactory, parameterElementsAbstractFactory, parametersAbstractFactory, variablesAbstractFactory, HM5InputContext); using (ISolver solver = dependenciesAbstractFactory.CreateSolverFactory().Create(solverConfiguration)) { Solution solution = solver?.Solve(model?.Model); if (solution?.ModelStatus == OPTANO.Modeling.Optimization.Solver.ModelStatus.Feasible) { model.Model.VariableCollections.ForEach(vc => vc.SetVariableValues(solution.VariableValues)); HM5OutputContext = contextsAbstractFactory.CreateHM5OutputContextFactory().Create( calculationsAbstractFactory, dependenciesAbstractFactory, resultElementsAbstractFactory, resultsAbstractFactory, model, solution); } } } return HM5OutputContext; })); }
public HM4OutputContext( ICalculationsAbstractFactory calculationsAbstractFactory, IDependenciesAbstractFactory dependenciesAbstractFactory, IResultElementsAbstractFactory resultElementsAbstractFactory, IResultsAbstractFactory resultsAbstractFactory, IHM4Model HM4Model, Solution solution) { // BestBound this.BestBound = resultsAbstractFactory.CreateBestBoundFactory().Create( (decimal)solution.BestBound) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // Gap this.Gap = resultsAbstractFactory.CreateGapFactory().Create( (decimal)solution.Gap) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // NumberOfExploredNodes this.NumberOfExploredNodes = resultsAbstractFactory.CreateNumberOfExploredNodesFactory().Create( solution.NumberOfExploredNodes) .GetValueForOutputContext(); // ObjectiveValue this.ObjectiveValue = resultsAbstractFactory.CreateObjectiveValueFactory().Create( (decimal)solution.ObjectiveValues.SingleOrDefault().Value) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // OverallWallTime this.OverallWallTime = resultsAbstractFactory.CreateOverallWallTimeFactory().Create( solution.OverallWallTime) .GetValueForOutputContext(); // IHat(t, Λ) this.DayScenarioRecoveryWardCensuses = HM4Model.IHat.GetElementsAt( resultElementsAbstractFactory.CreateIHatResultElementFactory(), resultsAbstractFactory.CreateIHatFactory(), HM4Model.tΛ) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // x(s, r, t) Ix x = HM4Model.x.GetElementsAt( resultElementsAbstractFactory.CreatexResultElementFactory(), resultsAbstractFactory.CreatexFactory(), HM4Model.srt); this.SurgeonOperatingRoomDayAssignments = x .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // SurgeonNumberAssignedOperatingRooms this.SurgeonNumberAssignedOperatingRooms = calculationsAbstractFactory.CreateSurgeonNumberAssignedOperatingRoomsCalculationFactory().Create().Calculate( resultElementsAbstractFactory.CreateSurgeonNumberAssignedOperatingRoomsResultElementFactory(), resultsAbstractFactory.CreateSurgeonNumberAssignedOperatingRoomsFactory(), calculationsAbstractFactory.CreateSurgeonNumberAssignedOperatingRoomsResultElementCalculationFactory().Create(), HM4Model.s, x) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // SurgeonNumberAssignedWeekdays this.SurgeonNumberAssignedWeekdays = calculationsAbstractFactory.CreateSurgeonNumberAssignedWeekdaysCalculationFactory().Create().Calculate( resultElementsAbstractFactory.CreateSurgeonNumberAssignedWeekdaysResultElementFactory(), resultsAbstractFactory.CreateSurgeonNumberAssignedWeekdaysFactory(), calculationsAbstractFactory.CreateSurgeonNumberAssignedWeekdaysResultElementCalculationFactory().Create(), HM4Model.s, x) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // SurgeonScenarioNumberPatients ISurgeonScenarioNumberPatients surgeonScenarioNumberPatients = calculationsAbstractFactory.CreateSurgeonScenarioNumberPatientsCalculationFactory().Create().Calculate( resultElementsAbstractFactory.CreateSurgeonScenarioNumberPatientsResultElementFactory(), resultsAbstractFactory.CreateSurgeonScenarioNumberPatientsFactory(), calculationsAbstractFactory.CreateSurgeonScenarioNumberPatientsResultElementCalculationFactory().Create(), HM4Model.rt, HM4Model.sΛ, HM4Model.n, x); this.SurgeonScenarioNumberPatients = surgeonScenarioNumberPatients.GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // ScenarioNumberPatients(Λ) this.ScenarioNumberPatients = calculationsAbstractFactory.CreateScenarioNumberPatientsCalculationFactory().Create() .Calculate( resultElementsAbstractFactory.CreateScenarioNumberPatientsResultElementFactory(), resultsAbstractFactory.CreateScenarioNumberPatientsFactory(), calculationsAbstractFactory.CreateScenarioNumberPatientsResultElementCalculationFactory().Create(), HM4Model.Λ, surgeonScenarioNumberPatients) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // SurgicalSpecialtyNumberAssignedOperatingRooms this.SurgicalSpecialtyNumberAssignedOperatingRooms = calculationsAbstractFactory.CreateSurgicalSpecialtyNumberAssignedOperatingRoomsCalculationFactory().Create().Calculate( resultElementsAbstractFactory.CreateSurgicalSpecialtyNumberAssignedOperatingRoomsResultElementFactory(), resultsAbstractFactory.CreateSurgicalSpecialtyNumberAssignedOperatingRoomsFactory(), calculationsAbstractFactory.CreateSurgicalSpecialtyNumberAssignedOperatingRoomsResultElementCalculationFactory().Create(), HM4Model.Δ, x) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // SurgicalSpecialtyNumberAssignedWeekdays this.SurgicalSpecialtyNumberAssignedWeekdays = calculationsAbstractFactory.CreateSurgicalSpecialtyNumberAssignedWeekdaysCalculationFactory().Create().Calculate( resultElementsAbstractFactory.CreateSurgicalSpecialtyNumberAssignedWeekdaysResultElementFactory(), resultsAbstractFactory.CreateSurgicalSpecialtyNumberAssignedWeekdaysFactory(), calculationsAbstractFactory.CreateSurgicalSpecialtyNumberAssignedWeekdaysResultElementCalculationFactory().Create(), HM4Model.Δ, x) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // z(s, t) Interfaces.Results.SurgeonDayAssignments.Iz z = HM4Model.z.GetElementsAt( resultElementsAbstractFactory.CreatezResultElementFactory(), resultsAbstractFactory.CreatezFactory(), HM4Model.st); this.SurgeonDayAssignments = z .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // ExpectedValueΦ(s, l, Λ) Interfaces.Results.SurgeonDayScenarioCumulativeNumberPatients.IExpectedValueΦ expectedValueΦ = calculationsAbstractFactory.CreateExpectedValueΦCalculationFactory().Create() .Calculate( resultElementsAbstractFactory.CreateExpectedValueΦResultElementFactory(), resultsAbstractFactory.CreateExpectedValueΦFactory(), calculationsAbstractFactory.CreateExpectedValueΦResultElementCalculationFactory().Create(), HM4Model.l, HM4Model.t, HM4Model.slΛ, HM4Model.L, HM4Model.p, HM4Model.μ); // VarianceΦ(s, l, Λ) Interfaces.Results.SurgeonDayScenarioCumulativeNumberPatients.IVarianceΦ varianceΦ = calculationsAbstractFactory.CreateVarianceΦCalculationFactory().Create() .Calculate( resultElementsAbstractFactory.CreateVarianceΦResultElementFactory(), resultsAbstractFactory.CreateVarianceΦFactory(), calculationsAbstractFactory.CreateVarianceΦResultElementCalculationFactory().Create(), HM4Model.l, HM4Model.t, HM4Model.slΛ, HM4Model.L, HM4Model.p, HM4Model.μ, HM4Model.σ); // ExpectedValueI(t, Λ) Interfaces.Results.DayScenarioRecoveryWardUtilizations.IExpectedValueI expectedValueI = calculationsAbstractFactory.CreateExpectedValueICalculationFactory().Create() .Calculate( resultElementsAbstractFactory.CreateExpectedValueIResultElementFactory(), resultsAbstractFactory.CreateExpectedValueIFactory(), calculationsAbstractFactory.CreateExpectedValueIResultElementCalculationFactory().Create(), HM4Model.l, HM4Model.t, HM4Model.st, HM4Model.tΛ, expectedValueΦ, z); this.DayScenarioRecoveryWardUtilizationExpectedValues = expectedValueI .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // VarianceI(t, Λ) Interfaces.Results.DayScenarioRecoveryWardUtilizations.IVarianceI varianceI = calculationsAbstractFactory.CreateVarianceICalculationFactory().Create() .Calculate( resultElementsAbstractFactory.CreateVarianceIResultElementFactory(), resultsAbstractFactory.CreateVarianceIFactory(), calculationsAbstractFactory.CreateVarianceIResultElementCalculationFactory().Create(), HM4Model.l, HM4Model.t, HM4Model.st, HM4Model.tΛ, varianceΦ, z); this.DayScenarioRecoveryWardUtilizationVariances = varianceI .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // EBS(t, Λ) Interfaces.Results.DayScenarioExpectedBedShortages.IEBS EBS = calculationsAbstractFactory.CreateEBSCalculationFactory().Create() .Calculate( resultElementsAbstractFactory.CreateEBSResultElementFactory(), resultsAbstractFactory.CreateEBSFactory(), calculationsAbstractFactory.CreateEBSResultElementCalculationFactory().Create(), HM4Model.tΛ, HM4Model.Ω, expectedValueI, varianceI); this.DayScenarioExpectedBedShortages = EBS .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // TEBS(Λ) Interfaces.Results.ScenarioTotalExpectedBedShortages.ITEBS TEBS_Λ = calculationsAbstractFactory.CreateTEBSΛCalculationFactory().Create() .Calculate( resultElementsAbstractFactory.CreateTEBSΛResultElementFactory(), resultsAbstractFactory.CreateTEBSΛFactory(), calculationsAbstractFactory.CreateTEBSΛResultElementCalculationFactory().Create(), HM4Model.t, HM4Model.Λ, EBS); this.ScenarioTotalExpectedBedShortages = TEBS_Λ .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // TEBS this.TotalExpectedBedShortage = calculationsAbstractFactory.CreateTEBSCalculationFactory().Create() .Calculate( resultsAbstractFactory.CreateTEBSFactory(), HM4Model.Λ, HM4Model.Ρ, TEBS_Λ) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // ScenarioTotalTimes(Λ) IScenarioTotalTimes scenarioTotalTimes = calculationsAbstractFactory.CreateScenarioTotalTimesCalculationFactory().Create() .Calculate( resultElementsAbstractFactory.CreateScenarioTotalTimesResultElementFactory(), resultsAbstractFactory.CreateScenarioTotalTimesFactory(), calculationsAbstractFactory.CreateScenarioTotalTimesResultElementCalculationFactory().Create(), HM4Model.Λ, HM4Model.srt, HM4Model.H, x); this.ScenarioTotalTimes = scenarioTotalTimes.GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // ScenarioUtilizedTimes(Λ) IScenarioUtilizedTimes scenarioUtilizedTimes = calculationsAbstractFactory.CreateScenarioUtilizedTimesCalculationFactory().Create() .Calculate( resultElementsAbstractFactory.CreateScenarioUtilizedTimesResultElementFactory(), resultsAbstractFactory.CreateScenarioUtilizedTimesFactory(), calculationsAbstractFactory.CreateScenarioUtilizedTimesResultElementCalculationFactory().Create(), HM4Model.Λ, HM4Model.srt, HM4Model.h, HM4Model.n, x); this.ScenarioUtilizedTimes = scenarioUtilizedTimes.GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // ScenarioUnutilizedTimes(Λ) IScenarioUnutilizedTimes scenarioUnutilizedTimes = calculationsAbstractFactory.CreateScenarioUnutilizedTimesCalculationFactory().Create() .Calculate( resultElementsAbstractFactory.CreateScenarioUnutilizedTimesResultElementFactory(), resultsAbstractFactory.CreateScenarioUnutilizedTimesFactory(), calculationsAbstractFactory.CreateScenarioUnutilizedTimesResultElementCalculationFactory().Create(), HM4Model.Λ, scenarioTotalTimes, scenarioUtilizedTimes); this.ScenarioUnutilizedTimes = scenarioUnutilizedTimes.GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // ScenarioUnderutilizations(Λ) this.ScenarioUnderutilizations = calculationsAbstractFactory.CreateScenarioUnderutilizationsCalculationFactory().Create() .Calculate( resultElementsAbstractFactory.CreateScenarioUnderutilizationsResultElementFactory(), resultsAbstractFactory.CreateScenarioUnderutilizationsFactory(), calculationsAbstractFactory.CreateScenarioUnderutilizationsResultElementCalculationFactory().Create(), HM4Model.Λ, scenarioTotalTimes, scenarioUnutilizedTimes) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); }
public HM3AOutputContext( ICalculationsAbstractFactory calculationsAbstractFactory, IDependenciesAbstractFactory dependenciesAbstractFactory, IResultElementsAbstractFactory resultElementsAbstractFactory, IResultsAbstractFactory resultsAbstractFactory, IHM3AModel HM3AModel, Solution solution, HM3AEncodingEnum HM3AEncodingEnum) { // BestBound this.BestBound = resultsAbstractFactory.CreateBestBoundFactory().Create( (decimal)solution.BestBound) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // Gap this.Gap = resultsAbstractFactory.CreateGapFactory().Create( (decimal)solution.Gap) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // NumberOfExploredNodes this.NumberOfExploredNodes = resultsAbstractFactory.CreateNumberOfExploredNodesFactory().Create( solution.NumberOfExploredNodes) .GetValueForOutputContext(); // ObjectiveValue this.ObjectiveValue = resultsAbstractFactory.CreateObjectiveValueFactory().Create( (decimal)solution.ObjectiveValues.SingleOrDefault().Value) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // OverallWallTime this.OverallWallTime = resultsAbstractFactory.CreateOverallWallTimeFactory().Create( solution.OverallWallTime) .GetValueForOutputContext(); // v(m, r) this.MachineOperatingRoomAssignments = HM3AModel.v.GetElementsAt( resultElementsAbstractFactory.CreatevResultElementFactory(), resultsAbstractFactory.CreatevFactory(), HM3AModel.mr) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // w(j, r) this.SurgicalSpecialtyOperatingRoomAssignments = HM3AModel.w.GetElementsAt( resultElementsAbstractFactory.CreatewResultElementFactory(), resultsAbstractFactory.CreatewFactory(), HM3AModel.jr) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // y(s, r) Iy y = HM3AModel.y.GetElementsAt( resultElementsAbstractFactory.CreateyResultElementFactory(), resultsAbstractFactory.CreateyFactory(), HM3AModel.sr); this.SurgeonOperatingRoomAssignments = y .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // SurgeonNumberAssignedOperatingRooms this.SurgeonNumberAssignedOperatingRooms = calculationsAbstractFactory.CreateSurgeonNumberAssignedOperatingRoomsCalculationFactory().Create().Calculate( resultElementsAbstractFactory.CreateSurgeonNumberAssignedOperatingRoomsResultElementFactory(), resultsAbstractFactory.CreateSurgeonNumberAssignedOperatingRoomsFactory(), calculationsAbstractFactory.CreateSurgeonNumberAssignedOperatingRoomsResultElementCalculationFactory().Create(), HM3AModel.s, y) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // SurgicalSpecialtyNumberAssignedOperatingRooms this.SurgicalSpecialtyNumberAssignedOperatingRooms = calculationsAbstractFactory.CreateSurgicalSpecialtyNumberAssignedOperatingRoomsCalculationFactory().Create().Calculate( resultElementsAbstractFactory.CreateSurgicalSpecialtyNumberAssignedOperatingRoomsResultElementFactory(), resultsAbstractFactory.CreateSurgicalSpecialtyNumberAssignedOperatingRoomsFactory(), calculationsAbstractFactory.CreateSurgicalSpecialtyNumberAssignedOperatingRoomsResultElementCalculationFactory().Create(), HM3AModel.Δ, y) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); }
public TPOutputContext( ICalculationsAbstractFactory calculationsAbstractFactory, IDependenciesAbstractFactory dependenciesAbstractFactory, IResultElementsAbstractFactory resultElementsAbstractFactory, IResultsAbstractFactory resultsAbstractFactory, ITPModel TPModel, Solution solution) { // BestBound this.BestBound = resultsAbstractFactory.CreateBestBoundFactory().Create( (decimal)solution.BestBound) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // Gap this.Gap = resultsAbstractFactory.CreateGapFactory().Create( (decimal)solution.Gap) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // NumberOfExploredNodes this.NumberOfExploredNodes = resultsAbstractFactory.CreateNumberOfExploredNodesFactory().Create( solution.NumberOfExploredNodes) .GetValueForOutputContext(); // ObjectiveValue this.ObjectiveValue = resultsAbstractFactory.CreateObjectiveValueFactory().Create( (decimal)solution.ObjectiveValues.SingleOrDefault().Value) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // OverallWallTime this.OverallWallTime = resultsAbstractFactory.CreateOverallWallTimeFactory().Create( solution.OverallWallTime) .GetValueForOutputContext(); // x(p, a) Interfaces.Results.TP.PatientGroupActiveDayNumberPatientAssignments.ITPx x = TPModel.x.GetElementsAt( resultElementsAbstractFactory.CreateTPxResultElementFactory(), resultsAbstractFactory.CreateTPxFactory(), TPModel.pa); this.PatientGroupActiveDayNumberPatientAssignments = x .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // y(w) this.WardNumberBedAssignments = TPModel.y.GetElementsAt( resultElementsAbstractFactory.CreateTPyResultElementFactory(), resultsAbstractFactory.CreateTPyFactory(), TPModel.w) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // z(s, a, r, k) Interfaces.Results.TP.SurgeonGroupActiveDayOperatingRoomBlockTypeAssignments.ITPz z = TPModel.z.GetElementsAt( resultElementsAbstractFactory.CreateTPzResultElementFactory(), resultsAbstractFactory.CreateTPzFactory(), TPModel.sark); this.SurgeonGroupActiveDayOperatingRoomBlockTypeAssignments = z .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // δMinus(w, d) this.WardDayBedAvailabilityMinusDeviations = TPModel.δMinus.GetElementsAt( resultElementsAbstractFactory.CreateδMinusResultElementFactory(), resultsAbstractFactory.CreateδMinusFactory(), TPModel.wd) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // δPlus(w) this.WardSpareBeds = TPModel.δPlus_w.GetElementsAt( resultElementsAbstractFactory.CreateδPluswResultElementFactory(), resultsAbstractFactory.CreateδPluswFactory(), TPModel.w) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // δPlus(w, d) this.WardDayBedAvailabilityPlusDeviations = TPModel.δPlus_wd.GetElementsAt( resultElementsAbstractFactory.CreateδPluswdResultElementFactory(), resultsAbstractFactory.CreateδPluswdFactory(), TPModel.wd) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // μ(w, d) Interfaces.Results.TP.WardDayBedRequirementMeans.Iμ μ = TPModel.μ.GetElementsAt( resultElementsAbstractFactory.CreateμResultElementFactory(), resultsAbstractFactory.CreateμFactory(), TPModel.wd); this.WardDayBedRequirementMeans = μ .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // Variance(w) this.WardBedOccupancyVariances = TPModel.Variance_w.GetElementsAt( resultElementsAbstractFactory.CreateVariancewResultElementFactory(), resultsAbstractFactory.CreateVariancewFactory(), TPModel.w) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // Variance(w, d) Interfaces.Results.TP.WardDayBedRequirementVariances.IVariance Variance_wd = TPModel.Variance_wd.GetElementsAt( resultElementsAbstractFactory.CreateVariancewdResultElementFactory(), resultsAbstractFactory.CreateVariancewdFactory(), TPModel.wd); this.WardDayBedRequirementVariances = Variance_wd .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // DayBedRequirementMeans(d) this.DayBedRequirementMeans = calculationsAbstractFactory.CreateDayBedRequirementMeansCalculationFactory().Create() .Calculate( resultElementsAbstractFactory.CreateDayBedRequirementMeansResultElementFactory(), resultsAbstractFactory.CreateDayBedRequirementMeansFactory(), calculationsAbstractFactory.CreateDayBedRequirementMeansResultElementCalculationFactory().Create(), TPModel.d, μ) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // DayBedRequirementVariances(d) this.DayBedRequirementVariances = calculationsAbstractFactory.CreateDayBedRequirementVariancesCalculationFactory().Create() .Calculate( resultElementsAbstractFactory.CreateDayBedRequirementVariancesResultElementFactory(), resultsAbstractFactory.CreateDayBedRequirementVariancesFactory(), calculationsAbstractFactory.CreateDayBedRequirementVariancesResultElementCalculationFactory().Create(), TPModel.d, Variance_wd) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // EBS(d) Interfaces.Results.TP.DayExpectedBedShortages.IEBS EBS = calculationsAbstractFactory.CreateEBSCalculationFactory().Create() .Calculate( resultElementsAbstractFactory.CreateEBSResultElementFactory(), resultsAbstractFactory.CreateEBSFactory(), calculationsAbstractFactory.CreateEBSResultElementCalculationFactory().Create(), TPModel.d, TPModel.w, TPModel.BEDS, μ, Variance_wd); this.DayExpectedBedShortages = EBS .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // NumberPatients this.NumberPatients = calculationsAbstractFactory.CreateNumberPatientsCalculationFactory().Create() .Calculate( resultsAbstractFactory.CreateNumberPatientsFactory(), TPModel.pa, x) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // SurgeonGroupNumberAssignedOperatingRooms(s) this.SurgeonGroupNumberAssignedOperatingRooms = calculationsAbstractFactory.CreateSurgeonGroupNumberAssignedOperatingRoomsCalculationFactory().Create() .Calculate( resultElementsAbstractFactory.CreateSurgeonGroupNumberAssignedOperatingRoomsResultElementFactory(), resultsAbstractFactory.CreateSurgeonGroupNumberAssignedOperatingRoomsFactory(), calculationsAbstractFactory.CreateSurgeonGroupNumberAssignedOperatingRoomsResultElementCalculationFactory().Create(), TPModel.s, z) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // SurgeonGroupNumberAssignedActiveDays(s) this.SurgeonGroupNumberAssignedActiveDays = calculationsAbstractFactory.CreateSurgeonGroupNumberAssignedActiveDaysCalculationFactory().Create() .Calculate( resultElementsAbstractFactory.CreateSurgeonGroupNumberAssignedActiveDaysResultElementFactory(), resultsAbstractFactory.CreateSurgeonGroupNumberAssignedActiveDaysFactory(), calculationsAbstractFactory.CreateSurgeonGroupNumberAssignedActiveDaysResultElementCalculationFactory().Create(), TPModel.s, z) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // SurgeonGroupNumberPatients(s) this.SurgeonGroupNumberPatients = calculationsAbstractFactory.CreateSurgeonGroupNumberPatientsCalculationFactory().Create() .Calculate( resultElementsAbstractFactory.CreateSurgeonGroupNumberPatientsResultElementFactory(), resultsAbstractFactory.CreateSurgeonGroupNumberPatientsFactory(), calculationsAbstractFactory.CreateSurgeonGroupNumberPatientsResultElementCalculationFactory().Create(), TPModel.s, TPModel.pa, TPModel.Ps, x) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // TEBS this.TotalExpectedBedShortage = calculationsAbstractFactory.CreateTEBSCalculationFactory().Create() .Calculate( resultsAbstractFactory.CreateTEBSFactory(), TPModel.d, EBS) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // TotalTime ITotalTime totalTime = calculationsAbstractFactory.CreateTotalTimeCalculationFactory().Create() .Calculate( resultsAbstractFactory.CreateTotalTimeFactory(), TPModel.sark, TPModel.Length, z); this.TotalTime = totalTime.GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // UtilizedTime IUtilizedTime utilizedTime = calculationsAbstractFactory.CreateUtilizedTimeCalculationFactory().Create() .Calculate( resultsAbstractFactory.CreateUtilizedTimeFactory(), TPModel.pa, TPModel.dur, x); this.UtilizedTime = utilizedTime.GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // UnutilizedTime IUnutilizedTime unutilizedTime = calculationsAbstractFactory.CreateUnutilizedTimeCalculationFactory().Create() .Calculate( resultsAbstractFactory.CreateUnutilizedTimeFactory(), totalTime, utilizedTime); this.UnutilizedTime = unutilizedTime.GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // Underutilization this.Underutilization = calculationsAbstractFactory.CreateUnderutilizationCalculationFactory().Create() .Calculate( resultsAbstractFactory.CreateUnderutilizationFactory(), totalTime, unutilizedTime) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // WardNumberAssignedOperatingRooms(w) this.WardNumberAssignedOperatingRooms = calculationsAbstractFactory.CreateWardNumberAssignedOperatingRoomsCalculationFactory().Create() .Calculate( resultElementsAbstractFactory.CreateWardNumberAssignedOperatingRoomsResultElementFactory(), resultsAbstractFactory.CreateWardNumberAssignedOperatingRoomsFactory(), calculationsAbstractFactory.CreateWardNumberAssignedOperatingRoomsResultElementCalculationFactory().Create(), TPModel.W, z) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // WardGroupNumberAssignedActiveDays(w) this.WardNumberAssignedActiveDays = calculationsAbstractFactory.CreateWardNumberAssignedActiveDaysCalculationFactory().Create() .Calculate( resultElementsAbstractFactory.CreateWardNumberAssignedActiveDaysResultElementFactory(), resultsAbstractFactory.CreateWardNumberAssignedActiveDaysFactory(), calculationsAbstractFactory.CreateWardNumberAssignedActiveDaysResultElementCalculationFactory().Create(), TPModel.W, z) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); }
public HM5Model( ICalculationsAbstractFactory calculationsAbstractFactory, IConstraintElementsAbstractFactory constraintElementsAbstractFactory, IConstraintsAbstractFactory constraintsAbstractFactory, ICrossJoinElementsAbstractFactory crossJoinElementsAbstractFactory, ICrossJoinsAbstractFactory crossJoinsAbstractFactory, IDependenciesAbstractFactory dependenciesAbstractFactory, IIndexElementsAbstractFactory indexElementsAbstractFactory, IIndicesAbstractFactory indicesAbstractFactory, IObjectiveFunctionsAbstractFactory objectiveFunctionsAbstractFactory, IParameterElementsAbstractFactory parameterElementsAbstractFactory, IParametersAbstractFactory parametersAbstractFactory, IVariablesAbstractFactory variablesAbstractFactory, IHM5InputContext HM5InputContext) { this.Context = HM5InputContext; this.Model = dependenciesAbstractFactory.CreateModelFactory().Create(); // Indices // d1 this.d1 = indicesAbstractFactory.Created1Factory().Create( this.Context.Weekdays .Select(x => indexElementsAbstractFactory.Created1IndexElementFactory().Create((PositiveInt)x)) .ToImmutableList()); // d2 this.d2 = indicesAbstractFactory.Created2Factory().Create( this.Context.Weekdays .Select(x => indexElementsAbstractFactory.Created2IndexElementFactory().Create((PositiveInt)x)) .ToImmutableList()); // j this.j = indicesAbstractFactory.CreatejFactory().Create( this.Context.SurgicalSpecialties .Select(x => x.Item1) .Select(x => indexElementsAbstractFactory.CreatejIndexElementFactory().Create(x)) .ToImmutableList()); // l this.l = indicesAbstractFactory.CreatelFactory().Create( this.Context.LengthOfStayDays .Select(x => indexElementsAbstractFactory.CreatelIndexElementFactory().Create((PositiveInt)x)) .ToImmutableList()); // r this.r = indicesAbstractFactory.CreaterFactory().Create( this.Context.OperatingRooms .Entry .Where(x => x.Resource is Location) .Select(x => indexElementsAbstractFactory.CreaterIndexElementFactory().Create((Location)x.Resource)) .ToImmutableList()); // s this.s = indicesAbstractFactory.CreatesFactory().Create( this.Context.Surgeons .Entry .Where(x => x.Resource is Organization) .Select(x => indexElementsAbstractFactory.CreatesIndexElementFactory().Create((Organization)x.Resource)) .ToImmutableList()); // t this.t = indicesAbstractFactory.CreatetFactory().Create( this.Context.PlanningHorizon .Select(x => indexElementsAbstractFactory.CreatetIndexElementFactory().Create( x.Key.Value.Value, x.Value)) .ToImmutableList()); // Λ this.Λ = indicesAbstractFactory.CreateΛFactory().Create( this.Context.Scenarios .Select(x => indexElementsAbstractFactory.CreateΛIndexElementFactory().Create((PositiveInt)x)) .ToImmutableList()); // Cross joins // rd1 this.rd1 = crossJoinsAbstractFactory.Createrd1Factory().Create( this.r.Value .SelectMany(b => this.d1.Value, (a, b) => crossJoinElementsAbstractFactory.Createrd1CrossJoinElementFactory().Create(a, b)) .ToImmutableList()); // rd1d2 this.rd1d2 = crossJoinsAbstractFactory.Createrd1d2Factory().Create( this.r.Value .SelectMany(b => this.d1.Value, (a, b) => crossJoinElementsAbstractFactory.Createrd1CrossJoinElementFactory().Create(a, b)) .SelectMany(b => this.d2.Value, (a, b) => crossJoinElementsAbstractFactory.Createrd1d2CrossJoinElementFactory().Create(a.rIndexElement, a.d1IndexElement, b)) .ToImmutableList()); // rd2 this.rd2 = crossJoinsAbstractFactory.Createrd2Factory().Create( this.r.Value .SelectMany(b => this.d2.Value, (a, b) => crossJoinElementsAbstractFactory.Createrd2CrossJoinElementFactory().Create(a, b)) .ToImmutableList()); // rt this.rt = crossJoinsAbstractFactory.CreatertFactory().Create( this.r.Value .SelectMany(b => this.t.Value, (a, b) => crossJoinElementsAbstractFactory.CreatertCrossJoinElementFactory().Create(a, b)) .ToImmutableList()); // slΛ this.slΛ = crossJoinsAbstractFactory.CreateslΛFactory().Create( this.s.Value .SelectMany(b => this.l.Value, (a, b) => crossJoinElementsAbstractFactory.CreateslCrossJoinElementFactory().Create(a, b)) .SelectMany(b => this.Λ.Value, (a, b) => crossJoinElementsAbstractFactory.CreateslΛCrossJoinElementFactory().Create(a.sIndexElement, a.lIndexElement, b)) .ToImmutableList()); // srd2 this.srd2 = crossJoinsAbstractFactory.Createsrd2Factory().Create( this.s.Value .SelectMany(b => this.r.Value, (a, b) => crossJoinElementsAbstractFactory.CreatesrCrossJoinElementFactory().Create(a, b)) .SelectMany(b => this.d2.Value, (a, b) => crossJoinElementsAbstractFactory.Createsrd2CrossJoinElementFactory().Create(a.sIndexElement, a.rIndexElement, b)) .ToImmutableList()); // srd2t this.srd2t = crossJoinsAbstractFactory.Createsrd2tFactory().Create( this.s.Value .SelectMany(b => this.r.Value, (a, b) => crossJoinElementsAbstractFactory.CreatesrCrossJoinElementFactory().Create(a, b)) .SelectMany(b => this.d2.Value, (a, b) => crossJoinElementsAbstractFactory.Createsrd2CrossJoinElementFactory().Create(a.sIndexElement, a.rIndexElement, b)) .SelectMany(b => this.t.Value, (a, b) => crossJoinElementsAbstractFactory.Createsrd2tCrossJoinElementFactory().Create(a.sIndexElement, a.rIndexElement, a.d2IndexElement, b)) .ToImmutableList()); // srt this.srt = crossJoinsAbstractFactory.CreatesrtFactory().Create( this.s.Value .SelectMany(b => this.r.Value, (a, b) => crossJoinElementsAbstractFactory.CreatesrCrossJoinElementFactory().Create(a, b)) .SelectMany(b => this.t.Value, (a, b) => crossJoinElementsAbstractFactory.CreatesrtCrossJoinElementFactory().Create(a.sIndexElement, a.rIndexElement, b)) .ToImmutableList()); // st this.st = crossJoinsAbstractFactory.CreatestFactory().Create( this.s.Value .SelectMany(b => this.t.Value, (a, b) => crossJoinElementsAbstractFactory.CreatestCrossJoinElementFactory().Create(a, b)) .ToImmutableList()); // sΛ this.sΛ = crossJoinsAbstractFactory.CreatesΛFactory().Create( this.s.Value .SelectMany(b => this.Λ.Value, (a, b) => crossJoinElementsAbstractFactory.CreatesΛCrossJoinElementFactory().Create(a, b)) .ToImmutableList()); // tΛ this.tΛ = crossJoinsAbstractFactory.CreatetΛFactory().Create( this.t.Value .SelectMany(b => this.Λ.Value, (a, b) => crossJoinElementsAbstractFactory.CreatetΛCrossJoinElementFactory().Create(a, b)) .ToImmutableList()); // Parameters // H this.H = parametersAbstractFactory.CreateHFactory().Create( this.Context.TimeBlockLength); // h(s, Λ) this.h = parametersAbstractFactory.CreatehFactory().Create( this.Context.SurgeonScenarioWeightedAverageSurgicalDurations .Select(x => parameterElementsAbstractFactory.CreatehParameterElementFactory().Create( this.s.GetElementAt(x.Item1), this.Λ.GetElementAt((PositiveInt)x.Item2), x.Item3)) .ToImmutableList()); // L(s) this.L = parametersAbstractFactory.CreateLFactory().Create( this.Context.SurgeonLengthOfStayMaximums .Select(x => parameterElementsAbstractFactory.CreateLParameterElementFactory().Create( this.s.GetElementAt(x.Key), (PositiveInt)x.Value)) .ToImmutableList()); // n(s, Λ) this.n = parametersAbstractFactory.CreatenFactory().Create( this.Context.SurgeonScenarioMaximumNumberPatients .Select(x => parameterElementsAbstractFactory.CreatenParameterElementFactory().Create( this.s.GetElementAt(x.Item1), this.Λ.GetElementAt((PositiveInt)x.Item2), (PositiveInt)x.Item3)) .ToImmutableList()); // p(s, l, Λ) this.p = parametersAbstractFactory.CreatepFactory().Create( this.Context.SurgeonDayScenarioLengthOfStayProbabilities .Select(x => parameterElementsAbstractFactory.CreatepParameterElementFactory().Create( this.s.GetElementAt(x.Item1), this.l.GetElementAt((PositiveInt)x.Item2), this.Λ.GetElementAt((PositiveInt)x.Item3), (FhirDecimal)x.Item4)) .ToImmutableList()); // Δ(j) // Must be populated before S1 this.Δ = parametersAbstractFactory.CreateΔFactory().Create( this.Context.SurgicalSpecialties .Select(x => parameterElementsAbstractFactory.CreateΔParameterElementFactory().Create( this.j.GetElementAt(x.Item1), x.Item2.Select(i => this.s.GetElementAt(i)).ToImmutableList())) .ToImmutableList()); // x(s, r, t) // Must be populated before S1 this.x = parametersAbstractFactory.CreatexFactory().Create( this.Context.SurgeonOperatingRoomDayAssignments .Select(x => parameterElementsAbstractFactory.CreatexParameterElementFactory().Create( this.s.GetElementAt(x.Item1), this.r.GetElementAt(x.Item2), this.t.GetElementAt(x.Item3), (FhirBoolean)x.Item4)) .ToImmutableList()); // S1 this.S1 = calculationsAbstractFactory.CreateS1CalculationFactory().Create().Calculate( parameterElementsAbstractFactory.CreateS1ParameterElementFactory(), parametersAbstractFactory.CreateS1Factory(), this.r, this.x, this.Δ); // W // Must be populated before S2 this.W = parametersAbstractFactory.CreateWFactory().Create( (PositiveInt)this.Context.NumberDaysPerWeek); // S2 this.S2 = calculationsAbstractFactory.CreateS2CalculationFactory().Create().Calculate( parameterElementsAbstractFactory.CreateS2ParameterElementFactory(), parametersAbstractFactory.CreateS2Factory(), this.d1, this.d2, this.r, this.t, this.rd1d2, this.W, this.x, this.Δ); // y(s, r) this.y = parametersAbstractFactory.CreateyFactory().Create( this.Context.SurgeonOperatingRoomAssignments .Select(x => parameterElementsAbstractFactory.CreateyParameterElementFactory().Create( this.s.GetElementAt(x.Item1), this.r.GetElementAt(x.Item2), (FhirBoolean)x.Item3)) .ToImmutableList()); // γ(r, t) this.γ = parametersAbstractFactory.CreateγFactory().Create( this.Context.OperatingRoomDayAssignedAvailabilities .Select(x => parameterElementsAbstractFactory.CreateγParameterElementFactory().Create( this.r.GetElementAt(x.Item1), this.t.GetElementAt(x.Item2), (FhirBoolean)x.Item3)) .ToImmutableList()); // μ(s, Λ) this.μ = parametersAbstractFactory.CreateμFactory().Create( this.Context.SurgeonScenarioMaximumNumberPatientMeans .Select(x => parameterElementsAbstractFactory.CreateμParameterElementFactory().Create( this.s.GetElementAt(x.Item1), this.Λ.GetElementAt((PositiveInt)x.Item2), (FhirDecimal)x.Item3)) .ToImmutableList()); // Ρ(Λ) this.Ρ = parametersAbstractFactory.CreateΡFactory().Create( this.Context.ScenarioProbabilities .Select(x => parameterElementsAbstractFactory.CreateΡParameterElementFactory().Create( this.Λ.GetElementAt((PositiveInt)x.Key), (FhirDecimal)x.Value)) .ToImmutableList()); // σ(s, Λ) this.σ = parametersAbstractFactory.CreateσFactory().Create( this.Context.SurgeonScenarioMaximumNumberPatientStandardDeviations .Select(x => parameterElementsAbstractFactory.CreateσParameterElementFactory().Create( this.s.GetElementAt(x.Item1), this.Λ.GetElementAt((PositiveInt)x.Item2), (FhirDecimal)x.Item3)) .ToImmutableList()); // ΦHat(s, l, Λ) this.ΦHat = parametersAbstractFactory.CreateΦHatFactory().Create( this.Context.SurgeonDayScenarioCumulativeNumberPatients .Select(x => parameterElementsAbstractFactory.CreateΦHatParameterElementFactory().Create( this.s.GetElementAt(x.Item1), this.l.GetElementAt((PositiveInt)x.Item2), this.Λ.GetElementAt((PositiveInt)x.Item3), (FhirDecimal)x.Item4)) .ToImmutableList()); // Ω this.Ω = parametersAbstractFactory.CreateΩFactory().Create( (PositiveInt)this.Context.MaximumNumberRecoveryWardBeds); // Variables // IHat(t, Λ) this.IHat = variablesAbstractFactory.CreateIHatFactory().Create( dependenciesAbstractFactory.CreateVariableCollectionFactory().Create( model: this.Model, indexSet1: this.t.Value, indexSet2: this.Λ.Value, lowerBoundGenerator: (a, b) => 0, upperBoundGenerator: (a, b) => double.MaxValue, variableTypeGenerator: (a, b) => VariableType.Continuous)); // xHat(s, r, t) this.xHat = variablesAbstractFactory.CreatexHatFactory().Create( dependenciesAbstractFactory.CreateVariableCollectionFactory().Create( model: this.Model, indexSet1: this.s.Value, indexSet2: this.r.Value, indexSet3: this.t.Value, lowerBoundGenerator: (a, b, c) => 0, upperBoundGenerator: (a, b, c) => 1, variableTypeGenerator: (a, b, c) => VariableType.Binary)); // z(s, t) this.z = variablesAbstractFactory.CreatezFactory().Create( dependenciesAbstractFactory.CreateVariableCollectionFactory().Create( model: this.Model, indexSet1: this.s.Value, indexSet2: this.t.Value, lowerBoundGenerator: (a, b) => 0, upperBoundGenerator: (a, b) => 1, variableTypeGenerator: (a, b) => VariableType.Binary)); // α(r, d1, d2) this.α = variablesAbstractFactory.CreateαFactory().Create( dependenciesAbstractFactory.CreateVariableCollectionFactory().Create( model: this.Model, indexSet1: this.r.Value, indexSet2: this.d1.Value, indexSet3: this.d2.Value, lowerBoundGenerator: (a, b, c) => 0, upperBoundGenerator: (a, b, c) => 1, variableTypeGenerator: (a, b, c) => VariableType.Binary)); // Constraints // Constraints 1 this.Model.AddConstraints( this.st.Value .Select( x => constraintElementsAbstractFactory.CreateConstraints1ConstraintElementFactory().Create( x.sIndexElement, x.tIndexElement, this.r, this.xHat, this.z) .Value)); // Constraints 2 this.Model.AddConstraints( this.rt.Value .Select( x => constraintElementsAbstractFactory.CreateConstraints2ConstraintElementFactory().Create( x.rIndexElement, x.tIndexElement, this.s, this.γ, this.xHat) .Value)); // Constraints 3 this.Model.AddConstraints( this.srt.Value .Select( x => constraintElementsAbstractFactory.CreateConstraints3ConstraintElementFactory().Create( x.rIndexElement, x.sIndexElement, x.tIndexElement, this.y, this.xHat) .Value)); // Constraints 4 this.Model.AddConstraints( this.tΛ.Value .Select( x => constraintElementsAbstractFactory.CreateConstraints4ConstraintElementFactory().Create( x.tIndexElement, x.ΛIndexElement, this.l, this.t, this.st, this.ΦHat, this.IHat, this.z) .Value)); // Constraints 5 this.Model.AddConstraints( this.rd1.Value .Where(x => this.S1.IsThereElementAt(x.rIndexElement)) .Select( x => constraintElementsAbstractFactory.CreateConstraints5ConstraintElementFactory().Create( x.d1IndexElement, x.rIndexElement, this.d2, this.α) .Value)); // Constraints 6 this.Model.AddConstraints( this.rd2.Value .Where(x => this.S1.IsThereElementAt(x.rIndexElement)) .Select( x => constraintElementsAbstractFactory.CreateConstraints6ConstraintElementFactory().Create( x.d2IndexElement, x.rIndexElement, this.d1, this.α) .Value)); // Constraints 7 this.Model.AddConstraints( this.rd1d2.Value .Where(x => this.S1.IsThereElementAt(x.rIndexElement)) .Where(x => this.S2.IsThereElementAt( x.rIndexElement, x.d1IndexElement, x.d2IndexElement)) .Select( x => constraintElementsAbstractFactory.CreateConstraints7ConstraintElementFactory().Create( x.rIndexElement, x.d1IndexElement, x.d2IndexElement, this.α) .Value)); // Constraints 8 this.Model.AddConstraints( this.srd2.Value .Where(x => this.S1.IsThereElementAt(x.rIndexElement)) .SelectMany(b => this.t.GetNthElementsAt( 0, this.W.Value.Value.Value * ((this.t.GetT() / this.W.Value.Value.Value) - 1), this.W.Value.Value.Value), (a, b) => Tuple.Create(a.sIndexElement, a.rIndexElement, a.d2IndexElement, b)) .Select( x => constraintElementsAbstractFactory.CreateConstraints8ConstraintElementFactory().Create( x.Item3, x.Item2, x.Item1, x.Item4, this.d1, this.t, this.x, this.xHat, this.α) .Value)); // Constraints 9 this.Model.AddConstraints( this.srt.Value .Where(x => !this.S1.IsThereElementAt(x.rIndexElement)) .Select( x => constraintElementsAbstractFactory.CreateConstraints9ConstraintElementFactory().Create( x.rIndexElement, x.sIndexElement, x.tIndexElement, this.x, this.xHat) .Value)); // Objective function this.Model.AddObjective( objectiveFunctionsAbstractFactory.CreateObjectiveFunctionFactory().Create( dependenciesAbstractFactory.CreateObjectiveFactory(), this.t, this.Λ, this.Ρ, this.IHat) .Value); }
public HM3BOutputContext( ICalculationsAbstractFactory calculationsAbstractFactory, IDependenciesAbstractFactory dependenciesAbstractFactory, IResultElementsAbstractFactory resultElementsAbstractFactory, IResultsAbstractFactory resultsAbstractFactory, IHM3BModel HM3BModel, Solution solution, HM3BEncodingEnum HM3BEncodingEnum) { // BestBound this.BestBound = resultsAbstractFactory.CreateBestBoundFactory().Create( (decimal)solution.BestBound) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // Gap this.Gap = resultsAbstractFactory.CreateGapFactory().Create( (decimal)solution.Gap) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // NumberOfExploredNodes this.NumberOfExploredNodes = resultsAbstractFactory.CreateNumberOfExploredNodesFactory().Create( solution.NumberOfExploredNodes) .GetValueForOutputContext(); // ObjectiveValue this.ObjectiveValue = resultsAbstractFactory.CreateObjectiveValueFactory().Create( (decimal)solution.ObjectiveValues.SingleOrDefault().Value) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // OverallWallTime this.OverallWallTime = resultsAbstractFactory.CreateOverallWallTimeFactory().Create( solution.OverallWallTime) .GetValueForOutputContext(); // x(s, r, t) Ix x = HM3BModel.x.GetElementsAt( resultElementsAbstractFactory.CreatexResultElementFactory(), resultsAbstractFactory.CreatexFactory(), HM3BModel.srt); this.SurgeonOperatingRoomDayAssignments = x .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // SurgeonNumberAssignedOperatingRooms this.SurgeonNumberAssignedOperatingRooms = calculationsAbstractFactory.CreateSurgeonNumberAssignedOperatingRoomsCalculationFactory().Create().Calculate( resultElementsAbstractFactory.CreateSurgeonNumberAssignedOperatingRoomsResultElementFactory(), resultsAbstractFactory.CreateSurgeonNumberAssignedOperatingRoomsFactory(), calculationsAbstractFactory.CreateSurgeonNumberAssignedOperatingRoomsResultElementCalculationFactory().Create(), HM3BModel.s, x) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // SurgeonNumberAssignedWeekdays this.SurgeonNumberAssignedWeekdays = calculationsAbstractFactory.CreateSurgeonNumberAssignedWeekdaysCalculationFactory().Create().Calculate( resultElementsAbstractFactory.CreateSurgeonNumberAssignedWeekdaysResultElementFactory(), resultsAbstractFactory.CreateSurgeonNumberAssignedWeekdaysFactory(), calculationsAbstractFactory.CreateSurgeonNumberAssignedWeekdaysResultElementCalculationFactory().Create(), HM3BModel.s, x) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // SurgeonScenarioNumberPatients ISurgeonScenarioNumberPatients surgeonScenarioNumberPatients = calculationsAbstractFactory.CreateSurgeonScenarioNumberPatientsCalculationFactory().Create().Calculate( resultElementsAbstractFactory.CreateSurgeonScenarioNumberPatientsResultElementFactory(), resultsAbstractFactory.CreateSurgeonScenarioNumberPatientsFactory(), calculationsAbstractFactory.CreateSurgeonScenarioNumberPatientsResultElementCalculationFactory().Create(), HM3BModel.rt, HM3BModel.sΛ, HM3BModel.n, x); this.SurgeonScenarioNumberPatients = surgeonScenarioNumberPatients.GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // SurgicalSpecialtyNumberAssignedOperatingRooms this.SurgicalSpecialtyNumberAssignedOperatingRooms = calculationsAbstractFactory.CreateSurgicalSpecialtyNumberAssignedOperatingRoomsCalculationFactory().Create().Calculate( resultElementsAbstractFactory.CreateSurgicalSpecialtyNumberAssignedOperatingRoomsResultElementFactory(), resultsAbstractFactory.CreateSurgicalSpecialtyNumberAssignedOperatingRoomsFactory(), calculationsAbstractFactory.CreateSurgicalSpecialtyNumberAssignedOperatingRoomsResultElementCalculationFactory().Create(), HM3BModel.Δ, x) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // SurgicalSpecialtyNumberAssignedWeekdays this.SurgicalSpecialtyNumberAssignedWeekdays = calculationsAbstractFactory.CreateSurgicalSpecialtyNumberAssignedWeekdaysCalculationFactory().Create().Calculate( resultElementsAbstractFactory.CreateSurgicalSpecialtyNumberAssignedWeekdaysResultElementFactory(), resultsAbstractFactory.CreateSurgicalSpecialtyNumberAssignedWeekdaysFactory(), calculationsAbstractFactory.CreateSurgicalSpecialtyNumberAssignedWeekdaysResultElementCalculationFactory().Create(), HM3BModel.Δ, x) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // y(s, r) Iy y = HM3BEncodingEnum switch { HM3BEncodingEnum.E001 => ((IHM3B001Model)HM3BModel).y.GetElementsAt( resultElementsAbstractFactory.CreateyResultElementFactory(), resultsAbstractFactory.CreateyFactory(), ((IHM3B001Model)HM3BModel).sr), HM3BEncodingEnum.E011 => ((IHM3B011Model)HM3BModel).y.GetElementsAt( resultElementsAbstractFactory.CreateyResultElementFactory(), resultsAbstractFactory.CreateyFactory(), ((IHM3B011Model)HM3BModel).sr), HM3BEncodingEnum.E101 => ((IHM3B101Model)HM3BModel).y.GetElementsAt( resultElementsAbstractFactory.CreateyResultElementFactory(), resultsAbstractFactory.CreateyFactory(), ((IHM3B101Model)HM3BModel).sr), HM3BEncodingEnum.E111 => ((IHM3B111Model)HM3BModel).y.GetElementsAt( resultElementsAbstractFactory.CreateyResultElementFactory(), resultsAbstractFactory.CreateyFactory(), ((IHM3B111Model)HM3BModel).sr), _ => null }; if (y != null) { this.SurgeonOperatingRoomAssignments = y .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); } // z(s, t) Iz z = HM3BModel.z.GetElementsAt( resultElementsAbstractFactory.CreatezResultElementFactory(), resultsAbstractFactory.CreatezFactory(), HM3BModel.st); this.SurgeonDayAssignments = z .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // β(s, r, d) this.SurgeonOperatingRoomDayNumberAssignedTimeBlocks = HM3BModel.β.GetElementsAt( resultElementsAbstractFactory.CreateβResultElementFactory(), resultsAbstractFactory.CreateβFactory(), HM3BModel.srd) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // γ(r, t) this.OperatingRoomDayAssignedAvailabilities = HM3BModel.γ.GetElementsAt( resultElementsAbstractFactory.CreateγResultElementFactory(), resultsAbstractFactory.CreateγFactory(), HM3BModel.rt) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // ScenarioNumberPatients(Λ) this.ScenarioNumberPatients = calculationsAbstractFactory.CreateScenarioNumberPatientsCalculationFactory().Create() .Calculate( resultElementsAbstractFactory.CreateScenarioNumberPatientsResultElementFactory(), resultsAbstractFactory.CreateScenarioNumberPatientsFactory(), calculationsAbstractFactory.CreateScenarioNumberPatientsResultElementCalculationFactory().Create(), HM3BModel.Λ, surgeonScenarioNumberPatients) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // ExpectedValueΦ(s, l, Λ) IExpectedValueΦ expectedValueΦ = calculationsAbstractFactory.CreateExpectedValueΦCalculationFactory().Create() .Calculate( resultElementsAbstractFactory.CreateExpectedValueΦResultElementFactory(), resultsAbstractFactory.CreateExpectedValueΦFactory(), calculationsAbstractFactory.CreateExpectedValueΦResultElementCalculationFactory().Create(), HM3BModel.l, HM3BModel.t, HM3BModel.slΛ, HM3BModel.L, HM3BModel.p, HM3BModel.μ); // VarianceΦ(s, l, Λ) IVarianceΦ varianceΦ = calculationsAbstractFactory.CreateVarianceΦCalculationFactory().Create() .Calculate( resultElementsAbstractFactory.CreateVarianceΦResultElementFactory(), resultsAbstractFactory.CreateVarianceΦFactory(), calculationsAbstractFactory.CreateVarianceΦResultElementCalculationFactory().Create(), HM3BModel.l, HM3BModel.t, HM3BModel.slΛ, HM3BModel.L, HM3BModel.p, HM3BModel.μ, HM3BModel.σ); // ExpectedValueI(t, Λ) Interfaces.Results.DayScenarioRecoveryWardUtilizations.IExpectedValueI expectedValueI = calculationsAbstractFactory.CreateExpectedValueICalculationFactory().Create() .Calculate( resultElementsAbstractFactory.CreateExpectedValueIResultElementFactory(), resultsAbstractFactory.CreateExpectedValueIFactory(), calculationsAbstractFactory.CreateExpectedValueIResultElementCalculationFactory().Create(), HM3BModel.l, HM3BModel.t, HM3BModel.st, HM3BModel.tΛ, expectedValueΦ, z); this.DayScenarioRecoveryWardUtilizationExpectedValues = expectedValueI .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // VarianceI(t, Λ) IVarianceI varianceI = calculationsAbstractFactory.CreateVarianceICalculationFactory().Create() .Calculate( resultElementsAbstractFactory.CreateVarianceIResultElementFactory(), resultsAbstractFactory.CreateVarianceIFactory(), calculationsAbstractFactory.CreateVarianceIResultElementCalculationFactory().Create(), HM3BModel.l, HM3BModel.t, HM3BModel.st, HM3BModel.tΛ, varianceΦ, z); this.DayScenarioRecoveryWardUtilizationVariances = varianceI .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // EBS(t, Λ) IEBS EBS = calculationsAbstractFactory.CreateEBSCalculationFactory().Create() .Calculate( resultElementsAbstractFactory.CreateEBSResultElementFactory(), resultsAbstractFactory.CreateEBSFactory(), calculationsAbstractFactory.CreateEBSResultElementCalculationFactory().Create(), HM3BModel.tΛ, HM3BModel.Ω, expectedValueI, varianceI); this.DayScenarioExpectedBedShortages = EBS .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // TEBS(Λ) Interfaces.Results.ScenarioTotalExpectedBedShortages.ITEBS TEBS_Λ = calculationsAbstractFactory.CreateTEBSΛCalculationFactory().Create() .Calculate( resultElementsAbstractFactory.CreateTEBSΛResultElementFactory(), resultsAbstractFactory.CreateTEBSΛFactory(), calculationsAbstractFactory.CreateTEBSΛResultElementCalculationFactory().Create(), HM3BModel.t, HM3BModel.Λ, EBS); this.ScenarioTotalExpectedBedShortages = TEBS_Λ .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // TEBS this.TotalExpectedBedShortage = calculationsAbstractFactory.CreateTEBSCalculationFactory().Create() .Calculate( resultsAbstractFactory.CreateTEBSFactory(), HM3BModel.Λ, HM3BModel.Ρ, TEBS_Λ) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // ScenarioTotalTimes(Λ) IScenarioTotalTimes scenarioTotalTimes = calculationsAbstractFactory.CreateScenarioTotalTimesCalculationFactory().Create() .Calculate( resultElementsAbstractFactory.CreateScenarioTotalTimesResultElementFactory(), resultsAbstractFactory.CreateScenarioTotalTimesFactory(), calculationsAbstractFactory.CreateScenarioTotalTimesResultElementCalculationFactory().Create(), HM3BModel.Λ, HM3BModel.srt, HM3BModel.H, x); this.ScenarioTotalTimes = scenarioTotalTimes.GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // ScenarioUtilizedTimes(Λ) IScenarioUtilizedTimes scenarioUtilizedTimes = calculationsAbstractFactory.CreateScenarioUtilizedTimesCalculationFactory().Create() .Calculate( resultElementsAbstractFactory.CreateScenarioUtilizedTimesResultElementFactory(), resultsAbstractFactory.CreateScenarioUtilizedTimesFactory(), calculationsAbstractFactory.CreateScenarioUtilizedTimesResultElementCalculationFactory().Create(), HM3BModel.Λ, HM3BModel.srt, HM3BModel.h, HM3BModel.n, x); this.ScenarioUtilizedTimes = scenarioUtilizedTimes.GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // ScenarioUnutilizedTimes(Λ) IScenarioUnutilizedTimes scenarioUnutilizedTimes = calculationsAbstractFactory.CreateScenarioUnutilizedTimesCalculationFactory().Create() .Calculate( resultElementsAbstractFactory.CreateScenarioUnutilizedTimesResultElementFactory(), resultsAbstractFactory.CreateScenarioUnutilizedTimesFactory(), calculationsAbstractFactory.CreateScenarioUnutilizedTimesResultElementCalculationFactory().Create(), HM3BModel.Λ, scenarioTotalTimes, scenarioUtilizedTimes); this.ScenarioUnutilizedTimes = scenarioUnutilizedTimes.GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // ScenarioUnderutilizations(Λ) this.ScenarioUnderutilizations = calculationsAbstractFactory.CreateScenarioUnderutilizationsCalculationFactory().Create() .Calculate( resultElementsAbstractFactory.CreateScenarioUnderutilizationsResultElementFactory(), resultsAbstractFactory.CreateScenarioUnderutilizationsFactory(), calculationsAbstractFactory.CreateScenarioUnderutilizationsResultElementCalculationFactory().Create(), HM3BModel.Λ, scenarioTotalTimes, scenarioUnutilizedTimes) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); // ΦHat(s, l, Λ) this.SurgeonDayScenarioCumulativeNumberPatients = calculationsAbstractFactory.CreateΦHatCalculationFactory().Create() .Calculate( calculationsAbstractFactory.CreateExpectedValueIResultElementCalculationFactory(), calculationsAbstractFactory.CreateExpectedValueΦResultElementCalculationFactory(), calculationsAbstractFactory.CreateVarianceIResultElementCalculationFactory(), calculationsAbstractFactory.CreateVarianceΦResultElementCalculationFactory(), calculationsAbstractFactory.CreateVHatResultElementCalculationFactory(), calculationsAbstractFactory.Createυ2ResultElementCalculationFactory(), calculationsAbstractFactory.CreateΦHatResultElementCalculationFactory(), calculationsAbstractFactory.CreateExpectedValueICalculationFactory(), calculationsAbstractFactory.CreateExpectedValueΦCalculationFactory(), calculationsAbstractFactory.CreateMRNBCalculationFactory(), calculationsAbstractFactory.CreateRNBCalculationFactory(), calculationsAbstractFactory.CreatetStarCalculationFactory(), calculationsAbstractFactory.CreateVarianceICalculationFactory(), calculationsAbstractFactory.CreateVarianceΦCalculationFactory(), calculationsAbstractFactory.CreateVHatCalculationFactory(), calculationsAbstractFactory.Createυ2CalculationFactory(), dependenciesAbstractFactory.CreateNormalFactory(), resultElementsAbstractFactory.CreateExpectedValueIResultElementFactory(), resultElementsAbstractFactory.CreateExpectedValueΦResultElementFactory(), resultElementsAbstractFactory.CreateVarianceIResultElementFactory(), resultElementsAbstractFactory.CreateVarianceΦResultElementFactory(), resultElementsAbstractFactory.CreateVHatResultElementFactory(), resultElementsAbstractFactory.Createυ2ResultElementFactory(), resultElementsAbstractFactory.CreateΦHatResultElementFactory(), resultsAbstractFactory.CreateExpectedValueIFactory(), resultsAbstractFactory.CreateExpectedValueΦFactory(), resultsAbstractFactory.CreateVarianceIFactory(), resultsAbstractFactory.CreateVarianceΦFactory(), resultsAbstractFactory.CreateVHatFactory(), resultsAbstractFactory.Createυ2Factory(), resultsAbstractFactory.CreateΦHatFactory(), HM3BModel.l, HM3BModel.t, HM3BModel.Λ, HM3BModel.slΛ, HM3BModel.st, HM3BModel.tΛ, HM3BModel.L, HM3BModel.p, HM3BModel.μ, HM3BModel.σ, HM3BModel.Ω, z) .GetValueForOutputContext( dependenciesAbstractFactory.CreateNullableValueFactory()); }