Steve: Nah, it really shouldn't be that bad. Those are the programming challenges I find interesting! Can you explain further what you mean by "output for the minimum points on the plots"? You mean provide orbital elements for both the type 1 and 2 minimums?
In other news, I had some inspiration on Thursday and decided I really know where the big flaw in the TOT is. The current goal for TOT as I've written it is to provide an optimum (or near optimum) trajectory based on user parameters. However, what is actually does is just put out porkchop plots for each stage of the flight. There's nothing inherently wrong with this: at one point, that was the only goal of the application. (Indeed, all the MATLAB files still reside in a folder called "Porkchop Plot Generator.") However, it's really not doing what it was advertized to do.
To that end, I pretty much need to rewrite the whole thing in order to provide a simple method of optimizing trajectory. What I couldn't do with version 1 of TOT is provide a deltaV function to the MATLAB function minimizer. Knowing in advance that this is what I want to do, I should be able to produce the requisite function easily. TOT v1 just wasn't written to do that sort of thing.
I won't be starting from scratch. I have the function library I built for version still, and almost all of that code is relevant here. It's mostly just a shift in paradigm, not the math.
I'll try to post updates here as I make progress.
---------- Post added 07-31-11 at 12:52 PM ---------- Previous post was 07-30-11 at 02:31 PM ----------
Right now I'm experimenting with a genetic algorithm to perform the trajectory optimization. The functions to calculate C3 energy needed from the launch vehicle and deltaV needed for powered flybys are written, and the function to calculate arrival deltaV to stop at the body is next.
My test case right now is the Voyager 2 Jupiter flyby, and the results are fairly promising as far as I can tell. I've had to mess with the sub-algorithms used within the MATLAB GA function, but I've got it to where I'm regularly hitting effectively 0 deltaV solutions 8 out of 10 times. GA is a stochastic algorithm and it's going to return slightly different solutions each time. This is fine, so long as the solutions are fairly close enough to each other. I'm planning on exposing some of the more basic algorithm options to the user so they can manipulate as they desire, but of course I'm trying to provide a decent set of defaults.
Next up on the list is to redo the GUI from scratch, taking into account what I've learned from version 1 and my GUI projects I'm completed since starting this previously. After that, I need to write the relevant callback functions to make the Tool come alive, write the code to generate porkchop plots, and write the code to create a map of the trajectory so people can visualize what's going on.
Here's some example output from my test script. I ran 10 trials, they are so labeled. The three long numbers a few lines down into each trial are the Earth departure date, Jupiter flyby date, and Saturn arrival date, respectively, in Julian Date. Elapsed time is the processing time in seconds (not CPU-seconds) required to generate the result.
Code:
1: ---------------------
Optimization terminated: maximum number of generations exceeded.
DeltaV is 1.9408e-005
2443515.95885315 2443853.03166839 2453941.58018276
Elapsed time is 25.913932 seconds.
2: ---------------------
Optimization terminated: maximum number of generations exceeded.
DeltaV is 4.4105e-005
2443515.95082796 2443853.02607047 2453941.77927664
Elapsed time is 25.508045 seconds.
3: ---------------------
Optimization terminated: maximum number of generations exceeded.
DeltaV is 1.494e-005
2443515.95796018 2443853.03141523 2453941.60673764
Elapsed time is 24.758804 seconds.
4: ---------------------
Optimization terminated: average change in the fitness value less than options.TolFun.
DeltaV is 0.19745
2443675.49995765 2444144.84000759 2452315.2736878
Elapsed time is 20.546130 seconds.
5: ---------------------
Optimization terminated: maximum number of generations exceeded.
DeltaV is 7.6528e-006
2443336.06434977 2443823.37390295 2451683.51491418
Elapsed time is 26.324571 seconds.
6: ---------------------
Optimization terminated: maximum number of generations exceeded.
DeltaV is 1.2393e-005
2443336.06449116 2443823.37411664 2451683.51823564
Elapsed time is 25.502319 seconds.
7: ---------------------
Optimization terminated: maximum number of generations exceeded.
DeltaV is 0.19745
2443675.49998729 2444144.82760091 2452315.36593189
Elapsed time is 26.056920 seconds.
8: ---------------------
Optimization terminated: maximum number of generations exceeded.
DeltaV is 4.8143e-007
2443336.064506 2443823.37417522 2451683.51541067
Elapsed time is 25.586863 seconds.
9: ---------------------
Optimization terminated: maximum number of generations exceeded.
DeltaV is 0.00023231
2443516.00502642 2443853.06638158 2453940.46983232
Elapsed time is 25.826775 seconds.
10: ---------------------
Optimization terminated: maximum number of generations exceeded.
DeltaV is 1.5697e-006
2443336.06447782 2443823.37413454 2451683.51555075
Elapsed time is 25.320806 seconds.
Comments, questions?
---------- Post added at 11:57 PM ---------- Previous post was at 12:52 PM ----------
And just a quick update before I go to bed. The cost function that combines the C3 energy, the total flyby deltaV, and the arrival deltaV has been written and tested. This next version of TOT will allow people to set requirements for when an encounter with a body must happen (that is, set the Julian Date, if you desire) as well as weight those three quantities I listed above with relative importance factors so you can optimize towards what you need.
Really, all I have to do is write the GUI now. The actual optimization code is up and running in a few test sets.