RESOURCE SCHEDULING ALGORITHM FOR MAINTENANCE …

44
RESOURCE SCHEDULING ALGORITHM FOR MAINTENANCE PLANNING RESOURCE SCHEDULING ALGORITHM FOR MAINTENANCE PLANNING INTERIM PROJECT REPORT SUBMITTED IN PARTIAL FULFILLMENT FOR THE REQUIREMENTS OF THE MODULE BPJ420 KIRSTEN YOUNG 14062471 University of Pretoria SEPTEMBER 4, 2017

Transcript of RESOURCE SCHEDULING ALGORITHM FOR MAINTENANCE …

Page 1: RESOURCE SCHEDULING ALGORITHM FOR MAINTENANCE …

RESOURCESCHEDULINGALGORITHM

FORMAINTENANCEPLANNING

RESOURCESCHEDULINGALGORITHMFORMAINTENANCEPLANNING

INTERIMPROJECTREPORTSUBMITTEDINPARTIALFULFILLMENTFORTHEREQUIREMENTSOFTHEMODULE

BPJ420

KIRSTENYOUNG14062471

UniversityofPretoria

SEPTEMBER4,2017

Page 2: RESOURCE SCHEDULING ALGORITHM FOR MAINTENANCE …

RESOURCESCHEDULINGALGORITHM

FORMAINTENANCEPLANNING

i

ANTIPLAGIARISMPAGEI,KirstenYoung,studentnumber14062471herebydeclarethatthisreportismyownoriginalwork,

and that the references listedprovides a comprehensive list of all sources citedor quoted in this

report.

Page 3: RESOURCE SCHEDULING ALGORITHM FOR MAINTENANCE …

RESOURCESCHEDULINGALGORITHM

FORMAINTENANCEPLANNING

ii

EXECUTIVESUMMARY“CompanyXYZ” isacompanywhichoutsourcesmaintenance tovariousenterprisesalloverSouth

Africa. Technicians are hired to travel to their customers which are geographically far from one

anothertoperformmaintenanceonelectricaldevicessuchasservers,computersandairconditioners.

Anemployee’sworkdayconsistsofboththeirtraveltimeandworkingtimeandsoroutingmustbe

carefully considered in order to reduce travel costs. Company XYZ’s employees find that their

workloadsareunbalancedi.e.somedaystheywillworkmuchlongerhoursthanothers.Thishasled

toCompanyXYZrequiringawaytoefficientlyscheduletheiremployeessothatcustomersdemand

can bemet,while keeping costs low, resource utilization high andworkloads balanced. Fourier-E

attempted solving Company XYZ’s problem by creating a linear programming resource allocation

model.Themodelworkedbutthereisstillmuchroomforimprovement.Allthedatawastherefore

alreadyavailableinadevicedatabasewhichcouldbeusedinthedevelopmentofanewsolution.

Afterperformingaliteraturestudyitwasfoundthattheproblemathandhasmanysimilaraspectsto

that of aMultiple Travelling Salesman Problem and so themanymethods of solving this kind of

problemwere researched. The genetic algorithmwas selected as themost suitable algorithm for

solving theproblembecauseof its short running timeand thestudent’sability tocode it.Specific

selection,crossoverandmutationtechniqueswereusedtoevolvetheinitialpopulationofsolutions.

Witheverynewgeneration,abetterschedulewasfound.Thebestsolutionofthefinalgeneration

wasselectedasthescheduletoanalyse.

Thegeneticalgorithmexhibitedmanyadvantagesoverusingtheexistinglinearprogrammingmethod.

Thechosenschedulesignificantlyreducedovertime,reducedtraveldistancesandbalancedresource

workloads.Itisuptothecompanytodecidewhethertheyshouldimplementitornot.CompanyXYZ

shouldvalidatethefinalschedulebyusingatestingteamtoensurethattheassumptionsonwhich

themodelwasbasedareacceptable.

Page 4: RESOURCE SCHEDULING ALGORITHM FOR MAINTENANCE …

RESOURCESCHEDULINGALGORITHM

FORMAINTENANCEPLANNING

iii

TABLEOFCONTENTSANTIPLAGIARISMPAGE...................................................................................................................I

EXECUTIVESUMMARY....................................................................................................................II

LISTOFFIGURES............................................................................................................................IV

LISTOFTABLES..............................................................................................................................IV

1. INTRODUCTIONANDBACKGROUND.......................................................................................11.1. THESERVICEINDUSTRY................................................................................................................11.2. COMPANYXYZ...........................................................................................................................11.3. PROBLEMBACKGROUND..............................................................................................................11.4. FOURIER-E.................................................................................................................................3

2. PROBLEMSTATEMENT............................................................................................................3

3. PROJECTAIM/RATIONALE......................................................................................................4

4. PROJECTAPPROACH,SCOPEANDDELIVERABLES....................................................................5PROJECTSCOPE......................................................................................................................................6

5. LITERATUREREVIEW...............................................................................................................75.1 EXACTMETHODS.........................................................................................................................8

5.1.1 MathematicalProgramming..........................................................................................85.1.2 DynamicProgramming...................................................................................................8

5.2 HEURISTICMETHODS..................................................................................................................95.2.1 LocalSearch-Hill-Climbing............................................................................................95.2.2 LocalSearch–Hill-ClimbingwithRandomRestart.......................................................105.2.3 LocalSearch-SimulatedAnnealing..............................................................................105.2.4 LocalSearch-TabuSearch...........................................................................................105.2.5 GeneticAlgorithm.........................................................................................................10

5.3 CONCLUSION............................................................................................................................14

6. PROBLEMINVESTIGATION....................................................................................................15

7. SOLUTIONDEVELOPMENT....................................................................................................187.1 INPUT.....................................................................................................................................187.2 PROCESS.................................................................................................................................207.3 OUTPUT..................................................................................................................................24

8. SOLUTIONANDSOLUTIONVALIDATION...............................................................................26

9. PROPOSEDIMPLEMENTATION..............................................................................................29

10. CONCLUSION.....................................................................................................................31

11. BIBLIOGRAPHY..................................................................................................................32

12. APPENDICES........................................................................................................................AAPPENDIXA:SIGNEDSPONSORSHIPFORM................................................................................................AAPPENDIXB:COMPLETEPYTHONCODING..................................................................................................B

Page 5: RESOURCE SCHEDULING ALGORITHM FOR MAINTENANCE …

RESOURCESCHEDULINGALGORITHM

FORMAINTENANCEPLANNING

iv

LISTOFFIGURESFigure1:AnillustrationofthehighlevelprocessCompanyXYZusestosatisfytheircustomers.........2

Figure2:Demonstrationofunevenworkloaddistribution...................................................................2

Figure3:CurrentsituationatCompanyXYZversuswhatamaintenanceplanwillhelpachieve..........4

Figure4:MapshowingthelocationsofCompanyXYZ'scustomersintheGautengregion..................6

Figure5:Representationofaroutingproblem.....................................................................................7

Figure6:Demonstrationofalocalmaximumbeingreachedratherthantheglobalmaximum...........9

Figure7:Demonstrationsofcommoncrossoveroperators................................................................12

Figure8:Demonstrationoforder1crossover.....................................................................................13

Figure9:AnexampleofanemployeejobsheetcreatedbyFourier'smodel......................................15

Figure10:Chartshowingcostofscheduleover80weeks..................................................................16

Figure11:Chartscomparinggeneratedschedulesof2employees....................................................16

Figure12:Thebasicconceptualmodelprocesswhichwillbefollowed..............................................18

Figure13:Previewofimportantaspectsofdatabase.........................................................................18

Figure14:Databasewhichgroupsdevicescommontoaspecificlocation.........................................19

Figure15:GeneticAlgorithmmethodology.........................................................................................20

Figure16:Representationofanindividualsolution............................................................................20

Figure17:Flowchartdemonstratingthelogicbehindthefitnessfunction........................................21

Figure18:Previewofasolutioninexcelformat..................................................................................25

Figure19:Graphsdepictingtheimprovementofsolutionswitheverynewgeneration....................26

Figure20:Comparisonofworkingdaysofinitialandfinalsolutionsforaparticularemployee.........27

LISTOFTABLESTable1:GeneticAlgorithmMethodology............................................................................................11

Table2:ComparisonofmethodsforsolvingTSP.................................................................................14

Table3:Comparisonofbestinitialsolutionandbestfinalsolutions..................................................27

Table4:Samplescheduleforanindividualemployee.........................................................................29

Table5:Samplescheduleforaspecificday.........................................................................................29

Page 6: RESOURCE SCHEDULING ALGORITHM FOR MAINTENANCE …

RESOURCESCHEDULINGALGORITHM

FORMAINTENANCEPLANNING

1

1. INTRODUCTIONANDBACKGROUND

1.1. THESERVICEINDUSTRY

Therehasbeenarapidgrowthintheserviceindustryoverthelastdecade.Thisisduetothefactthat

companies are recognizing the benefits of outsourcing activities that are not part on their core

functions (Linton, 2012). Outsourcing services such as accounting, IT or maintenance allows a

company to concentrate on the activities thatwillmake themmoney. Companies that provide a

serviceworkinverydifferentwaytomanufacturingcompaniesaspeoplearetheessenceandcoreof

thebusiness (Dorne,2008).Employeesworking inservicesareusuallynotconfinedtoaparticular

facility; rather they travel to provide their services across geographical areas. Unlike the

manufacturing industry, services cannot build up an inventory during times where there is less

demand–itneedstobemetasitisrequired.Thisplacesagreatimportanceonservicemanagement

