Lesson Route Optimization Problem - Artificial Intelligence - ثالث ثانوي

Lesson 3 Route Optimization Problem

Mathematical Programming In Optimization Problems

Table 5.2: Examples of decision and state variables

Lesson 3 Route Optimization Problem

The objective function is formulated as a mathematical expression

The Knapsack Problem

Lesson 3 Route Optimization Problem

A knapsack instance is illustrated in figure 5.6 with six items having specific weights

The code creates a list x to store the binary decision variables for the items. The mip library provides:

Lesson 3 Route Optimization Problem

for each item

Traveling Salesman Problem

Lesson 3 Route Optimization Problem

The following code can be used to create an instance of the TSP.

The following code used the above function to create a TSP instance with 8 locations and pairwise distances between 5 and 20:

Lesson 3 Route Optimization Problem

Creating a Brute-Force Solver for the Traveling Salesman Problem

The brute force solver uses the permutations() tool to create all possible routes. Note that the startstop

Lesson 3 Route Optimization Problem

The brute force solver computes the total distance of each route and

Using MIP to Solve the Traveling Salesman Problem

Lesson 3 Route Optimization Problem

The following code uses the Python mip library to create an MIP solver. It then adds one binary decision variable for every possible transition in the TSP instance generated above.

The above code uses the numpy.full() tool to create N×N numpy array for storing the binary x variables.

The next step is to ensure that the solver only reports solutions that visit each location,

Lesson 3 Route Optimization Problem

The complete formulation of the TSP includes one more type of constraint to ensure the computation

Lesson 3 Route Optimization Problem

As an example, consider the 1→2→1 route in the 2-route solution of the TSP instance shown

Lesson 3 Route Optimization Problem

The following code generates 100 TSP instances with 8 locations and a distance range between5

The results verify that the MIP solver reports the optimal solution for 100% of the problem instances.

Lesson 3 Route Optimization Problem

Explain how mathematical programming can be used to solve complex optimization problems.

What are the advantages and disadvantages of the MIP approach for solving optimization problems?

Lesson 3 Route Optimization Problem

Analyze two optimization problems that can be solved with mathematical programming and outline their state and decision variables.

List three different optimization problems from the family of routing problems.

Lesson 3 Route Optimization Problem

You want to create a brute-force solver function for the Traveling Salesman Problem. Complete the following code so that the solver function returns the best route and best total distance.

Lesson 3 Route Optimization Problem

You want to create an MIP solver for the Traveling Salesman Problem. Complete the following code so that the decision variables and connectivity constraints are selected correctly.