Lab 5 Traveling Salesperson Problem With Depth First Search We Will Explore Two

Lab 5- Traveling Salesperson Problem with Depth First Search

We will explore two algorithms for solving the very famous traveling salesperson problem. 

Consider a graph of cities. The cost on an edge represents the cost to travel between two cities. The goal of the salesperson is to visit each city once and only once, and returning to the city he/she originally started at. Such a path is called a “tour” of the cities. 

How many tours are there? If there are N cities, then there can be N! possible tours. If we tell you which city to start at, there are (N-1)! Possible tours. For example, if there are 4 cities (A, B, C, D), and we always start at city A, then there are 3! possible tours: 

(A, B, C, D) (A, B, D, C) (A, C, B, D) (A, C, D, B) (A, D, B, C) (A, D, C, B) 

It is understood that one travels back to A at the end of the tour. 

The traveling salesperson problem consists of finding the tour with the lowest cost. The cost includes the trip back to the starting city. Clearly this is a horrendously difficult problem, since there are potentially (N-1)! possible solutions that need to be examined. We will consider DFS algorithms for finding the solution. 

The DFS algorithm is exhaustive – it will attempt to examine all (N-1)! possible solutions. This can be accomplished via a recursive algorithm (call it recTSP). This function is passed a “partial tour” (a sequence of M cities (M <= N) which is initially empty) and a “remaining cities” (sequence of N cities). There are clearly M-N cities not in this partial tour. Thus the function recTSP will have to call itself recursively M-N times, adding each of the M-N cities to the current partial tour out of the remaining cities. If M=N we have a complete tour. 