aswellasthelogisticsofhavingtherightstaffmembersattherightplaceandattherighttimein

ordertosatisfycustomerdemand.

1.2. COMPANYXYZ

Thecompanyforwhichthisprojectwillbeundertakenwouldliketoremainconfidentialandsofor

the purposes of this project, it will be referred to as ‘Company XYZ.’ Company XYZ is a national

maintenance company to which numerous enterprises all over South Africa outsource their

maintenance.

Employeesarehiredtotraveltocustomerstoperformscheduledmaintenanceonawiderangeof

electricaldevicessuchasairconditioners,computers,telecoms,serversetc.Scheduledmaintenance

involvesplanningtomaintaindevicesormachinesatregular,predeterminedintervals.Thisincludes

activitiessuchasinspections,adjustments,regularservicesandplannedshutdowns(O'Brien,2017)in

ordertopreventmachinesfrombreakingdown.

1.3. PROBLEMBACKGROUND

AscanbeseeninFigure1,employees(resources){R1;R2;…;RN}travelfromtheirbranches{B1;B2;

…;BN}tocustomers’premises{PR1;PR2;…;PRN}wheretheelectricaldevices{ED1;ED2;…;EDN}on

whichtheyarerequiredtoworkarekept.Eachelectricaldevicehasitsownservicetime.Inasingle

dayemployeesmayberequiredtotraveltomultiplelocationstoperformservices.Aworkdayofan

employeewillthusconsistoftheirtraveltimeplusthetimetheyspendworkingonelectricaldevices.

Page 7: RESOURCE SCHEDULING ALGORITHM FOR MAINTENANCE …

RESOURCESCHEDULINGALGORITHM

FORMAINTENANCEPLANNING

2

FIGURE1:ANILLUSTRATIONOFTHEHIGHLEVELPROCESSCOMPANYXYZUSESTOSATISFYTHEIRCUSTOMERS

Customer’spremisesaregeographicallyfarfromanotherandthereforeroutesneedtobecarefully

consideredso thatemployeescanmaximize their timespentworkingand reduce travel costsand

overtime.Afull-timeemployeeshouldideallywork40hoursperweek(8hoursperday),butthisis

rarelythecase.Inoneweekanemployeemaywork50hoursandwillhavetobepaidovertime.Inthe

nextweekhemayonlywork30hours,butwillstillhavetobepaidforafull40hours’worthofwork

becausehewasavailable.ThetotalworkloadortheresourceutilisationofCompanyXYZistherefore

unevenlydistributed,asdemonstratedinthefigurebelow:

FIGURE2:DEMONSTRATIONOFUNEVENWORKLOADDISTRIBUTION

Page 8: RESOURCE SCHEDULING ALGORITHM FOR MAINTENANCE …

RESOURCESCHEDULINGALGORITHM

FORMAINTENANCEPLANNING

3

1.4. FOURIER-E

Fourier-E(partofFourierApproach) isan IndustrialEngineeringconsultingcompanyspecialising in

theareasofDecisionSupport,CashManagement,OperationalDesignandSupplyChainEngineering.

CompanyXZYhasbeenaclientofFourier’sformanyyears.In2009FourierwashiredtohelpCompany

XYZintheallocatingofmaintenancetasksinordertosmoothoutresourceutilisation,andthenonce

againin2012tobuildapilotmodelforoneregioninwhichtheyoperatedwhichminimisedtravelin

addition to allocating maintenance tasks to smooth resource utilisation. In 2016 this model was

executedacrossallmaintenancetasksandresourcesoverallregions inSouthAfrica.Fourier-Ewill

thereforebeveryusefulinprovidingdataforthisproject.

2. PROBLEMSTATEMENTCompanyXYZhasthelogisticalproblemofdecidingwhichjobsneedtodone,whentheyneedtobe

done,atwhichcustomerpremisesandbywhichemployees.CompanyXYZrequiresasystemwhich

plansstaffinginsuchawayastobalancetheworkloadsoftheiremployees,reducecostsandmeet

customerdemand.

Page 9: RESOURCE SCHEDULING ALGORITHM FOR MAINTENANCE …

RESOURCESCHEDULINGALGORITHM

FORMAINTENANCEPLANNING

4

3. PROJECTAIM/RATIONALEThe aim of this project is to create amaintenance plan for Company XYZ which indicates which

resourceswillbeservicingwhichdevicesonwhichdays.AsseeninFigure3below,thisplanshould

optimizetheworkloaddistributionofemployeesaswellastheroutestheytraveleachdaysothat

customerscanbeservicedinthemostefficientwaypossible.Thiswill leadtotheimprovementof

customersatisfactionandthereductionofworkforcecosts(Dorne,2008)suchasovertimeandidle

time,aswellasfuelandvehiclemaintenancecosts.

CurrentSituation IdealSituation

Movingtowards

Employeesareworkingadifferent

numberofhourseachdayandsome

employeesareworkingmorehoursthan

others.

Employeesarescheduledinsuchaway

thattheirdaysaremoreorless8hours

andeachemployeehasroughlythesame

amountofworktodo.

Movingtowards

Currentroutesarecomplexandnot

muchthoughthasgoneintothem.

Employeesfindthemselvesgoingback

pastplacestheyhavealreadyvisited.

Routeshavebeenoptimizedtoreduce

traveltimeperdayandthustravelcosts

sothatemployeeshavemoretimeto

performtheirvalueaddingjobs.

FIGURE3:CURRENTSITUATIONATCOMPANYXYZVERSUSWHATAMAINTENANCEPLANWILLHELPACHIEVE

0

8

16

Hours

Days0

8

16

Hours

Days

Page 10: RESOURCE SCHEDULING ALGORITHM FOR MAINTENANCE …

RESOURCESCHEDULINGALGORITHM

FORMAINTENANCEPLANNING

5

4. PROJECTAPPROACH,SCOPEANDDELIVERABLESThissectionprovidesthegeneralapproachthatwillbetakeninthesolvingofCompanyXYZ’sproblem.

The problem that needs to be addressed and the solution that will presented is typical of an

OperationsResearchbasedproject. T.ATaha (1976)definesOperationsResearchas “…ascientific

knowledgethroughinterdisciplinaryteameffortforthepurposeofdeterminingthebestutilizationof

limitedresources,”whichiswhatthisprojectultimatelyaimstodo.AccordingtoWinston(2003)the

following seven-step model-building procedure should therefore be followed as an approach to

solvingthisOperationsResearchbasedproblem:

• Projectproposal• Literature

review

• Probleminvestigation• Existingmodelanalysis

• Conceptualmodel• Actualmodel

Phase1:FormulatetheProblemThisphasewillinvolvespeakingtotheemployeesfromFourier-EwhichwereinvolvedintheResource

AllocationProjectsandhavingthemexplainthebackgroundoftheproblem.Individualresearchwill

be conducted to gain enough information about the project so that a project proposal can be

completed.Anin-depthliteraturestudy(Section5)willthenbeundertakentoidentifywhatkindof

problemisbeingdealtwithaswellaswhatmethodsareavailabletosolveit.

Phase2:ObservetheSystemAsmentionedinSection1,Fourier-EhasperformedseveralprojectsatCompanyXYZandthushave

builtupalargedatabaseofinformationpertainingtotheoperationsofthecompany.Thisdatabase

willbeusedasthestartingpointforunderstandinghowthecompanyworksandhowallthedifferent

aspectsofthecompanyfittogetheri.e.regions,bases,customerpremises,resources,equipmentetc.

Amorein-depthdiscussionoftheproblemwillthenbepresented.Aspartoftheprobleminvestigation

(Section6),Fourier’sexistingmodelwillbeanalysedandthestrengthsandshortcomingsofitwillbe

discussed.

Phase3:FormulateaMathematicalModeloftheProblemA conceptualmodelwill bedesigned to showwhich inputs andoutputswill be required, and the

generalwayinwhichthemodelshouldworkwillbeexplained.Thefinalmodelwillthenbedeveloped

using knowledge and background gained from literature studies and Fourier’s model. The

developmentofthefinalmodelcanbefoundinSection7.

Modelformulation Systemobservation Problemformulation 11

22

3

Page 11: RESOURCE SCHEDULING ALGORITHM FOR MAINTENANCE …

RESOURCESCHEDULINGALGORITHM

FORMAINTENANCEPLANNING

6

• Verificationandvalidation

• Alternativescomparison

• Report• Presentation• Poster

• Implementationprocedure

• Recommendations

Phase4:VerifyandValidatetheModelTheactionsthatCompanyXYZshouldtakeinordertoverifyandvalidatethecompletedmodelwillbe

explained(Section8).

Phase5:SelectaSuitableAlternativeDifferent types of scheduling algorithms and linear programmingmethodswill be researched and

comparedwithoneotherinordertodetermineifanyaresuitablefortheapplicationatCompanyXYZ

or if something completely newneeds to be formulated. These comparisons can be found in the

literaturereview(Section5).

Phase6:PresentResultsandConclusionA final report, poster, and PowerPoint presentationwill be created to present the final proposed

maintenanceplanaswellashowitwasdeveloped.

Phase7:ImplementandEvaluateRecommendationsThe final report will include recommendations on how Company XYZ should go about the

implementationphaseiftheyweretoaccepttheproposedmaintenanceplan(Section9).

PROJECTSCOPE

Thereisalargeamountofdataavailabletouse.Thereare6regionsinSouthAfricainwhichCompany

XYZ operates and so it would be a

goodideatomodelonlytheGauteng

region initially. If the finalalgorithm

works effectively, it can then be

easily adapted to solve for other

regions in the future. The Gauteng

region has only one branch, which

employs36full-timetechnicians.The

companieswhichthisbranchservices

areshowninthemapalongside.

FIGURE4:MAPSHOWINGTHELOCATIONSOFCOMPANYXYZ'SCUSTOMERSINTHEGAUTENGREGION

Implementation&Recommendations

Results&Conclusion

Alternatives selection

Verification&Validation 6 5 4 7

Page 12: RESOURCE SCHEDULING ALGORITHM FOR MAINTENANCE …

RESOURCESCHEDULINGALGORITHM

FORMAINTENANCEPLANNING

7

5. LITERATUREREVIEWInthissectionaliteraturereviewisconductedtofindandunderstandtheorythatcouldbeappliedto

the problem at hand aswell as specific applications of this theory aboutwhich researchers have

writtenpapers.Thereareanumberofmethodsdiscussedbelow.Onemethodoracombinationof

thesedifferentmethodswillbeselectedtosolveCompanyXYZ’sproblem,basedontheirsuitability

totheproblemandthestudent’sabilities.

Theproblemathandhaselementsofbothschedulingandroutingbecausetasksandtechniciansneed

tobescheduled insuchawayastocompleteall thetasksrequestedbycustomers, inadditionto

determining efficient routeswhichminimise the costs associatedwith travelling to geographically

distributedcustomers.

Routingandschedulingproblemscanbepresentedasgraphicalnetworks(Hakseveretal.,2000).In

Figure5below,thecirclesarecallednodeswhichrepresentpickupand/ordeliverypoints.Node1

representsthedepotorhomebaseofthevehicles.The linesconnectingthenodesarecalledarcs

whichcanrepresentthetime,distanceorcostrequiredtotravelfromonenodetoanother.Thegoal

ofroutingandschedulingproblemsisusuallytominimizethistime,distanceorcostoftravelling.

FIGURE5:REPRESENTATIONOFAROUTINGPROBLEM

Numeroustypesofroutingandschedulingproblemsarementionedinliterature,eachhavingavariety

ofwaysinwhichtheycanbesolved.Theclassificationofaroutingandschedulingproblemdepends

oncharacteristicssuchassizeofthedeliveryfleet,wherethefleetishoused,capacitiesofthevehicles,

aswellasroutingandschedulingobjectives(Hakseveretal.,2000).

Page 13: RESOURCE SCHEDULING ALGORITHM FOR MAINTENANCE …

RESOURCESCHEDULINGALGORITHM

FORMAINTENANCEPLANNING

8

In the simplest andmostwell-known case of routing problems, theTravelling SalesmanProblem

(TSP),asinglevehicleisrequiredtovisitasetofnodes.Theoutputisaroutewhichbeginsandends

at thedepotwhichenables thevehicle tovisiteachnodeexactlyoncewhileminimizing travelling

distance. In the case of theMultiple Travelling Salesmen Problem (mTSP), a fleet of vehicles is

required tovisit a setofnodesandeachvehicle starts andendsat thedepot. Theobjective is to

determinearouteforeachsalesmansuchthatthetotaldistanceisminimizedandthateachcityis

visited exactly once by only one salesman. The Vehicle Routing Problem (VRP) expands on the

multiple traveling salesmanproblem. In this case thecapacityof thevehicles is restrictedand the

nodestobevisitedhavevaryingdemands.IntheChinesePostmanProblem(CPP),thedemandfor

service occurs on the arcs rather that at the nodes, for example street sweeping and newspaper

delivery.

Fromthedescriptionsofthecasesabove,itappearsthattheMultipleTravellingSalesmanProblem

mostcloselyresemblestheproblemwithwhichCompanyXYZ is faced,becausetherearemultiple

techniciansbutthecapacitiesoftheirvehiclesarenotlimitedandthedemandfortheirserviceoccurs

onlyatthenodes.ApproachesforsolvingthemTSPabovecanbedividedintotwocategories:exact

algorithmsandheuristicalgorithms.

5.1 EXACTMETHODS

Thefollowingtraditionaltechniqueshavebeenusedtofindexactsolutionsforsmallproblemsbutas

thesizeofthesolutionspaceincreases,sodoestherunningtimeofthesealgorithms(Laporte,1992).

5.1.1 MATHEMATICALPROGRAMMING

Thereexistsawidevarietyofmathematicalprogrammingmethods,themostbasiconebeingLinear

programming(LP).This istheoptimisationofaprobleminwhichtheobjectiveandconstraintsare

linear. In integerprogramming (IP), variablesare restricted tobe integers.Whensomebutnotall

variablesarerestrictedtobeintegers,itisamixedintegerprogram(MIP)(Pinedo,2012).Inbinary

integerprogramming(BIP),eachvariablecanonlytakeonthevalueof0or1.Variousalgorithmsexist

tosolvetheTSPandvariationsofit.SomeincludetheBranch-and-pricealgorithmandtheBranch-

and-boundalgorithm.

5.1.2 DYNAMICPROGRAMMING

Dynamic Programming is very different to linear programming in that there is no standard

mathematicalformulationoftheproblem.Itis“amethodthatingeneralsolvesoptimizationproblems

thatinvolvemakingasequenceofdecisionsbydetermining,foreachdecision,subproblemsthatcan

Page 14: RESOURCE SCHEDULING ALGORITHM FOR MAINTENANCE …

RESOURCESCHEDULINGALGORITHM

FORMAINTENANCEPLANNING

9

be solved in like fashion, such thatanoptimal solutionof theoriginal problemcanbe found from

optimalsolutionsofsubproblems"(LewandMauch,2007).Dynamicprogramminghasoftenbeen

usedinthesolvingofTravellingSalesmanProblems(Laporte,1992)usingtheHeld-Karpalgorithm.

5.2 HEURISTICMETHODS

Whenthenumberofvariablesgetstoolarge,computershavedifficultyinfindinganexactsolution.

In thecaseof theTSPorvariantsof it, thedifficulties in solving thisproblemarise fromthe large

numberofpossibletours:thefactorialofthenumberofcitiestobevisited(Larranagaetal.,1999).In

thiscase,heuristicsmethodsshouldbeusedtofindgood, ifnotoptimal,solutionstotheproblem

(Winston, 2003). Reeves (1993) defines a heuristic as: “a technique which seeks good (i.e. near-

optimal)solutionsatareasonablecomputationcostwithoutbeingabletoguaranteeeitherfeasibility

oroptimality,oreveninmanycasestostatehowclosetooptimalityaparticularfeasiblesolutionis.”

Severalcommonheuristicapproachesarepresentedbelow:

5.2.1 LOCALSEARCH-HILL-CLIMBING

Hill-climbinginvolvesstartingatarandompointinthesearchspaceandthenlookingattheclosest

neighbour/candidatesolutions.Ifthevalueofaneighboursolutionisbettersolutionthanthecurrent

solution,thenitbecomesthecurrentnode.Iftheneighbourisnotabettersolution,thecurrentnode

remainsthesame.Theprocessloopsoverandoveruntilnobettersolutioncanbefoundi.e.alocal

maximum has been reached. It is possible to have more than one local optimum. In Figure 6,

dependingonthestartingposition,alocalmaximummaybereachedandthealgorithmwouldget

stuck,butitmaynotbetheglobalmaximumi.e.thebestsolution.Thisisoneofthemajordrawbacks

ofthehill-climbingalgorithm.

FIGURE6:DEMONSTRATIONOFALOCALMAXIMUMBEINGREACHEDRATHERTHANTHEGLOBALMAXIMUM.

Page 15: RESOURCE SCHEDULING ALGORITHM FOR MAINTENANCE …

RESOURCESCHEDULINGALGORITHM

FORMAINTENANCEPLANNING

10

5.2.2 LOCALSEARCH–HILL-CLIMBINGWITHRANDOMRESTART

Thisalgorithmfixestheproblemsassociatedwithhill-climbing.Thehill-climbingalgorithmisrununtil

alocalmaximumisfound.Itwillthenberunagainstartingfromadifferentrandompositioninthe

searchspace,whichpossiblyenablesanewlocalmaximumtobefound.Thisprocessisrepeatedand

eventuallythebestoptimumthatwasfoundwillbereturned.

5.2.3 LOCALSEARCH-SIMULATEDANNEALING

Thisalgorithmisbasedonthesameideaashill-climbingwithrestartbutitisdifferentinthesense

thattheneighbourchosenisnotalwaysanimprovementtothecurrentsolutioni.e.thealgorithm

maymove downhill. This is because it looks further than just the neighbour solution – it takes a

randomwalkinthesearchspacetoseeiftherearebettersolutionsbeyondlocalmaximumsinthe

hopes of discovering the global maximum i.e. searches getting stuck in at local maximums are

prevented.Simulatedannealingwasinspiredbymetallurgy’sannealingtechnique-amethodusedto

reducedefectsinametalbyusingheatingandcontrolledcoolingdownofthematerial.Thissearch

process is dependent on the variable ‘t’ or ‘temperature’. The algorithm begins with a high

temperature,and slowly coolsdown toa low temperature.Thehigher the t, themore the search

ignoreslocalmaximumswhilethelowerthet,themorethisalgorithmbehaveslikethenormalhill

climbingalgorithm.

5.2.4 LOCALSEARCH-TABUSEARCH

Unlike the above local search algorithms, Tabu searchmakes use ofmemorywhich enables it to

overcomelocalmaximums.ThisheuristiciscommonlyusedinthesolvingofmTSPs,TSPsandVRPs

(Uldall,TaarnhøjandVorts,2008).

5.2.5 GENETICALGORITHM

Geneticalgorithmswereinspiredbyprocessesobservedinbiologicalevolutionandnaturalselection.

In thisalgorithm,a solution toaproblemcanbeviewedasan individual andagroupof solutions

becomesapopulation.Somesortofobjectivefunction,calledthefitnessfunction,isusedtocompare

variousindividualsinapopulation.Inaniterativeprocess,newgenerationsareformedfromthebest

performing individuals in the previous generation as well as their offspring, while keeping the

populationsizeconstant.Newgenerationsarecreatedthroughselection,crossoverandmutationof

individualsfromthepreviouspopulation.

Page 16: RESOURCE SCHEDULING ALGORITHM FOR MAINTENANCE …

RESOURCESCHEDULINGALGORITHM

FORMAINTENANCEPLANNING

11

Potvin(1996)definesthestepstoasimple“pure”geneticalgorithmasfollows:

TABLE1:GENETICALGORITHMMETHODOLOGY

Step1.CreateaninitialpopulationofPchromosomes(generation0).

Step2.Evaluatethefitnessofeachchromosome.

Step3.SelectPparentsfromthecurrentpopulationviaproportionalselection

Step4.Chooseat randomapairofparents formating.Exchangebit stringswith theone-point

crossovertocreatetwooffspring.

Step5.Processeachoffspringbythemutationoperator,andinserttheresultingoffspringinthe

newpopulation.

Step6.Repeatsteps4and5untilallparentsareselectedandmated(Poffspringarecreated).

Step7.Replacetheoldpopulationofchromosomesbythenewone.

Step8.Evaluatethefitnessofeachchromosomeinthenewpopulation.

Step9.Gobacktostep3ifthenumberofgenerationsislessthansomeupperbound.Otherwise,

thefinalresultisthebestchromosomecreatedduringthesearch.

Someoftheconceptsmentionedabovearedescribedasfollows:

Fitness: In order to evaluate how effective a solution is, and to compare effectiveness between

solutions, a fitness function is required. In the case of a TSP, the shorter a solution’s total travel

distance,themoreeffectivethatsolutionis,andsothefitnessofthesolutionwouldbeafunctionof

thetotaldistancetravelled.

Selection:Theselectionprocessofageneticalgorithmdetermineswhichindividualsshouldmateand

produceoffspring for thenext generation. The aimof selection is to choose individualswithhigh

fitnessvaluesandtodiscardthepoorperformingones.However,thesebadindividualsshouldalso

haveachancetobeselectedbecausetheymayleadtousefulgeneticmaterial(RazaliandGeraghty,

2011).Variousselectionmethodsexist:

• Proportionalroulettewheelselectionselectsindividualsinproportiontotheirfitness,sothe

higheranindividual’sfitnessvalue,themorelikelyisitistobeselected(Luke,2013).

• Inrankbasedroulettewheelselection,solutionsareorderedaccordingtotheirfitnessvalues

andselectionprobabilitiesarecalculatedforeachsolutionbasedontheirranksrelativetothe

population rather than on their fitness value. This selection method is therefore not

influenced by extremely high performing individuals, like the proportional roulette wheel

selectionis.

Page 17: RESOURCE SCHEDULING ALGORITHM FOR MAINTENANCE …

RESOURCESCHEDULINGALGORITHM

FORMAINTENANCEPLANNING

12

• Tournament selection is the most popular method due to its efficiency and simple

implementation (Razali and Geraghty, 2011). k individuals are randomly chosen from the

populationandtheindividualwiththebestfitnessvaluewins.Thelargerthevalueofk,the

greater chance for loss of diversity in new generations (Blickle and Thiele, 1995). This is

because poor performing individuals are unlikely towin large tournaments and therefore

don’tgetachancetobeselectedformating.Smallervaluesofkgivemostindividualsachance

to be selected and thus preserve genetic diversity. In a study performed by Razali and

Geraghty(2011),itwasfoundthattournamentselectiongavebetterresultsthanproportional

roulettewheelforallsizesofproblemsthatweretested.Itwasalsoeasiertoimplementthan

therankbasedroulettewheelselectionmethod.

Crossover:CrossoveristheGeneticAlgorithm’sdistinguishingfeature(Luke,2013).Thebestfeatures

oftheparentschosenfromtheselectionsteparecombinedtocreateoffspring.Therearethreewell-

knowncrossovermethods,whichareillustratedinFigure7.

• One-pointcrossover:arandomnumberischosenbetween0andthelengthofthesolution

whichisthecutpoint.Thechildwillcontainthevaluesupuntilthecutpointfromparent1,

andthevaluesafterthecutpointinparent2.

• Two-pointcrossover:Thismethodbreaksupthesolutionat2points,creatingasectionwhich

isswappedwiththesectioncreatedfromtheotherparent.

• Uniformcrossover:Thismethodselectsrandompositionsinboththeparentstoswaptheir

genes.

FIGURE7:DEMONSTRATIONSOFCOMMONCROSSOVEROPERATORS

Page 18: RESOURCE SCHEDULING ALGORITHM FOR MAINTENANCE …

RESOURCESCHEDULINGALGORITHM

FORMAINTENANCEPLANNING

13

WhenapplyingthepuregeneticalgorithmtoaTSP,aproblemisencounteredwhenusinganyofthe

aforementionedcrossovermethods.Afterapplyingacrossover,somecitiesmayappearmorethan

onceintheoffspringcreated,makingtheminfeasiblesolutionsi.e.thechildisnotapermutationof

itsparents.Potvin(1996)describesthe‘order1crossover’method(asillustratedinFigure8)which

overcomesthisissue.Theaimofthistechniqueistopreservetheorderingofthelocationsfromboth

parentsanditworksinthefollowingway:

1. Selectarandompartofthechromosomefromparent1byrandomlychoosing2cutpoints

2. Dropthispartdowntochild1andmarkouttheselocationsfromparent2

3. Add the remaining values fromparent2 to the child in theorder inwhich theyappear in

parent2,startingafterthesecondcutpoint

4. Ifasecondchildisrequired,swapparent1andparent2andgobacktostep1.

FIGURE8:DEMONSTRATIONOFORDER1CROSSOVER

Mutation:Inordertomaintaingeneticdiversitythroughgenerations,amutationofsomeindividuals

shouldoccurwithasmallprobability.Mutationpreventsthealgorithmfromgettingstuckatalocal

optima(Larranagaetal.,1999).Examplesofmutationmethodsinclude:

• Swapping:2locationsinthechromosomearerandomlyselectedandthenswapped.

• Scrambling:Twocutpointsarerandomlyselected,andthelocationswithinthetwocutpoints

arerandomlypermuted

Elitism:Thisconceptisoftenusedingeneticalgorithmstoensurethatthebestperformingindividuals

(theelites)appearinfuturegenerations.Howeverthistechniquemaycauseprematureconvergence

ifnotkeptincheck(Luke,2013).

AccordingtoPinedo(2012),usinggeneticalgorithmsisadvantageousbecausetheyareeasilycoded

andgivegoodsolutions,buttheircomputationtimecanbelongerthanotherheuristicapproaches.

Page 19: RESOURCE SCHEDULING ALGORITHM FOR MAINTENANCE …

RESOURCESCHEDULINGALGORITHM

FORMAINTENANCEPLANNING

14

5.3 CONCLUSIONThe problemwithwhich Company XYZ is faced can be classified as a type of Travelling Salesman

Problem. A variety of exact and heuristic methods exist to solve these problems, which are

summarisedandcomparedbelow:

TABLE2:COMPARISONOFMETHODSFORSOLVINGTSP

Method Advantages Disadvantages

Mathematicalprogramming

ManyformulationsofTSPhavebeenfound

AlmostimpossibletofindoptimalsolutionforlargeproblemsLongrunningtime

Dynamicprogramming

ExistingHeld-Karpmethodfoundinliterature

LongrunningtimeDifficulttodevelopcodeHighmemoryusage

Hill-climbing Verysimplealgorithm Highchanceofgettingstuckatlocaloptima

Hill-climbingwithrandomrestart

Localoptimacanbeavoided Ifrandomrestartpointsareclose,samelocaloptimumwillcontinuallybereached

Simulatedannealing

EasilycodedLocaloptimacanbeavoided

Canbeslow,especiallyifcostfunctionisexpensivetocomputeSimpler,fastermethodsexistCannottellifsolutionisoptimal

Tabusearch Localoptimacanbeavoided OnlyworksindiscretespacesRequiresalotofmemoryCannottellifsolutionisoptimal

Geneticalgorithm EasilycodedKnowntohaveproducedgoodsolutionsLocaloptimacanbeavoidedAlotofliteraturefound

LongerrunningtimesthanotherheuristicapproachesCannottellifsolutionisoptimal

Becauseitissuchalargeproblem,heuristicsappearstobethebestwayoffindingavalidsolution.

GeneticAlgorithmisaneffectivemethodwhichhascommonlybeenusedtosolveTSPs.Thegenetic

algorithmtechniquesfoundcanbeadaptedforthespecificuseofthesolvingCompanyXYZproblem.

Page 20: RESOURCE SCHEDULING ALGORITHM FOR MAINTENANCE …

RESOURCESCHEDULINGALGORITHM

FORMAINTENANCEPLANNING

15

6. PROBLEMINVESTIGATIONBefore Fourier-E’s intervention, Company XYZ had no specialized programming or algorithmic

methodstouseintheschedulingoftheiremployees.Eachdayamanually-createdjobsheetwasgiven

toanemployeewhowouldthenhavetovisitandserviceeachoftheservicerequestsinthatday.If

anotherjobcameup,itwouldsimplybeaddedontopofthepile.Thismeantthatnothoughtwent

intotheroutingortheorderinwhichjobsshouldbedoneandsotherewasalotoftravellingback

and forth. This lead to employees working overtime which became costly for Company XYZ. As

mentionedinthebackgroundoftheproblem,resourceutilisationwasalsounbalanced.Someweeks,

anemployeewouldworkmuchlongerhoursthaninotherweeks.Theseissuesleadtotheneedfor

consulting Fourier-E to performa resourceplanningproject. From2009, Fourier-E hasworkedon

buildingmodelstoimprovemaintenancetaskallocation,smoothoutresourceallocationandminimise

traveltimesforCompanyXYZ.Theirfinallinear-programmingmodelwasusedtoscheduleemployees

overan80-weekperiod forall the regions inwhichCompanyXYZworked. Its logicworked in the

followingway:

1. Aresourceisselected

2. Aparticularweekisselected

3. Thesitewiththemostequipmentisselectedtobeservicedfirstinthisweek

4. Thereafter,theclosestsitewiththemostequipmentisselected

5. Thetimeavailableischeckedtoseeiftheresourcecanperformtheservice

6. Theequipmenttobeservicedisselected,orderedbypriority,andtimeavailable

7. Themaintenanceplanofthecurrentequipmentisupdated

Theoutputofthemodelisanemployeejobsheetwhichincludedthefollowinginformation:

• Resourcenumber

• Weeknumber

• List of equipment

tobeserviced

• Totaltraveltime

• Totaltasktime

• Totaltime

FIGURE9:ANEXAMPLEOFANEMPLOYEEJOBSHEETCREATEDBYFOURIER'SMODEL

Page 21: RESOURCE SCHEDULING ALGORITHM FOR MAINTENANCE …

RESOURCESCHEDULINGALGORITHM

FORMAINTENANCEPLANNING

16

Agraphhasbeencreatedtoshowthecostsassociatedwiththeuseofthemodelledscheduleover

the80-weekperiod.Thischartillustratestheimbalanceofworkloadoverthe80weeks.Therearestill

periodswithhighutilisationofemployeesandperiodswherethereisverylittleutilisation.

FIGURE10:CHARTSHOWINGCOSTOFSCHEDULEOVER80WEEKS

Thechartsbelowcomparetheschedulesoftwoemployees.Theredlinerepresentstheemployees’

available time towork in aweek. The charts clearly show that employees are still not being fully

utilized, and their schedules have not balanced their workloads over the 80-week period. Also

Resource3755927hasamuchbusierschedulethanResource1212551,eventhoughhe/shehasless

timeavailabletowork.

FIGURE11:CHARTSCOMPARINGGENERATEDSCHEDULESOF2EMPLOYEES

0

20000

40000

60000

80000

100000

Weeks

AllResources

SumofTimeCost SumofReturnTravelTime SumofTotalTimeCost

0

200

400

600

800

1000

1200

1400

1600

1800

2000

Weeks

Resource1212551

0

200

400

600

800

1000

1200

1400

1600

1800

2000

Weeks

Resource3755927

Page 22: RESOURCE SCHEDULING ALGORITHM FOR MAINTENANCE …

RESOURCESCHEDULINGALGORITHM

FORMAINTENANCEPLANNING

17

ThemodelworksforCompanyXYZandtheyarecurrentlyusingittoautomatetheirscheduling

processbutthereisstillthereismuchroomforimprovement.Fourier’smodelcanthereforebe

usedasabaseonwhichtoimproveinordertosolvetheproblemsofCompanyXYZ.Thefollowing

considerationshavebeenmaderegardingthecurrentandpotentialmodel:

• Linear programmingwas used to create Fourier’smodel. Because of the large number of

variablesandconstraints,thismodeltookdaystosolve,whichmakesitimpracticaltouseon

adailyorweeklybasis.Literaturerevealsthatmetaheuristicsisausefultoolinsolvinglarge,

complexproblemsandsothisshouldbeimplementedinthenewmodel

• Fourier’smodelworkedintermsofweeks.Thisallowsforthefreedomofrefiningtheweekly

scheduleifemergenciesneedtobeaccommodated.However,dailyschedulingprovidesmore

accuratetraveltimesandsoitshouldbeincorporatedintothenewmodel

• Themodelcreatedastaticplanfor80weeks.Inthislongtimeframe,alotcanhappenand

changewhichmakesthislongtermplanimpractical.Ifchangesshouldoccur,oremergency

servicesneedtoscheduled,thenthemodelshouldbeabletoreorganiseexistingschedules.

• Therobustnessofthescheduleneedstobeconsidered.Isitbettertohavearoughplanwhich

guidesemployeesbuttheycanmakechangesiftheyneedto,ortohaveaverydetailedplan

whichanemployeehastostickto?

• Emergencybreakdownsorissuescanhappenatanypointintime,whichthemodelneedsto

take intoaccount. Is itbetter tohave forexample7resourceswith100%utilisationanda

separateteamtodealwithemergencies,ortohave10resourceswith75%utilisationsothat

theyareavailablewhenemergenciesoccur?

Allthesepointswillbeconsideredinthedevelopmentofthefinalmodel,whichispresentedinthe

followingsection.

Page 23: RESOURCE SCHEDULING ALGORITHM FOR MAINTENANCE …

RESOURCESCHEDULINGALGORITHM

FORMAINTENANCEPLANNING

18

7. SOLUTIONDEVELOPMENTThissectiondescribesthechosenalgorithmanditsdevelopmentindetail.

FIGURE12:THEBASICCONCEPTUALMODELPROCESSWHICHWILLBEFOLLOWED

7.1 INPUTTheDatabase

ThedevicedatabaseisanexcelspreadsheetcontaininginformationabouteachdevicethatCompany

XYZisrequiredtoservice.Thisdatabasewillbeconvertedintoacsvfiletobeusedasaninputtothe

algorithm. Important attributesof eachequipmentwhich thealgorithmwill use in its calculations

includethedevice’sidentificationnumber,servicetime(minutes),aswellasitslongitudeandlatitude.

Apreviewofthisdatabaseisshowninthefigurebelow:

FIGURE13:PREVIEWOFIMPORTANTASPECTSOFDATABASE

Thereare20379electricaldevicesinthedatabasethatneedtobeserviced.IntheTravellingSalesman

Problem,thenumberofpossibleroutesisafactorialofthenumberofcitiestovisit.Ifeachelectrical

deviceweretobetreatedasacity,therewouldbe20378!=8.02E+78968routestoconsider.

Manyofthedevicesare locatedinthesamebuildings,andsotosimplifytheproblemslightly,the

electricaldevicesinthedatabasewillbeorderedaccordingtotheircoordinates.Devicesinthesame

locationswillthenbegroupedtogether,andanewinputcsvfilewillbecreatedsuchastheonein

Figure14usingasimplePythonprogram.Thiswillensurethatwhencreatingrandomindividualsfor

Page 24: RESOURCE SCHEDULING ALGORITHM FOR MAINTENANCE …

RESOURCESCHEDULINGALGORITHM

FORMAINTENANCEPLANNING

19

the population, devices in the same location will not be separated, and the algorithm will then

optimizedistancesbetweenlocationsratherthandistancesbetweenthedevicesthemselves.

FIGURE14:DATABASEWHICHGROUPSDEVICESCOMMONTOASPECIFICLOCATION

Afterapplyingthegroupingprogramthereare7778locations,labelled1to7778,whichmeansthere

arenowonly7778!=3.74E+26887routestoconsider.

Assumptions

Thefollowingassumptionswillbeapplicableinthebuildingofthegeneticalgorithm:

• 36full-timetechniciansarecurrentlyemployedbyCompanyXYZ

• TechniciansworkMondaythroughFriday

• Techniciansshouldworkroughly8hoursperday

• Alltechnicianshavetherequiredskillstoserviceanyelectricaldevice

• Techniciansdriveatanaveragespeedof70kmperhour(vehiclesmakeuseofmainroads

wherepossible)

• Techniciandrivesbacktodepotaftertheirlastjobinaday

• Servicingofadevicehastobecompletedthedayitwasstarted

• Servicingofanydevicerequiresonlyonetechnician

• Straightlinedistancesareusedbetweentwolocations

Page 25: RESOURCE SCHEDULING ALGORITHM FOR MAINTENANCE …

RESOURCESCHEDULINGALGORITHM

FORMAINTENANCEPLANNING

20

7.2 PROCESSThegeneticalgorithmwillbebuiltinPython3.6usingthemethodologybelow,adaptedfromTable1

toapplytoaMultipleTravellingSalesmanProblem.EachstepoftheGeneticAlgorithmwillthenbe

described inmoredetail.Notethatthecompletepythoncodingforthealgorithmcanbefound in

AppendixB.

FIGURE15:GENETICALGORITHMMETHODOLOGY

1. Generateinitialpopulation

Firstly,thesolutiontotheproblem(chromosome)willberepresentedasalistoflocationIDs,inwhich

eachlocationrepresentsthedevicesitholds.Eachlocationislistedexactlyonce.Thissatisfiesthefirst

objectiveofthemodel:tosatisfyallcustomerdemand.i.e.serviceeachdeviceonce.

1 2 3 … 7776 7777 7778

FIGURE16:REPRESENTATIONOFANINDIVIDUALSOLUTION

Now,Algorithm1generatesapopulationbytakingthisinitialsolutionasaninputandcreating100

randompermutationsofit:

Page 26: RESOURCE SCHEDULING ALGORITHM FOR MAINTENANCE …

RESOURCESCHEDULINGALGORITHM

FORMAINTENANCEPLANNING

21

Algorithm 1: Population Input: Initial solution (ind) Output: Population consisting of s permutations of initial solution def population(ind, s): return [random.sample(ind, len(ind)) for i in range(s)]

2. Evaluatefitnessofeachindividualofthepopulation

Inordertocomparethesedifferentsolutionsanddeterminewhicharebetterthanothers,afitness

functionisrequired.Goingbacktotheproblemstatement,themainobjectivesofthemodelareto1)

