Example #1
0
def stochasticindex(request, schedule_id):
    duration = 0
    durationCDF = 0
    iterCount = int(request.GET.get('itercount', 1000))
    reportType = int(request.GET.get('type', 2))
    weather = Weather(schedule_id)
    durationList = []
    demoMode = settings.DEMO_MODE

    if reportType == 2:
        durationList = weather.CalcStochastic(iterCount,
                                              ReportType.WEATHER_AWARE)
    if reportType == 4:
        # This should be the weather aware point, even though it is unlikely to show
        _, duration, _ = CalcReverseReport(schedule_id)
        weather.schedule.StatusTypeId = 1
        durationList = weather.CalcStochastic(iterCount, ReportType.REVERSE,
                                              duration)

        # find the probability for the marked point
        itemCDF = [item for item in durationList if item[1] == duration]
        if len(itemCDF) > 0: durationCDF = itemCDF[0][0]

    template = loader.get_template('report/stochasticindex.html')
    context = {
        'durationList': durationList,
        'scheduleId': schedule_id,
        'startDate': weather.schedule.StartDate,
        'duration': duration,
        'durationCDF': durationCDF,
        'reportType': reportType,
        'demoMode': demoMode
    }

    return HttpResponse(template.render(context, request))
Example #2
0
 def testReverseStochastic(self):
     weather = Weather(2)
     weather.schedule.StatusTypeId = 1
     durationList = weather.CalcStochastic(100,
                                           reportType=ReportType.REVERSE)
     averageDays = sum(days for probability, days in durationList) / 100
     assert 470.0 <= averageDays <= 490.0
Example #3
0
 def testStochastic(self):
     weather = Weather(2)
     weather.schedule.StatusTypeId = 1
     durationList = weather.CalcStochastic(
         100, reportType=ReportType.WEATHER_AWARE)
     averageDays = sum(days for probability, days in durationList) / 100
     assert 550.0 <= averageDays <= 570.0
Example #4
0
 def testDaysOfYear(self):
     weather = Weather(2)
     weather.schedule.StatusTypeId = 1
     durationList, endDateList = weather.CalcDaysOfYear()
     averageDuration = sum(durationList) / 365
     assert len(durationList) == 365
     assert int(averageDuration) == 570
Example #5
0
 def testStochasticStatusDate(self):
     weather = Weather(2)
     weather.schedule.StatusDate = datetime.date(2017, 4, 1)
     weather.schedule.StatusTypeId = 2
     durationList = weather.CalcStochastic(
         100, reportType=ReportType.WEATHER_AWARE)
     averageDays = sum(days for probability, days in durationList) / 100
     assert 510.0 <= averageDays <= 530.0
Example #6
0
def daysindex(request, schedule_id):
    weather = Weather(schedule_id)
    weather.schedule.StatusTypeId = 1
    durationList, endDateList = weather.CalcDaysOfYear()

    template = loader.get_template('report/daysindex.html')
    context = {
        'durationList': durationList,
        'endDateList': endDateList,
        'scheduleId': schedule_id
    }
    return HttpResponse(template.render(context, request))
Example #7
0
def CalcReverseReport(scheduleId):
    """"This is to mark a point on the reverse report that shows where the weather aware
    duration appears"""
    # Get the weather aware durations and set these durations for the reverse report
    weather = Weather(scheduleId)
    weather.schedule.StatusTypeId = 1

    result = weather.CalcScheduleDuration(calcType=ReportType.WEATHER_AWARE)

    for idx, activity in enumerate(weather.activityList):
        weather.activityList[idx].Duration = result[0][idx].NewDuration

    # Get the planned durations from the weather aware durations
    result = weather.CalcScheduleDuration(calcType=ReportType.REVERSE)

    return result