For example, we start with recTSP ({A}). This will have to call recTSP ({A, B}), recTSP ({A, C}, and recTSP ({A, D}). Here is a partial picture of how the sequence of function calls is done. This tree is not something you build explicitly – it arises from your function calls. You traverse this tree in a “depth-first” manner, The numbers tell you the order in which the nodes are processed. 

Each leaf node is a complete tour, which you will compute the cost of. Note that each non-leaf node is an incomplete tour, which you can also compute the cost of. If the cost of an incomplete tour is greater than the best complete tour that you have found thus far, you clearly do not have to continue working on that incomplete tour. Thus you can “prune” your search. 

Just how hard are these problems? For example, if there are 29 cities, how many possible tours are there? If you can check 1,000,000 tours per second, how many years would it take to check all possible tours? Has the universe been around that long? 

Since this program may take too long to complete, be sure to output the tour and its cost when it finds a new best tour.  

We have to first develop the distance matrix, also called adjacency matrix. This adjacency matrix is populated using a given data file. You will run your program to find the best tours for 12, 14, 16, 19, and 29 cities.

Here is a sample code to populate the distance matrix

 public void populateMatrix(int[][] adjacency){

int value, i, j; 

for (i = 0; i < CITI && input.hasNext(); i++) { //CITI is a constant  

  for (j = i; j < CITI && input.hasNext(); j++){ 

    if (i == j) { 

          adjacency[i][j] = 0;

    }

    else {

          value = input.nextInt();

           adjacency[i][j] = value;

           adjacency[j][i] = value;

    }

  }

}

}

Here is an algorithm to compute tour cost

Algorithm computeCost (ArrayList<Integer> tour)

           Set totalcost = 0

      For (all cities in this tour)

          totalcost += adjacency [tour.get(i)][ tour.get(i+1)]

           EndFor

           If (tour is a complete tour)

                       totalcost += adjacency [tour.get(tour.size()-1)][0]

           EndIf

           return totalcost

 End computeCost

Here is the DFS algorithm

Use ArrayList for “partialTour” and “remainingCities” – This implementation is inefficient due to higher space complexity. 

/* requies : partialTour = <0>, remainingCities = <1,2, 3, ….N-2, N-1>

  ensures: partialTour = <0,…..n> where n E <1,2,3, …, N-1> &&

                Cost(partialTour) is the absolute minimum cost possible.

*/

Algorithm recDFS (ArrayList<Integer> partialTour, ArrayList<Integer> remainingCities )

           If (remainingCities is empty)

                       Compute tour cost for partialTour

                      If (tour cost is less than best known cost)

                                  Set best known cost with tour cost

                                   Output this tour and its cost

                       EndIf

           Else

                       For (all cities in remainingCities)

                                   Create a newpartialTour with partialTour

                                   Add the i_th city of remainingCities to newpartialTour

                                   Compute the cost of newpartialTour

                                   If (newpartialTour cost is less than the best known cost) // pruning

                                               Create newRemainingCities with remainingCities

                                               Remove the i_th city from newRemainingCities

                                               Call recDFS with newpartialTour and newRemainingCities

                                  EndIf

                       EndFor

           EndIf              

 End recDFS

The minimal cost path for 12 cities is 821, and the minimal cost path for 29 cities is 1610, but 29! = 8841761993739700772720181510144 (!!!!!)

Well, Sorry to disappoint you. We will have to wait until the midterm to implement the second algorithm!!! 

Turn in your source program and outputs as an attachment of this assignment. You should turn in your outputs in a PDF. Do not turn in PDF with source code!!! 

 
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"
ORDER NOW

Lab 4c Loops Complete A Program To Draw Circles Arranged In A Grid For Example

Hi this is the second time i am posting this and I am hoping that someone can actually help me! This is actually really simple for someone who knows how to code in Java!!! The code that is already given, CAN NOT BE ALTERED!!!!!! It is simply filling in the two spots where it says “enter code here”. I know the second part has a loop within a loop. If someone can please hep. Thanks! Remember, you CAN NOT ALTER the given code!

 
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"
ORDER NOW

Label Each Of The Following Statements As True Or False Isoelectric Focusing Of

Label each of the following statements as True or False:

a. Isoelectric focusing of proteins separates by size.

b. After protein separation by SDS-PAGE each band on the gel represents only one protein.

c. SDS only binds to polar proteins.

 
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"
ORDER NOW

Lab Overviewscenario Summarydownload The Lab Instructions And The Lab Report For

Lab Overview

Scenario/Summary

Download the Lab instructions and the Lab report for the necessary steps to be completed for this lab. They can be found in the Files section of the Course Menu under the Lab category. Complete this template Lab report document by completing the sections listed on the page (Objectives, Results, and Conclusions). You will notice that the readings, including lectures, the examples we worked on during the lecture, and other audio and visual aids provided, will help you tackle this week’s lab. Remember to always follow the instructions to get maximum credit, and use the weekly discussion related to the Lab and the Course Q & A Forum in the Introduction and Resources module for additional help. Be specific and state the problem you are having clearly, including what you have done to resolve it, in the discussion.

Deliverables

Please save the completed Word document using the following naming convention. Save it personalized as flastnameLab02, where f is your first initial, followed by your last name and the original file name Lab02.

Do not include .docx; Word will finish with the .docx extension (e.g., Tom Brews, tbrewsLab02 and Word will finish with .docx).

Submit your lab.

Required Software

This Lab will use the following Lab Resources:

Microsoft Office: Word

MySQL

Use a personal copy of the software or access Lab Resources under Introduction and Resources > Course Resources and view the Lab Resourcessection.

Lab Steps

Step 1:

The report cover sheets must be completed for all labs. The key parts of these sheets include the following.

  • Objective: Provide a one- or two-sentence explanation of the purpose of the lab.
  • Results: Give a statement of the final output, such as what will make this lab successful.
  • Conclusions: Conclusions should be based on the results usually directly related to the purpose of the lab.
  • Observations and Measurements: All results from the lab must be recorded on the cover sheets. Turn in the cover sheets for grading and retain the remainder of the lab as worksheets.
 
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"
ORDER NOW

Label Each Of The Following Scenarios In Which There Are Problems Enacting And A

Label each of the following scenarios in which there are problems enacting and applying fiscal policy as being an example of either recognition lag, administrative lag, or operational lag.

a. To fight a recession, Parliament has passed a bill to increase infrastructure spending—but the legally required environmental-impact statement for each new project will take at least two years to complete before any building can begin.

b. Distracted by a conflict that is going badly, inflation reaches 8 percent before politicians take notice.

     (Click to select)Recognition lagAdministrative lagOperational lag

c. A sudden recession is recognized by politicians, but it takes many months of political deal making before a stimulus bill is finally approved. 

     (Click to select)Recognition lagAdministrative lagOperational lag

d. To fight a recession, the president issues an executive order requiring Federal agencies to get rid of petty regulations that burden private businesses—but the Federal agencies begin by spending a year developing a set of regulations on how to remove petty regulations.

 
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"
ORDER NOW

Lab For C Pass By Value Functions Num Description 1 Reversing Digits Complete

}

