<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Phurit Warapattanapong on Medium]]></title>
        <description><![CDATA[Stories by Phurit Warapattanapong on Medium]]></description>
        <link>https://medium.com/@phuritwarapat?source=rss-a58ec54a38a1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*cIk8qe-X2KOFZLZ0_ASemQ@2x.jpeg</url>
            <title>Stories by Phurit Warapattanapong on Medium</title>
            <link>https://medium.com/@phuritwarapat?source=rss-a58ec54a38a1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 19:20:32 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@phuritwarapat/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Vehicle Routing Problem and Ant Colony Optimization to schedule a simple trip]]></title>
            <link>https://medium.com/@phuritwarapat/vehicle-routing-problem-and-ant-colony-optimization-to-schedule-a-simple-trip-d6cfba15399d?source=rss-a58ec54a38a1------2</link>
            <guid isPermaLink="false">https://medium.com/p/d6cfba15399d</guid>
            <category><![CDATA[optimization-techniques]]></category>
            <category><![CDATA[vehicle-routing-problem]]></category>
            <category><![CDATA[itinerary-planner]]></category>
            <category><![CDATA[ant-colony-optimization]]></category>
            <category><![CDATA[algorithms]]></category>
            <dc:creator><![CDATA[Phurit Warapattanapong]]></dc:creator>
            <pubDate>Sat, 08 Apr 2023 21:49:01 GMT</pubDate>
            <atom:updated>2024-08-17T03:27:58.375Z</atom:updated>
            <content:encoded><![CDATA[<p>Assuming we already have the list of places to go on a trip, we can create an optimization module to schedule the trip based on a simple condition using the concept of Vehicle Routing Problem (VRP).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ygRtg0sgZ4dJF5MPcTNJpQ.jpeg" /><figcaption>Photo by <a href="https://www.pexels.com/@vlada-karpovich/">Vlada Karpovich</a> from <a href="https://www.pexels.com/photo/woman-looking-at-a-map-with-a-pen-in-her-hand-7368300/">Pexels</a></figcaption></figure><h4>Vehicle Routing Problem</h4><p>The <a href="https://en.wikipedia.org/wiki/Vehicle_routing_problem">Vehicle Routing Problem</a> (VRP)is is the problem of finding an optimal path for visiting and serving every customer with a given set of vehicles and customers&#39; locations. Finding the optimal solution to a vehicle routing problem is <a href="https://en.wikipedia.org/wiki/NP-hardness">NP-hard</a>, meaning that it is impossible to get to a final answer, so we normally search for an optimal answer instead. The vehicle routing problems can be solved by using some graph strategies to generate an initial solution and then using local search for finding the optimal solution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*vldJpLpw3JqML5pX4MNzUQ.png" /><figcaption>Icon created by <a href="https://www.flaticon.com/authors/doraclub">doraclub </a>from <a href="https://www.flaticon.com/free-icon/warehouse_6756101?term=depot&amp;page=1&amp;position=3&amp;origin=tag&amp;related_id=6756101">Flaticon</a></figcaption></figure><p>Since finding the optimal solution for a vehicle routing problem is NP-hard, there are two main methods for solving the problem, exact solution methods and metaheuristics. In this article, we apply Ant Colony Optimization, which is a metaheuristics method, to solve the VRP.</p><h4>Vehicle Routing Problem with Time Windows Constraint</h4><p>There are plenty of vehicle routing problem variants which are vehicle routing problems with an additional constraint. The vehicle routing problem with time windows (VRPTW) is a variant of the VRP in which each customer is only available during specific time windows.</p><p>Since some places have opening and closing times that allow the customer to visit within that range of time, we can adapt the time windows constraint to deal with those opening and closing times of each place.</p><h4>Trip Scheduling as a Vehicle Routing Problem</h4><p>In the VRP, we have one depot, a set of customers’ locations to be visited, and a number of vehicles. However, in trip scheduling, a set of places to be visited is similar to a set of customers’ locations, accommodation as the depot, and the number of trip days as the number of vehicles. Since each vehicle in the VRP is required to depart from the depot and get back to the depot after serving all the customers in its responsible path, it is similar to the trip scheduling that we have to depart from an accommodation at the beginning of a trip day and return to the accommodation at the end of a trip day.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/392/1*KYJ4LPMw5RGfSK8ycVrxLw.png" /></figure><p>To simplify the problem, we specify the <em>day_start_time </em>and <em>day_end_time </em>specifying the time to start and end a day in the trip. Thus, each day trip must start after <em>day_start_time </em>and return to the hotel before <em>day_end_time</em>. Moreover, each place has its own specific duration to be spent before departing to the next place in the plan.</p><h4>Ant Colony Optimization</h4><p>Ant colony optimization (ACO) is an optimization algorithm that simulated ants’ foraging behavior by studying how they find the shortest path between their nest and food source, without any central coordination mechanism.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*3Fy4vHj8AWp1ptWbejISCg.png" /><figcaption><a href="https://www.flaticon.com/free-icon/sweets_3081949?term=dessert&amp;page=1&amp;position=3&amp;origin=search&amp;related_id=3081949">Sweets</a> icon and <a href="https://www.flaticon.com/free-icon/anthill_4993359?term=ant&amp;page=1&amp;position=28&amp;origin=search&amp;related_id=4993359">anthill</a> icon by <a href="https://www.flaticon.com/authors/freepik">Freepik</a> and <a href="https://www.flaticon.com/authors/iconixar">iconixar</a> from Flaticon</figcaption></figure><p>Generally, ants have an initial random activity pattern in the search for a food source. When the food source is located, the activity patterns become more organized, which means other ants will follow the same path, the shortest path. The autocatalytic behavior is when forager ants lay pheromones along followed trails. Paths with a larger pheromone concentration are more attractive to other ants.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*rLd4x3kxEAr0ul-LN3iwug.png" /></figure><p>ACO simulates the autocatalytic behavior by using the probabilistic technique for solving computational problems and finding the optimal solution for graph problems.</p><h4>Applying Ant Colony Optimization on Trip Scheduling</h4><p>To apply ACO to scheduling a trip, we have to represent our problem as a <em>complete directed graph.</em> First, we have to represent places to be visited, including accommodation, as nodes of the graph. Edges of the graph represent travel direction and its weight represents the minimum traveling time between two places. However, traveling from place X to place Y and traveling from place Y to place X might require different routes which are possible to take different traveling times. Thus, the weight of edge [X, Y] and the weight of edge [Y, X] could be different. Additionally, each node has its own available time window that allows the ant to visit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/467/1*zLctMR_zuUAdgj6mGqBo0g.png" /><figcaption>Example of the graph representing places and traveling time between places.</figcaption></figure><p>By using ACO, each ant will construct the path until all nodes are visited, where the hotel node is allowed to be visited multiple times. In the path construction process, an ant will start on the hotel node and then decide to travel to the next node based on the transition probability of the remaining feasible nodes. Each ant has its own <em>current_time </em>to simulate the current time on that day in the trip. When the ant moves to the next node, we will calculate the new <em>current_time </em>by adding traveling time and duration spent in the current node. If there is no such feasible node, which means <em>current_time</em> exceeds the available time windows of all unvisited nodes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*4NO1QwWDSvDuol4LDsdKxA.png" /></figure><p>Since ACO constructs multiple paths, then we will choose the optimal path from an objective function, e.g., total travel time, minimizing the number of days in the trip. After we chose the optimal path, we can use information about traveling time between places, each place spent duration, and <em>day_start_time </em>and <em>day_end_time, </em>to interpret the arrival and departure time of each place. After the interpretation, we successfully generated a travel plan from the list of places!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/428/1*yZQQKVmVR1zpXxvranEzFA.png" /></figure><p>Assuming that <em>day_start_time </em>is 8:30:00 and spend two hours on each place. The picture above shows an example of the interpreted trip plan from the optimal path that we’ve got from the ACO.</p><h4>Flexible Departure Time</h4><p>Additionally, we can make our algorithm more flexible by calculating the wait time when an ant selects the next node. For example, if we specify to start a day at 8:00 a.m. but there is no such place that opens since 8:00 a.m., the earliest place that will be open is open at 9:00 a.m. Then, we can wait at the hotel for one hour and start the day one hour late at 9:00 a.m.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nafq26hMTuNFx-57mIdswg.png" /></figure><h4>Conclusion</h4><p>To sum it up, this article shows an application of Ant Colony Optimization in scheduling tasks, trip scheduling in this case. As shown above, we can implement a simple program to automate the scheduling task by illustrating a problem as a graph, treating it as a Vehicle Routing Problem, then applying the ACO algorithm to find an optimal solution for it.</p><p>Please noted that the application in this article is just a simple idea and has a lot of room for improvement. But I hope this article can help you understand the application of Vehicle Routing Problems and Ant Colony Optimization more clearer!</p><p><strong>References:<br></strong><em>Toth, P.; Vigo, D., eds. (2002). The Vehicle Routing Problem. Monographs on Discrete Mathematics and Applications. Vol. 9. Philadelphia: Society for Industrial and Applied Mathematics. ISBN 0–89871–579–2.</em></p><p><em>Andries P. Engelbrecht. “SACO: Pheromone Evaporation”. In: Computational intelligence: An introduction. Second. John Wiley, 2007.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d6cfba15399d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>