Example #8
0
    def testGanttReverse(self):
        weather = Weather(2)
        weather.schedule.StatusTypeId = 1

        # get the end date with no weather aware extensions
        result = weather.CalcScheduleDuration(calcType=ReportType.NORMAL)
        originalEndDate = result[0][-1].EndDate

        # now go forwards and then backwards
        result = weather.CalcScheduleDuration(
            calcType=ReportType.WEATHER_AWARE)

        for idx, activity in enumerate(weather.activityList):
            weather.activityList[idx].Duration = result[0][idx].NewDuration

        result = weather.CalcScheduleDuration(calcType=ReportType.REVERSE)
        reversedEndDate = result[0][-1].EndDate

        self.assertEqual(originalEndDate, reversedEndDate)
Example #9
0
def index(request, schedule_id):
    fromSchedules = request.GET.get('fromschedules', False)
    reportType = int(request.GET["reporttype"])
    weather = Weather(schedule_id)
    statusDate = GetStatusDate(schedule_id)
    originalLabel = "Planned dur"
    newLabel = "Actual dur"

    if reportType == 2:
        activities, duration, _ = weather.CalcScheduleDuration(
            calcType=ReportType.WEATHER_AWARE)
        activities2, duration2, _ = weather.CalcScheduleDuration(
            calcType=ReportType.NORMAL)

        for idx, _ in enumerate(activities):
            activities2[idx].NewDuration = activities[idx].NewDuration

    if reportType == 4:
        # Get the weather aware durations as we want to work backwards from these predictions
        activities, duration, _ = weather.CalcScheduleDuration(
            calcType=ReportType.WEATHER_AWARE)

        for activity in activities:
            activity.Duration, activity.NewDuration = activity.NewDuration, activity.Duration

        for activity in weather.activityList:
            activity.Duration = activity.NewDuration

        # Get the planned activity durations from the weather aware durations
        activities2, duration2, _ = weather.CalcScheduleDuration(
            calcType=ReportType.REVERSE)

        originalLabel, newLabel = newLabel, originalLabel

    context = {
        'activities': activities,
        'activities2': activities2,
        'dependencies': weather.dependencyList,
        'scheduleId': schedule_id,
        'duration': duration,
        'duration2': duration2,
        'reportType': reportType,
        'originalLabel': originalLabel,
        'newLabel': newLabel,
        'fromSchedules': fromSchedules,
        'statusDate': statusDate
    }

    template = loader.get_template('report/index.html')
    return HttpResponse(template.render(context, request))
Example #10
0
 def testPlus1(self):
     self.assertEqual(
         Weather.GetAdjustedDate(datetime.date(2018, 1, 8),
                                 self._standardWorkingDays, 1),
         datetime.date(2018, 1, 9))
Example #11
0
 def testGanttWeatherStatusdate(self):
     weather = Weather(2)
     weather.schedule.StatusDate = datetime.date(2017, 4, 1)
     weather.schedule.StatusTypeId = 2
     result = weather.CalcScheduleDuration()
     self.assertEqual(result[0][-1].EndDate, datetime.date(2018, 12, 31))
Example #12
0
 def testMinus10WeatherEffected(self):
     self.assertEqual(
         Weather.GetAdjustedDate(datetime.date(2018, 1, 17),
                                 self._standardWorkingDays,
                                 -10, self._parameter),
         datetime.date(2018, 1, 1))
Example #13
0
 def testMinus1WeekendAllowed(self):
     self.assertEqual(
         Weather.GetAdjustedDate(datetime.date(2018, 1, 8),
                                 [1, 1, 1, 1, 1, 1, 1], -1),
         datetime.date(2018, 1, 7))
Example #14
0
 def testMinus1Weekend(self):
     self.assertEqual(
         Weather.GetAdjustedDate(datetime.date(2018, 1, 8),
                                 self._standardWorkingDays, -1),
         datetime.date(2018, 1, 5))
Example #15
0
 def testGanttWeather(self):
     weather = Weather(2)
     weather.schedule.StatusTypeId = 1
     activities = weather.CalcScheduleDuration()[0]
     self.assertEqual(activities[-1].EndDate, datetime.date(2019, 3, 14))
Example #16
0
 def testPlus1WeekendAllowed(self):
     self.assertEqual(
         Weather.GetAdjustedDate(datetime.date(2018, 1, 5),
                                 [1, 1, 1, 1, 1, 1, 1], 1),
         datetime.date(2018, 1, 6))