#include&lt;iostream&gt;using namespace std;double getTax(double amount);int main() {double number;cout &lt;&lt; &quot;Enter the income: &quot;;cin &gt;&gt; number; } cout &lt;&lt; &quot;Tax:…

 
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"
ORDER NOW

Label Each As True Or False Centrifugation Can Be Used To Separate Cellular Comp

Label each as TRUE or FALSE:

  1. Centrifugation can be used to separate cellular components effectively.
  2. Centrifugation is an outdated technology and has been replaced by other methods.
  3. Centrifugation can only be used to separate large objects, but small particles like microsomes and ribosomes cannot be separated.
 
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"
ORDER NOW

Lab Ex 5 7 As Se Forma Talking About Activities In The Present Additional Yo Irr

Lab Ex. 5-7 Así se forma: Talking about activities in the present: Additional yo-irregular verbs

B. Additional yo-irregular verbs

5-7 ¿Qué hace Pepita? ¿

1.  sus libros.

 mi libro de español a clase todos los días.

2. La profesora 

 “Buenos días”.

 “Buenos días” a mi profesor.

3. Pepita 

 la tarea después de clase.

 la tarea después de clase.

4. 

 la tele.

 la tele por la noche.

  • Attachment 1
  • Attachment 2
  • Attachment 3
  • Attachment 4
 
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"
ORDER NOW

Lab Transshipment Problem 100 Points Problem 1 Transshipment Problem Courtesy Ex

Lab Transshipment Problem (100 Points)

Problem 1 Transshipment Problem

Courtesy example from Spreadsheet Modeling and Decision Analysis By Cliff Ragsdale)

The Bavarian Motor Company (BMC) manufactures expensive luxury cars in Hamburg, Germany and exports cars to sell in the United States. The exported cars are shipped from Hamburg to ports in Newark, New Jersey, and Jacksonville, Florida. From these ports, the cars are transported by rail or truck to distributors located in Boston, Massachusetts; Columbus, Ohio; Atlanta, Georgia; Richmond, Virginia; and Mobile, Alabama. Figure 1 shows the possible shipping routes available to the company along with the transportation cost for shipping each car along the indicated path.

Currently, 200 cars are available at the port in Newark, NJ and 300 are available in Jacksonville, FL. The numbers of cars needed by the distributors in Boston, Columbus, Atlanta, Richmond, and Mobile are 100, 60, 170, 80, and 70, respectively. BMC wants to determine the least costly way of transporting cars from the ports in Newark and Jacksonville to the cities where are needed.

Problem 2 Maximum Flow Problem

Consider the north-south interstate highway system passing through Cincinnati, Ohio. The north-south vehicle flow reaches a level of 15,000 vehicles per hour at peak times. Due to a summer highway maintenance program, which calls a for the temporary closing of lanes and lower speed limits, a network alternative routes through Cincinnati has been proposed by a transportation planner committee. The alternative routes include other highways as well as city streets.

Because of differences in speed limits and traffic patterns, flow capacities vary, depending on the particular streets and roads used. The proposed network with arc flow capacities is shown in Figure 2.