reducetraveltimesand2)evenoutworkloaddistribution.Thefitnessfunctionthereforeneedstobe

comprisedoftwoelements:1)totaldistanceofthescheduleand2)thetotaldeviationfrom8hours

ofworkingtimeperresourceperday.Thisfitnessfunctionwilltakeanindividualsolutionasaninput,

and return that solution’s totaldistanceanddeviation.The flowdiagrambelowdemonstrates the

logicbehindthefitnessfunction:

FIGURE17:FLOWCHARTDEMONSTRATINGTHELOGICBEHINDTHEFITNESSFUNCTION

Page 27: RESOURCE SCHEDULING ALGORITHM FOR MAINTENANCE …

RESOURCESCHEDULINGALGORITHM

FORMAINTENANCEPLANNING

22

Firstly, the travel time to the first location listed in the solution from thedepot is calculated.The

followingalgorithmwillbeusedtocalculatethestraightlinedistancesbetween2locations,andthen

bemultipliedbythespeedofthevehicletofindthetraveltime:

Algorithm 2: Distance Input: Origin coordinates and destination coordinates Output: Straight line distance in km between 2 input locations def distance(origin, destination): lat1, lon1 = origin lat2, lon2 = destination radius = 6371 dlat = radians(lat2 - lat1) dlon = radians(lon2 - lon1) a = sin(dlat / 2) * sin(dlat / 2) + cos(radians(lat1)) * cos(radians(lat2)) * sin(dlon / 2) * sin(dlon / 2) c = 2 * atan2(sqrt(a), sqrt(1 - a)) d = radius * c return d

