Stumped on 106 Random Search Optimization

Back to General discussions forum

kawasaki     2020-05-03 03:00:12

Hi! I'm not suggesting there is a checker bug, as 88 people have solved the problem. But it does have me stumped.

My answers never match the checker answers. Sometimes they have better times....?

But at any rate, I modified my program to print out the results after each suggested change. And I have yet to find anything resembling the solution set in the prime mover speeds that were evaluated. Everything checks out with the trial data in the explanation.

These are the steps in my program.

  1. Gather the data and make it suitable for manipulation.

  2. Send all of the data to an optimization method which is the backbone of the program. In the optimization method, I put the first line of the given data into a list of best speeds. I then send this list to a simulation method which runs the pseudocode given in the example. The simulation method returns a time, which I establish as best time.

  3. I begin to iterate through the random alterations. I make a copy of the current best speeds and then alter the copy with the alteration.

  4. I send the copy to a method which checks for validity of the set according to the boundaries of the problem. This routine returns a boolean. (At first, I assumed that the last speed must be <= 3, like the first. But I realized later that the text does not say that, and I altered my program accordingly. Unfortunately, this did not seem to change my results.)

  5. If the copy is invalid, I continue to the next iteration, using the current best speeds.

  6. If the copy is valid, I run it through the simulation.

  7. I compare the time of the simulation with the best current time. If it is greater than or equal to the current best time, I go to the next iteration (I have also tried to accept times that were equal, but the results were poor).

  8. If the time is less than the current best time, I make the copy the new best speeds, and the returned time the new best time.

  9. This repeats until this list is exhausted.

  10. The data is returned, cleaned of trailing zeros and printed.

After several failures, I altered the program to display each trial and the results. I have yet to see the solution set in any of the trials. In fact, I have yet to see any of the trials that matches the solution set beyond the first two speeds. I know I a must be missing something really simple, but I don't know what.

Please login and solve 5 problems to be able to post at forum