Esempio n. 1
0
        public static int GetNumberOfFreeSpots()
        {
            List <FreeWharfSpace> lista = FreeWharfSpace.ListOfFreeWharfPlacesInHarbour();
            var f1 = lista
                     .Select(f => f.LenghtOfFreePlaces)
                     .Sum();

            return(f1);
        }
Esempio n. 2
0
        public virtual bool IsTherePLaceForBoatInHarbour()
        {
            List <FreeWharfSpace> list = FreeWharfSpace.ListOfFreeWharfPlacesInHarbour();
            var l1 = list
                     .Where(l => l.LenghtOfFreePlaces >= NumberOfWharfPlacesNeededAtHarbour)
                     .ToList();

            return(l1.Count() > 0);
        }
Esempio n. 3
0
        public virtual int CheckForBestPlaceInHarbour()
        {
            List <FreeWharfSpace> list = FreeWharfSpace.ListOfFreeWharfPlacesInHarbour();

            var q1 = list
                     .Where(q => q.LenghtOfFreePlaces >= NumberOfWharfPlacesNeededAtHarbour)
                     .OrderBy(q => (q.LenghtOfFreePlaces > NumberOfWharfPlacesNeededAtHarbour + 4 ? NumberOfWharfPlacesNeededAtHarbour + 5 : q.LenghtOfFreePlaces) + AsCloseSameDaysLeftInHarbour(q))
                     .Select(q => StartOrEndPosition(q))
                     .ToList();

            return(q1[0]);
        }
Esempio n. 4
0
        public override bool IsTherePLaceForBoatInHarbour()
        {
            int halfPlaceSpot = FreeWharfSpace.WhereIsHalfPlace();

            if (halfPlaceSpot > 0)
            {
                return(true);
            }
            else
            {
                List <FreeWharfSpace> list = FreeWharfSpace.ListOfFreeWharfPlacesInHarbour();
                var l1 = list
                         .Where(l => l.LenghtOfFreePlaces >= NumberOfWharfPlacesNeededAtHarbour)
                         .ToList();

                return(l1.Count() > 0);
            }
        }
Esempio n. 5
0
        public int StartOrEndPosition(FreeWharfSpace freeSpot)
        {
            double value = freeSpot.DaysLeftForBoatBeforeSpace / (double)DaysLeftToStayInHarbour;

            if (value < 1)
            {
                value = 2 - value;
            }
            double value2 = freeSpot.DaysLeftForBoatAfterSpace / (double)DaysLeftToStayInHarbour;

            if (value2 < 1)
            {
                value2 = 2 - value2;
            }
            if (value <= value2)
            {
                return(freeSpot.StartPosition);
            }
            return(freeSpot.StartPosition + freeSpot.LenghtOfFreePlaces - NumberOfWharfPlacesNeededAtHarbour);
        }
Esempio n. 6
0
        public override int CheckForBestPlaceInHarbour()
        {
            int halfPlaceSpot = FreeWharfSpace.WhereIsHalfPlace();

            if (halfPlaceSpot > 0)
            {
                return(halfPlaceSpot);
            }
            else
            {
                List <FreeWharfSpace> list = FreeWharfSpace.ListOfFreeWharfPlacesInHarbour();

                var q1 = list
                         .Where(q => q.LenghtOfFreePlaces >= NumberOfWharfPlacesNeededAtHarbour)
                         .OrderBy(q => (q.LenghtOfFreePlaces > NumberOfWharfPlacesNeededAtHarbour + 4 ? NumberOfWharfPlacesNeededAtHarbour + 5 : q.LenghtOfFreePlaces) + AsCloseSameDaysLeftInHarbour(q))
                         .Select(q => StartOrEndPosition(q))
                         .ToList();
                return(q1[0]);
            }
        }
Esempio n. 7
0
        public double AsCloseSameDaysLeftInHarbour(FreeWharfSpace freeSpot)
        {
            double value = freeSpot.DaysLeftForBoatBeforeSpace / (double)DaysLeftToStayInHarbour;

            if (value < 1)
            {
                value = 2 - value;
            }
            double value2 = freeSpot.DaysLeftForBoatAfterSpace / (double)DaysLeftToStayInHarbour;

            if (value2 < 1)
            {
                value2 = 2 - value2;
            }
            if (value == 1 && value2 == 1)
            {
                return(0.9);
            }
            else if (value <= value2)
            {
                return(value);
            }
            return(value2);
        }
        public static List <string> StringInfo()
        {
            List <string> info = new List <String>();

            info.Add($"DAG {Counter.DaysSinceStartOfSimulation}. Idag kom det {Counter.NumberOfNewBoatsPerUdate} nya båtar till hamnen.\n");
            info.Add($"I hamnen ligger nu:\n- Roddbåtar \t{Counter.GetNumberOfBoatType("R")} st\n- Motorbåtar \t{Counter.GetNumberOfBoatType("M")} st\n- Segelbåtar \t{Counter.GetNumberOfBoatType("S")} st\n- Katamaraner \t{Counter.GetNumberOfBoatType("K")} st\n- Lastfartyg \t{Counter.GetNumberOfBoatType("L")} st\n");
            info.Add($"Summan av alla båtars vikt: {Counter.TotalWeight()} kg.\n");
            info.Add($"Medelhastighet för alla båtar: {Counter.AverageKmPerHour()} km/h.\n");
            info.Add($"Antal hela lediga platser: {Counter.GetNumberOfFreeSpots()} st\nAntal lediga halvplatser (för roddbåt): {(FreeWharfSpace.WhereIsHalfPlace() > 0 ? "1" : "0")} st.\n");
            info.Add($"Antal avvisade båtar för dagen: {Counter.NumberOfDeclinedBoatsEachDay} st\n");
            info.Add($"Antal avvisade båtar sedan simuleringens start: {Counter.NumberOfDeclinedBoatsSinceStartOfSimulation} st\nAvvisade båtar i genomsnitt per år: {Counter.DeclinedBoatsPerYear()} st/år.\n");
            if (Counter.NumberOfDeclinedBoatsEachDay > 0)
            {
                string s = "Avvisade båtar: ";
                foreach (var boat in HarbourAdministration.DeclinedBoats)
                {
                    s += $"{boat.IdentityNumber} ";
                }
                info.Add(s);
            }
            return(info);
        }