Ifthereisenoughtimeleftinthedayfortheresourcetodrivethereandperformtheservicing,then

theresourcewill traveltothat location.Thetraveltimeandservicingtimesarethenaddedtothe

totalworkinghours,andthetotaldistancefortheschedule isupdated.Whenthere isnotenough

timeleftinthedayforaresourcetodrivetoalocation,hewilldrivebacktothedepot,andthena

newresourcewillbeselectedtotraveltothatlocation.Onceall36resourcesareusedupinaday,a

newdaybeginswithresource1.

Notethatthe‘istheretimetotraveltolocationandservicedevices’decisionblockdoesnotcheckif

thereisalsotimetodrivebacktothedepotonceservicingiscomplete.Thismeansthatthedriveback

tothedepotmaycauseanemployee’sdaytorunover480minutes.Whenaresourcedrivesbackto

the depot, his total time, service time and travel time for that day are printed. This is when the

deviationofthescheduleiscalculated:

𝐷𝑒𝑣𝑖𝑎𝑡𝑖𝑜𝑛 = (,-./010230456)8

91:;0where‘count’isthetotalnumberofschedulescreated.

3. Copyelitestonewgeneration

Thisprocesswillbedescribedinstep7

Page 28: RESOURCE SCHEDULING ALGORITHM FOR MAINTENANCE …

