istellartech / OpenGoddard

Trajectory Optimization for Python
https://istellartech.github.io/OpenGoddard/
MIT License
108 stars 27 forks source link

<list index out of range> error for 3DoF Delta III optimal ascent control problem formulation #8

Open athulpg007 opened 6 years ago

athulpg007 commented 6 years ago

Hi there!

I have been trying to extend the 12_two_stage_rocket problem in OpenGoddard examples to solve a 3DoF Delta III launch problem described in this article.

I have read in earlier issues here that the developer is aware of some convergence issues. However, I am having some difficulty getting the solver to accept the problem set up. My problem formulation source code is attached here along with this issue.delta-iii-problem.txt

I am faced with the error message before even starting iterations, and cannot seem to find what might be wrong in the code! Can the developer kindly take a look at the code or suggest any reasons why I am running into this issue? Thanks!

---- iteration : 1 ----

IndexErrorTraceback (most recent call last) C:\Users\athul\Dropbox\Codes\OpenGoddard\OpenGoddard-master\examples\delta-iii-problem-lab.py in () 654 print("final time : {0:.3f}".format(tf)) 655 --> 656 prob.solve(obj, display_func, ftol=1e-3) 657 658 C:\Users\athul\AppData\Local\Enthought\Canopy\edm\envs\User\lib\site-packages\OpenGoddard\optimize.pyc in solve(self, obj, display_func, options) 679 options={"disp": True, 680 "maxiter": maxiter, --> 681 "ftol": ftol}) 682 print(opt.message) 683 display_func() C:\Users\athul\AppData\Local\Enthought\Canopy\edm\envs\User\lib\site-packages\scipy\optimize_minimize.pyc in minimize(fun, x0, args, method, jac, hess, hessp, bounds, constraints, tol, callback, options) 456 elif meth == 'slsqp': 457 return _minimize_slsqp(fun, x0, args, jac, bounds, --> 458 constraints, callback=callback, options) 459 elif meth == 'dogleg': 460 return _minimize_dogleg(fun, x0, args, jac, hess, C:\Users\athul\AppData\Local\Enthought\Canopy\edm\envs\User\lib\site-packages\scipy\optimize\slsqp.pyc in _minimize_slsqp(func, x0, args, jac, bounds, constraints, maxiter, ftol, iprint, disp, eps, callback, *unknown_options) 309 # Set the parameters that SLSQP will need 310 # meq, mieq: number of equality and inequality constraints --> 311 meq = sum(map(len, [atleast_1d(c['fun'](x, c['args'])) for c in cons['eq']])) 312 mieq = sum(map(len, [atleast_1d(c['fun'](x, c['args'])) for c in cons['ineq']])) 313 # m = The total number of constraints C:\Users\athul\AppData\Local\Enthought\Canopy\edm\envs\User\lib\site-packages\OpenGoddard\optimize.pyc in for_solver(p, arg0, arg1) 645 def for_solver(p, arg0, arg1): 646 self.p = p --> 647 return func(arg0, arg1) 648 return for_solver 649 C:\Users\athul\AppData\Local\Enthought\Canopy\edm\envs\User\lib\site-packages\OpenGoddard\optimize.pyc in equality_add(equality_func, obj) 616 tix = self.time_start(i) / self.unit_time 617 tfx = self.time_final(i) / self.unit_time --> 618 dx = self.dynamics[i](self, obj, i) 619 result = np.hstack((result, derivative - (tfx - tix) / 2.0 dx)) 620 IndexError: list index out of range

athulpg007 commented 6 years ago

I have been able to solve the above mentioned issue. The problem was that I used

prob.dynamics = [dynamics, dynamics] prob.knot_states_smooth = [False]

where I should have used,

prob.dynamics = [dynamics, dynamics, dynamics, dynamics] prob.knot_states_smooth = [False, False, False]

since I have four "sections" and three "knots" in the problem.