The direction of flow for each arc is indicated, and the arc capacity is shown next to each arc. Note that most of the streets are one-way. However, a two-way street can be found between nodes 2 and 3 and between node 5 and 6. In both cases, the capacity is the same in each direction.

 
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"
ORDER NOW

Lab Assignment 2 Advanced Encryption Standard Aes Due In Week 9 And Worth 120 Po

Lab Assignment 2: Advanced Encryption Standard (AES)

Due in week 9 and worth 120 points.

Instructions

  • Download the lab worksheet here.
  • Complete the lab according to the lab instructions provided on the lab worksheet.
  • Submit the lab worksheet as an attachment in the online course shell.
  • Capture a screen shot as you complete each one of the lab steps and paste it in the designated spot below each step.

Example:Step 1:Lab Assignment 2: Advanced Encryption Standard (AES)

Due Week 9 and worth 120 points

This exercise uses the Advanced Encryption Standard (AES). The United States National Institute of Standards and Technology (NIST) adopted AES as Federal Information Processing Standards Publications 197 (FIPS PUB 197) in 2001. AES supports key lengths of 128, 192, and 256 bits; JavaScrypt uses 256 bit keys exclusively.

For this exercise, you will need to use two (2) different e-mail accounts (i.e., your Strayer email account and your personal email account). You will be creating an encrypted message and sending it from your first e-mail account to your second e-mail account.

Instructions

  • Capture a screen shot as you complete each one of the lab steps and paste it in the designated spot below each step.

Example:

Step 1:

If there is a question in a step, your response should be included directly under the screen shot of that step.

  • Submit the lab worksheet as an attachment in the online course shell.

Lab Steps:

  1. Go to the JavaScrypt Encryption and Decryption page, located at  http://www.fourmilab.ch/javascrypt/javascrypt.html

<paste screen shot here>

2. Create a key and enter it into the text box under the “Key” section. (The text option button under the textbox should be selected.) Next, click the “Generate” command button. Copy the contents of the “Key” text box to a notepad file because you will need it later.

<paste screen shot here>

3. Then, go to the “Plain Text”” box immediately underneath the “Key” text box and enter text that you want to encrypt. (The “Codegroup” option button under the textbox should be selected.) Click the “Encrypt” command button.

<paste screen shot here>

4. Look at the “Cipher Text” text box located below the “Encrypt” command button. Explain what is there.

<paste screen shot here>

5. Login to your second e-mail account and open a new email.

<paste screen shot here>

6. Copy the contents of the “Cipher Text” text box into the body of the email that you will be sending to your second email account.

<paste screen shot here>

7. Clear the contents of each of the “Key,” “Plain Text,” and “Cipher Text” text boxes.

<paste screen shot here>

8. Send the email from your first email account to your second email account.

<paste screen shot here>

9. Go to your second email account and open the email that you sent to yourself. Copy the encrypted message and paste it into the “Cipher Text” text box at http://www.fourmilab.ch/javascrypt/javascrypt.html. Click the “Decrypt” command button.

<paste screen shot here>

10.  Look back in the “Plain Text” text box. What do you see? Discuss what happened.

<paste screen shot here>

11.  Now, enter the key (plain or encrypted) into the “Key” text box. Which key did you enter? Can you enter the plain (unencrypted) key or do you have to use the encrypted one in order for the contents of the encrypted “Cipher Text” text box to be unencrypted and displayed in the “Plain Text” text box? Provide a rationale for your response.

<paste screen shot here>

12.  If a person does not have the original encrypted key, can he or she encrypt the original key that he or she entered in the “Key” text box? Provide a rationale for your response. Note:No screen shot is needed for this step.

13.  Explain the differences, if any, between using AES encryption versus a DES one. Note:No screen shot is needed for this step. 

14.  Why do many consider AES encryption more secure than DES?  Provide a rationale for your response.Note:No screen shot is needed for this step. there is a question in a step, your response should be included directly under the screen shot of that step.

Click here to view the grading rubric.

 
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"
ORDER NOW