RESOURCESCHEDULINGALGORITHM

FORMAINTENANCEPLANNING

23

4. Selectparentswithtournamentselection

Tournamentselectionwillbeusedasthemethodofselectingparentsforbreeding.Randomlyselect

kindividualsfromthepopulationandreturnthebestperformingindividualfromthisgroup.

Algorithm 3: Selection (Tournament selection) Input: Population (P) and tournament size (k) Output: Winning individual of the tournament def selection(P, k): best = null for i in range(1, k): ind = random individual in P if (best == null) or fitness(ind) > fitness(best): best = ind return best

5. Crossoverselectedparentstocreatechildren

Orderonecrossoverwasselectedasthemethodofperformingacrossovertopreventinvalidsolution

frombeingcreated.

Algorithm 4: Crossover (Order one) Input: Two individual parents, p1 and p2 Output: Child containing characteristics from both parents, with no location repetitions def crossover(p1, p2): r1 = random number between 0 and length of length of parents r2 = random number between 0 and length of length of parents child = list with length equal to length of p1 Copy elements between r1 and r2 from p1 to child, in same positions as p1 y = List holding elements of p1 which are not in child yet Order the elements in y according to their order in p2 Copy remaining elements into child according to their order in p2 starting after r2 return child

6. Mutatesomeindividualsinnewgeneration

