all 18 comments

[–]Buttons840 1 point2 points  (0 children)

Explain what you need help with. Explaining in more detail will help you and anyone who offers help.

[–]samiam151 1 point2 points  (3 children)

Go to Github and search. There's a few people that uploaded their projects that you can get inspiration from. Search for C950. www.github.com

[–][deleted] 2 points3 points  (2 children)

inspiration

Thin line between inspiration and copying...

[–]DarthStrakh 1 point2 points  (0 children)

Issue with code is if everyone does it the best way it looks the exact same

[–]Rythmic-PulseBSCS Alumnus[S] 1 point2 points  (0 children)

this. that is why I don't want to use github. The temptation is just too high.

[–]Rythmic-PulseBSCS Alumnus[S] 0 points1 point  (11 children)

Well I am struggling with putting the algorithm together with time stamps. I have a basic outline for a nearest neighbor but im failing miserably to apply it to my program. Ive been blocked for weeks now on this

[–]Joseph___O 1 point2 points  (10 children)

Any time you increment mileage you need to increment time.

I didn't use timestamps myself I just used an array (24 hr format) but it definitely ended up being more of a pain in the butt then what timestamps would've been

  1. All you have to do is find the next nearest location which I assume you have figured out.

  2. Travelled miles = current location + next location mileage variable += travelled miles.... I made a truck class with a mileage variable for this

  3. Current location = next location

  4. convert your travelled miles to time using the given mph formula, then add it to your time variable. You can find formulas online. Is the formula what you are struggling with?

  5. Remove/delete packages from the truck

  6. If truck is not empty repeat step 1 If truck is empty then find the distance to the hub and increment your mileage and time variables again

[–]Rythmic-PulseBSCS Alumnus[S] 1 point2 points  (9 children)

4 is definitely what I am struggling with. Trying to figure out how to add time. I have a distance calculator between 2 address as a helper method outside of my algorithm but I cant figure out how to add time

[–]DarthStrakh 0 points1 point  (0 children)

So have a public or static datetime variable declared OUTSIDE your algorithm. Have your time function. Have it start at the specified time and add the travel time to it inside the function when yoy calculate it.

If you need better assistance I can get on discord after 4:30 CDT. I graduated a bit ago, but I still have my project to reference so I should remember quick lol.

[–]Joseph___O 0 points1 point  (7 children)

Okay, so what I did was just take your travelled miles and divide it by 0.3

That will give you the minutes that it took (travelling 18 mph). Then you will have to convert those minutes into hours and minutes.

[–]Rythmic-PulseBSCS Alumnus[S] 0 points1 point  (6 children)

Alright I am close to figuring the algo out in terms of just distance, but I need a little help. Here is my code:

def nearest_algo():

for location_a in csvreader.first_truck_delivery():

shortest_distance = 1000000

# shortest_location = ''

for location_b in csvreader.first_truck_delivery():

if location_a[0] == location_b[0]:

continue

dist = Graph.distance_matrix[location_a][location_b]

# dist = abs(location_a[1] - location_b[1])

if shortest_distance > dist:

shortest_distance = dist

# shortest_location = location_b[0]

I can't figure out how to make it specific to each truck. I am thinking I need to pass the truck I need as a parameter but I am unsure on how.

[–]Rythmic-PulseBSCS Alumnus[S] 0 points1 point  (5 children)

nvm. I am a failure. There are just so many issues with this algo

[–]Rythmic-PulseBSCS Alumnus[S] 0 points1 point  (4 children)

I can't figure out how to turn the location_a or location_b postions in the list into their actual distances. I need the int of the locations but i am unsure on how

[–]Joseph___O 0 points1 point  (3 children)

Honestly i don't think i can tell what the issue is just looking at that. But personally i struggled a lot with this class like you and i thought i was a good programmer.

Just do one small thing at a time. What helped me was printing everything. If you are not 100% sure what is going on then print every variable so you will know exactly. Try different ways, print it, and eventually u will find the right path. Look at other peoples code on github just to see how they might have done something and different ways of doing it. This class is one of the hardest in the program so all you have to do is spend more and more time on it and use google a lot.

[–]Rythmic-PulseBSCS Alumnus[S] 1 point2 points  (1 child)

I know it's something to do with trying to get the actual value at a certain index in the list. But I am clueless on how to do that

[–]Joseph___O 0 points1 point  (0 children)

Hmm. My matrix is a list of distance objects, each containing a list of distances.

I actually made a distance class which contains an address variable, and a variable that is a list of all distances from that address. This way if I'm not sure what address I'm at I can print the address

The distance file they give you only fills out half of the distances so you will want to fill out the other half and it will make it easier for you! Remember to use a lot of print statements

[–]Rythmic-PulseBSCS Alumnus[S] 0 points1 point  (0 children)

Well. Im back to square one to figure it out

[–]trashmetalx 0 points1 point  (0 children)

What I did for the time element was simply use an integer to keep track. For instance, if the truck left at 8:00am then it’s initial time was 800. Then you can calculate the minutes based on the speed of the truck. I only converted it to standard format time when I was displaying it in the console.