0

I am trying to solve a nonlinear program with Direct collocation in drake. I want to regain the solution when SNOPT solved the program successfully. First I saved the initial guess of each variable in a .txt file, then I read the initial guess and set decision variables by SetInitialGuess() , and change nothing else, but I did not get the same solution, WHY? MOREOVER, when I run more times, the latter solutions are same.
e.g. solution1 != solution2; solution2 == solution3; solution3 == solution4;.....

I have check each initial guess to make sure they are same. Is there options in SNOPT or initial settings in NP should be set beside the initial guess of decision variables to get a same solution?

Zoe
  • 27,060
  • 21
  • 118
  • 148
cby
  • 21
  • 4

1 Answers1

0

Without knowing more about your program, one possible reason is that when you save the initial guess to a.txt, the floating number get truncated when print it to a txt file. So in the second run, the initial guess is not exactly the same as the first run. And this tiny difference in the initial guess causes the SNOPT to find a different solution. For solution 2, 3, 4, do they all load the initial guess from a.txt?

In order to print the floating number to the txt file, you could use setprecision command.

Hongkai Dai
  • 2,546
  • 11
  • 12