Algorithm 5: Mutation (Swapping) Input: An individual (ind) Output: Individual with 2 locations swapped around def mutation(ind): x = random integer between 0 and length of individual y = random integer between 0 and length of individual ind[x], ind[y] = ind[y], ind[x] return ind

Page 29: RESOURCE SCHEDULING ALGORITHM FOR MAINTENANCE …

RESOURCESCHEDULINGALGORITHM

FORMAINTENANCEPLANNING

24

7. Newgeneration

An‘evolve’functioniscreatedbycombiningselection,crossoverandmutation.Theindividualsofthe

populationwill be sorted according to their fitness values. The top 20%of thepopulationwill be

copied to the next generation as they are [Step 3: Copy elites to new generation]. Next, random

individualswillbechosenfromthecurrentgenerationtoproduce2children.Theelitesmayalsobe

selectedforbreeding.Oncecrossoveroccurs,theremaybeachancethatthechildrenaremutated.

Thisprocesswillloopthroughuntilthenextgenerationislargeenough.

Algorithm 6: Evolution Input: Population (P) sorted in order of fitness, mutation probability (m), elitist percentage (r) Output: New population def evolve(P, m = 0.01, r = 0.2): retain_length = length of P * r parents = P[:retain_length] parents_length = length of parents desired_length = length of P - parents_length children = [] while length of children < desired_length: p1 = selection(p, 3) p2 = selection(p, 3) if p1 is not the same as p2: child1 = crossover(p1, p2) child2 = crossover(p2, p1) append child1 to parents append child2 to parents for i in parents: if m > randomly generated number between 0 and 1: mutate(i) sort individuals in parents according to fitness return parents

7.3 OUTPUT

Theevolutionfunctionwillberun100timestoproduce100generations.Thebestperformingsolution

of the 100th generation will be exported as a csv file and analysed. The solution indicates which

resourceswillbeperformingservicesonwhichdevices,onwhichday,howlongtheirdaywillbeand

whatproportionsof itwillbespenttravellingandactuallyperformingtheservice. Apreviewofa

solutioncanbeseeninthefollowingfigure:

Page 30: RESOURCE SCHEDULING ALGORITHM FOR MAINTENANCE …

RESOURCESCHEDULINGALGORITHM

FORMAINTENANCEPLANNING

25

FIGURE18:PREVIEWOFASOLUTIONINEXCELFORMAT

Theoutputwillalsoshowhowmanydayswillberequiredtocompleteservicingofallelectricaldevices

aswellastheschedule’stotaldistancetravelledandtotaldeviation.

Page 31: RESOURCE SCHEDULING ALGORITHM FOR MAINTENANCE …

RESOURCESCHEDULINGALGORITHM

FORMAINTENANCEPLANNING

26

8. SOLUTIONANDSOLUTIONVALIDATIONThissectionpresentsthefinalsolutionaswellashowCompanyXYZshouldgoabouttheprocessof

verifyingandvalidatingthefinalmodel.

Graphshavebeencreatedtoshowhowboththetotaldistanceandtotaldeviationofthesolutions

decreased with every new generation created. Both the best and worst fitness values of each

generationwereplotted,ascanbeseeninthegraphsbelow:

FIGURE19:GRAPHSDEPICTINGTHEIMPROVEMENTOFSOLUTIONSWITHEVERYNEWGENERATION

Toshowhowthegeneticalgorithmperformed,thebestsolutionofthefinalgenerationiscompared

with the best solution of the initial generation in Table 3 on the following page:

……………………………………………………..

316497.06

312328.59

308000

310000

312000

314000

316000

318000

320000

1 5 9 13 17 21 25 29 33 37 41 45 49 53 57 61 65 69 73 77 81 85 89 93 97

TotalD

istance(km)

Generation

TotalDistance

Best Worst

142.51

140.45

138139140141142143144145

1 5 9 13 17 21 25 29 33 37 41 45 49 53 57 61 65 69 73 77 81 85 89 93 97

StandardDeviatio

n

Generation

Deviation

Best Worst

Page 32: RESOURCE SCHEDULING ALGORITHM FOR MAINTENANCE …

RESOURCESCHEDULINGALGORITHM

FORMAINTENANCEPLANNING

27

TABLE3:COMPARISONOFBESTINITIALSOLUTIONANDBESTFINALSOLUTIONS

InitialSolution FinalSolution

Totalovertime 91.206hours 91.296hours

Totalidletime 13872.654hours 13669.592hours

Totaldistance 316843.8km 312328.59km

Totaldeviation 142.86minutes 140.45minutes

Daystocomplete 189days,36resources 189days,7resources

Overtimehoursincreasedonlyveryslightlybutidletimehasdecreasedby203hours.Thishasallowed

theservicingofallthedevicestotakeplacein189days,usingonly7resourcesonthe189thdayrather

thantheinitial36.Thegraphsbelowshowarandomlyselectedemployees’workinghoursoverthe

