public IUnutilizedTime Calculate(
     IUnutilizedTimeFactory unutilizedTimeFactory,
     ITotalTime totalTime,
     IUtilizedTime utilizedTime)
 {
     return(unutilizedTimeFactory.Create(
                totalTime.Value
                -
                utilizedTime.Value));
 }
        public IUtilizedTime Create(
            decimal value)
        {
            IUtilizedTime result = null;

            try
            {
                result = new UtilizedTime(
                    value);
            }
            catch (Exception exception)
            {
                this.Log.Error(
                    exception.Message,
                    exception);
            }

            return(result);
        }
Ejemplo n.º 3
0
        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());
        }