periodoftheschedules.Theaveragelengthofaworkingdayhasincreasedfromtheinitialsolutionto

thefinalsolutionwhichmeansthatthedaysforthisemployeearemorefulli.e.thereislessidletime.

FIGURE20:COMPARISONOFWORKINGDAYSOFINITIALANDFINALSOLUTIONSFORAPARTICULAREMPLOYEE

353.1

0

100

200

300

400

500

600

1 7 13 19 25 31 37 43 49 55 61 67 73 79 85 91 97 103

109

115

121

127

133

139

145

151

157

163

169

175

181

187

Lengthofw

orkingday(m

inutes)

Day

InitialSolution

359.7

0.0

100.0

200.0

300.0

400.0

500.0

600.0

1 7 13 19 25 31 37 43 49 55 61 67 73 79 85 91 97 103

109

115

121

127

133

139

145

151

157

163

169

175

181

187

Lengthofw

orkingday(m

inutes)

Day

FinalSolution

Page 33: RESOURCE SCHEDULING ALGORITHM FOR MAINTENANCE …

RESOURCESCHEDULINGALGORITHM

FORMAINTENANCEPLANNING

28

Therehasbeenareductioninthedeviationsfroman8-hourworkingday,butthereisstillvisiblyalot

of idletime.Thiscanbeusedtothecompany’sadvantage-anyemployeewithfreetimeontheir

schedulecanbeput“oncall”foranyemergenciesthatmayoccur.

HasthegeneticalgorithmaddressedCompanyXYZ’sissues?

Thewaythealgorithmisbuiltdoesnotallowaresourcetotraveltolocationiftherewon’tbeenough

timetoservicethedevices,andsobyusingthisalgorithm,CompanyXYZcanautomaticallycutdown

ontheirovertimecosts.

Thealgorithmproducesdailyschedulesforeachemployeeratherthanweekly.Thismeansthatthe

travellingtimesaremoreaccurateandthescheduleismorespecific.

Thegeneticalgorithmproducesasolutionwithinhourswhilethelinearprogrammingmethodthat

wasbeingused tookdays.Thismeans that thecompanycanuse thealgorithm formoredynamic

planningbecause it ismoreefficientandeasiertokeepupwithcontinuouschanges. Ifanydevice

servicespopupthatwerenotinitiallyplannedfor,thealgorithmcanbereruntoaccommodatethese

devicesinamoreoptimalway.CompanyXYZcanrunthemodelitatthebeginningofeachweekto

createschedules,insteadoffollowingastatic80-weekplan.

SolutionValidation

The schedules produced by the genetic algorithm should be validated before the company starts

implementingthem.Thecompanycanputtogetheratestingteamforaweekortwowhichfollowthe

scheduleasitis,andthenreportbackanyissuestheymayhavehad.Parameterssuchastravelling

speed,andtimeinthedaymayhavetobeadjustedifemployeesfindthattheycannotmanagewith

thegivenschedule.Abenefitofusingthisalgorithmisthat itonlyrequiresPythonwhichisafree,

opensourceprogrammingsoftwareaswellasapersonwithabackgroundofcoding.Thecodecanon

acontinuousbasisbeeasilybeadaptedandmodified.

Page 34: RESOURCE SCHEDULING ALGORITHM FOR MAINTENANCE …

RESOURCESCHEDULINGALGORITHM

FORMAINTENANCEPLANNING

29

9. PROPOSEDIMPLEMENTATIONThecsvoutputfilethatwasproducedbythealgorithmcanbeusedinanumberofways.Firstly,the

exceltablecanbefilteredtoshowthescheduleofeachemployee.Resource17forexample,hasthe

followingschedulefortwoweeks:

TABLE4:SAMPLESCHEDULEFORANINDIVIDUALEMPLOYEE

Day Devices TotalTime Traveltime Servicetime

75

11296,11297,11298,11299,11300,11301,11302,11303,11304,11305,11306,11307,11308,11309,11310,11311,11312,11313,11314,11315,11316,11317,11318,11319,11320,11321,11322,11323,11324

431.9 20.0 411.9

76 10954,10955,10956,10957 400.0 20.0 38077 6121 395.5 80.5 31578 3480,3481,3482,3483 412.7 32.7 38079 7514,7515,7516,7517 398.4 18.4 38080 3306 354.8 39.8 31581 19914,19915,19916,19917 405.7 25.7 38082 5329 348.7 53.7 29583 10564 315.0 20.0 29584 20183 273.9 63.9 210

Theexceltablecanalsobefilteredtoshoweachday.ManagersofCompanyXZYcanusethistosee

whichoftheiremployeeswillservicingwhichdevices.Thetablebelowisasampleforsomeofthe

employeesonday1.

TABLE5:SAMPLESCHEDULEFORASPECIFICDAY

Resource Devices Totaltime Traveltime Servicetime13 ['[12086,12087,12088,12089]'] 401.9 21.9 38014 ['[2428,2429]'] 424.1 64.1 36015 ['[4276]'] 268.7 58.7 21016 ['[16432,16433]'] 422.8 32.8 39017 ['[13703,13704,13705,13706]'] 400.7 19.7 38118 ['[3946,3947,3948,3949]'] 438.4 58.4 38019 ['[2424]','[17003]'] 391.7 69.2 322.520 ['[18285]'] 331.5 16.5 31521 ['[19976,19977]'] 410.6 22.6 388

Page 35: RESOURCE SCHEDULING ALGORITHM FOR MAINTENANCE …

RESOURCESCHEDULINGALGORITHM

FORMAINTENANCEPLANNING

30

AsmentionedinSection8,thealgorithmmustfirstbeputtothetesttoensurethatitisbenefitting

thecompanyandthat theschedule ithasproduced isverifiedandvalidated.Oncethescheduling

methodhasbeenimplementedattheGautengbranchandusedforaperiodoftime,usersofthis

systemcanstartmakingsuggestionsandimprovements,andgetridofbugs.Thereafter,afinalised

algorithmcanbeadoptedbyotherregionsinthecountry.

Page 36: RESOURCE SCHEDULING ALGORITHM FOR MAINTENANCE …

RESOURCESCHEDULINGALGORITHM

FORMAINTENANCEPLANNING

31

10. CONCLUSIONCompanyXYZ ishaving troublescheduling their staffanddeterminingwhichroutes its technicians

shouldbetaking inordertosatisfycustomerdemand,while incurringminimalcosts.Thisproblem

wasaddressedbyconductingaliteraturereviewtodeterminewhattypeofproblemwasathandand

whatmethodshavebeendevelopedtosolvesimilarproblems.Theproblemcanbeclassifiedasatype

ofTravellingSalesmanproblem.ItwasfoundthattheGeneticAlgorithmprovestobeaveryuseful

efficientmethodofsolvingtheseproblems.UsingPython3.6,ageneticalgorithmwasbuiltandrun

100 times tocreate100generations.Witheachnewgeneration,abetter scheduling solutionwas

foundi.e.scheduleswhichreducedtraveldistancesandbalancedtechnicianworkloads.

And so, going back to the problem statement, has the developed solution met its objectives?

“CompanyXYZrequiresasystemwhichplansstaffinginsuchawayastobalancetheworkloadsof

theiremployees,reducecostsandmeetcustomerdemand.”Ageneticalgorithmhasbeencreated[a

systemwhichplansstaffing]which iterativelyreducessolutions’deviationfroman8hours’dayof

work[balanceworkloads]andtotaltravellingdistance,therebysavingonpetrol,vehiclemaintenance

costsandovertime[reducecosts].Thealgorithmensuresthateveryelectricaldevicewillgetserviced

[meetcustomerdemand].

Beforeanyschedule is implementedCompanyXYZshouldgothroughavalidationphasetoensure

thatassumptionsmade inthemodelaresuitable.Usingthegeneticalgorithmtocreateschedules

couldbeadvantageousforCompanyXYZbecauseitreducesovertime,plansdaily,andfindssolutions

quickly.

Page 37: RESOURCE SCHEDULING ALGORITHM FOR MAINTENANCE …

RESOURCESCHEDULINGALGORITHM

FORMAINTENANCEPLANNING

32

11. BIBLIOGRAPHYBlickle, T. and Thiele, L. (1995) ‘A Comparison of Selection Schemes used in Genetic Algorithms’,

EvolutionaryComputation,2(11),pp.311–347.doi:10.1162/evco.1996.4.4.361.

Dorne,R.,2008.ServiceChainManagement:TechnologyInnovationfortheServiceBusiness.s.l.:s.n.

Haksever,C.etal.(2000)VehicleRoutingandScheduling,ServiceManagementandOperation.

Kokemuller, N., n.d. Advantages & Disadvantages of a Part-Time Employees. [Online]

Available at: http://smallbusiness.chron.com/advantages-disadvantages-parttime-employees-

21870.html

[Accessed25March2017].

Laporte, G. (1992) ‘The traveling salesman problem: An overview of exact and approximate

algorithms’, European Journal of Operational Research, 59(2), pp. 231–247. doi: 10.1016/0377-

2217(92)90138-Y.

Larranaga, P. et al. (1999) ‘Genetic Algorithms for the Travelling Salesman Problem: A Review of

Representations and Operators’, Artificial Intelligence Review, 13(2), pp. 129–170. doi:

10.1023/A:1006529012972.

Lew,A.andMauch,H. (2007) ‘1 Introduction toDynamicProgramming’,Studies inComputational

Intelligence,38,pp.3–43.Availableat:www.springerlink.com.

Linton,I.,2012.TakingTechnologytotheMarket:AGuidetotheCriticalSuccessFactorsinMarketing

Technology.s.l.:GowerPublishing.

Luke,S.(2013)EssentialsofMetaheuristics.2ndedn,Optimization.2ndedn.doi:10.1007/s10710-

O'Brien, J., 2017. What is scheduled maintenance critical percent?. [Online]

Available at: https://www.fiixsoftware.com/blog/scheduled-maintenance-critical-percent/

[Accessed26March2017].

Pinedo,M.L.(2012)Scheduling:Theory,Algorithms,andSystems.Fourth,Springer.Fourth.London.

doi:10.1007/s13398-014-0173-7.2.

Potvin, J.-Y. (1996) ‘Genetic Algorithms’, Annals of Operations Research, 63, pp. 339–370. doi:

10.1016/B978-0-12-804494-0.00010-3.

Page 38: RESOURCE SCHEDULING ALGORITHM FOR MAINTENANCE …

RESOURCESCHEDULINGALGORITHM

FORMAINTENANCEPLANNING

33

Razali,M.andGeraghty,J.(2011)‘Geneticalgorithmperformancewithdifferentselectionstrategies

in solving TSP’, World Congr. Eng., II(978-988-19251-4–5), pp. 4–9. Available at:

http://umpir.ump.edu.my/2609/.

Reeves, C. R., 1993.ModernHeuristics Techniques for Combinatorial Problems. London: Blackwell

ScientificiPublicaitons.

Uldall,C.P.,Taarnhøj,E.S.andVorts,S.(2008)TechnicianRoutingandScheduling.Denmark.Available

at:http://orbit.dtu.dk/getResource?recordId=211562&amp;objectId=1&amp;versionId=1.

Winston,W.(2003)‘IntroductiontoLinearProgramming’,inOperationsResearch:Applicationsand

Algorithms.4thedn,pp.49–125.

Page 39: RESOURCE SCHEDULING ALGORITHM FOR MAINTENANCE …

RESOURCESCHEDULINGALGORITHM

FORMAINTENANCEPLANNING

A

12. APPENDICES

APPENDIXA:SIGNEDSPONSORSHIPFORM

Page 40: RESOURCE SCHEDULING ALGORITHM FOR MAINTENANCE …

RESOURCESCHEDULINGALGORITHM

FORMAINTENANCEPLANNING

B

APPENDIXB:COMPLETEPYTHONCODINGimport math import csv import random import null daylength = 8 * 60 employed = 36 depot = -26.117920, 28.135320 speed = 70 / 60 with open("/Users/kirstenyoung/Google Drive/University/4th Year/BPJ/Data/CSVs/GroupedData.csv") as csvfile: ImportEquip = list(csv.reader(csvfile, delimiter=';')) eqtdetails = {} initialsolution = [] # Initial Solution def initialise(): counter = 0 for e in ImportEquip: counter += 1 initialsolution.append(counter) eqtdetails[counter] = e return initialsolution def devices(location): return eqtdetails[location][1] # Calculate distance between 2 equipment locations def d(origin, destination): lat1, lon1 = origin lat2, lon2 = destination radius = 6371 dlat = math.radians(lat2 - lat1) dlon = math.radians(lon2 - lon1) a = math.sin(dlat / 2) * math.sin(dlat / 2) + math.cos(math.radians(lat1)) * math.cos( math.radians(lat2)) * math.sin(dlon / 2) * math.sin( dlon / 2) c = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a)) d = radius * c return d # Return the coordinates of a device def coords(device): return float(eqtdetails[device][3]), float(eqtdetails[device][4]) # Return the service time of a device def serv(device): return float(eqtdetails[device][2]) # Rotate elements ina list def rotate(lst, x): lst[:] = lst[x + 1:] + lst[:x + 1] return lst

Page 41: RESOURCE SCHEDULING ALGORITHM FOR MAINTENANCE …

RESOURCESCHEDULINGALGORITHM

FORMAINTENANCEPLANNING

C

# Calculate the total distance of the schedule def fitness(solution): resource = 1 day = 1 timeleft = daylength totaltime = 0 distance = 0 depot = -26.117920, 28.135320 fromcoords = depot deviation = 0 count = 0 for i in solution: tocoords = coords(i) travel = d(fromcoords, tocoords) / speed service = serv(i) if (travel + service) > timeleft: travel = d(fromcoords, depot) distance += travel totaltime += travel / speed deviation += (daylength - totaltime) ** 2 count += 1 totaltime = 0 timeleft = daylength fromcoords = depot resource += 1 travel = d(fromcoords, tocoords) / speed if resource > employed: totaltime = 0 timeleft = daylength fromcoords = depot resource = 1 day += 1 travel = d(fromcoords, tocoords) / speed if (travel + service) <= timeleft and resource <= employed: totaltime += travel + service timeleft -= travel + service distance += travel * speed fromcoords = tocoords deviation += (daylength - totaltime) ** 2 standarddeviation = (deviation / (count + 1)) ** (0.5) return round(distance, 2), round(standarddeviation, 2) # Create a population of individuals def population(solution, size): return [random.sample(solution, len(solution)) for i in range(size)] # Calculate average fitness of a population def grade(pop): dis = 0 dev = 0 for i in pop: dis += fitness(i)[0] dev += fitness(i)[1] return round(dis / len(pop), 2), round(dev / len(pop), 2)

Page 42: RESOURCE SCHEDULING ALGORITHM FOR MAINTENANCE …

RESOURCESCHEDULINGALGORITHM

FORMAINTENANCEPLANNING

D

# Tournament selection def selection(pop, k): best = null for i in range(1, k): ind = pop[random.randint(1, len(pop) - 1)] if (best == null) or ind[0] < best[0]: best = ind return best # Crossover def crossover(parent1, parent2): l = len(parent1) # Get 2 random numbers between 0 and length of individual r1 = random.randint(0, l - 1) r2 = random.randint(0, l - 1) while r1 >= r2: r1 = random.randint(0, l - 1) r2 = random.randint(0, l - 1) # Create the child... initial elements are -1 child = [-1] * l # Copy elements between r1, r2 from parent1 to child for i in range(r1, r2 + 1): child[i] = parent1[i] # Create list to hold elements of parent1 which are not in child yet y = [0] * (l - (r2 - r1) - 1) j = 0 for i in range(0, l): if parent1[i] not in child: y[j] = parent1[i] j += 1 # Order of places is the same as the number of elements after r2 copy = parent2[:] rotate(copy, r2) # Order the elements in y according to their order in parent2 y1 = [0] * (l - (r2 - r1) - 1) j = 0 for i in range(0, l): if copy[i] in y: y1[j] = copy[i] j += 1 # Copy remaining elements into child according to their order in parent2 starting after r2 for i in range(0, len(y1)): ci = (r2 + i + 1) % l child[ci] = y1[i] return child # Mutate def swap(solution): x = random.randint(0, len(solution) - 1) y = random.randint(0, len(solution) - 1) solution[x], solution[y] = solution[y], solution[x] return solution

Page 43: RESOURCE SCHEDULING ALGORITHM FOR MAINTENANCE …

RESOURCESCHEDULINGALGORITHM

FORMAINTENANCEPLANNING

E

# Evolve the population def evolve(graded, mutate=0.01, retain=0.2): p = [x[1] for x in graded] retain_length = int(len(p) * retain) parents = p[:retain_length] parents_length = len(parents) desired_length = len(p) - parents_length children = [] while len(children) < desired_length: p1 = selection(p, 3) p2 = selection(p, 3) if p1 != p2: child1 = crossover(p1, p2) child2 = crossover(p2, p1) children.append(child1) children.append(child2) parents.extend(children) for i in parents: if mutate > random.random(): parents.remove(i) parents.append(swap(i)) graded = [((fitness(x)), x) for x in parents] graded = [x for x in sorted(graded)] fitnesses = [x[0] for x in graded] print(fitnesses[0],fitnesses[99]) return graded def output(solution): resource = 1 day = 1 schedule = [] timeleft = daylength totaltime = 0 traveltime = 0 servicetime = 0 FromCoords = depot for i in solution: ToCoords = coords(i) travel = d(FromCoords, ToCoords) / speed service = serv(i) if (travel + service) > timeleft: traveltime += d(FromCoords, depot) / speed totaltime += d(FromCoords, depot) / speed z = [] for j in schedule: z.append(devices(j)) print(str(day) + ";" + str(resource) + ";" + str(z) + ";" + str(totaltime) + ";" + str(traveltime) + ";" + str(servicetime))

Page 44: RESOURCE SCHEDULING ALGORITHM FOR MAINTENANCE …

RESOURCESCHEDULINGALGORITHM

FORMAINTENANCEPLANNING

F

totaltime = 0 traveltime = 0 servicetime = 0 timeleft = daylength schedule = [] FromCoords = depot resource += 1 travel = d(FromCoords, ToCoords) / speed if resource > employed: totaltime = 0 traveltime = 0 servicetime = 0 timeleft = daylength schedule = [] FromCoords = depot resource = 1 day += 1 travel = d(FromCoords, ToCoords) / speed if (travel + service) <= timeleft and resource <= employed: totaltime += travel + service timeleft -= travel + service traveltime += travel servicetime += service schedule.append(i) FromCoords = ToCoords z = [] for i in schedule: z.append(devices(i)) print(str(day) + ";" + str(resource) + ";" + str(z) + ";" + str(totaltime) + ";" + str(traveltime) + ";" + str(servicetime))

initial = initialise() p = population(initial, 100) pop = [((fitness(x)), x) for x in p] pop = [x for x in sorted(pop)] for i in range(100): pop = evolve(pop) print(output(pop[0][1]))