Jump to content

[WIN/MAC/LINUX] KSP Trajectory Optimization Tool v1.6.9 [New MATLAB Version!]


Recommended Posts

Hey y’all, is there something extra needed to setup the ability to run a parallel pool for optimization? When I try to enable it, I just get a message saying it wasn’t able to start a pool.

While I have some experience running parallelized code at work, I’ve never tried to set it up at home. I do have MATLAB, if that’s a requirement.

Link to comment
Share on other sites

On 11/18/2019 at 2:37 AM, Drew Kerman said:

thx for the latest release! also have you had a chance to read over my post, if not checked out the analysis package? Just want to make sure I was clear in what I was working on. Haven't really touched it myself since I posted it

It's on the to-do list! :)

On 11/18/2019 at 6:12 PM, Razgriz1 said:

Hey y’all, is there something extra needed to setup the ability to run a parallel pool for optimization? When I try to enable it, I just get a message saying it wasn’t able to start a pool.

While I have some experience running parallelized code at work, I’ve never tried to set it up at home. I do have MATLAB, if that’s a requirement.

No, it should just work.  Can you post the contents of your ksptot.log file here?  How much RAM does your PC have?  What about number of cores on the CPU?

Link to comment
Share on other sites

4 hours ago, Arrowstar said:

No, it should just work.  Can you post the contents of your ksptot.log file here?  How much RAM does your PC have?  What about number of cores on the CPU?

Starting it up fresh and attempting to setup a parallel pool yields a log that only says

Starting parallel pool (parpool) using the 'local' profile ...

I have 24 GB of RAM and my CPU has 6 cores and 12 logical processors. I have also verified that I am able to start a 12 worker pool through MATLAB (2018b) itself. 

Link to comment
Share on other sites

Hi

I had downloaded the new 1.65 prerelease, copied the new KSPTOT connect dll into my 1.7.3 JNSQ save, and tried to create a new bodies file. I got an error. The error log was:

Index exceeds matrix dimensions.

Error in getBodiesINIFileFromKSP (line 135)

Error in mainGUI>createNewBodiesFileFromKSP_Callback

Error in gui_mainfcn (line 95)

Error in mainGUI (line 42)

Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)mainGUI('createNewBodiesFileFromKSP_Callback',hObject,eventdata,guidata(hObject))

Error using waitforallfiguresclosed (line 9)
Error while evaluating Menu Callback.

Will revert back to 1.6.4 to see if it helps

Thanks

 

Edit1: Sorry...dd not write that well...meant to say that I recopied the dll from the 1.6.4. download, then added the new prerelease. Am deleting everything and will test a fresh install.

Edit2: it works...just redownloaded everything and reinstalled. sorry for the mixup
 

Edited by Gilph
clarify
Link to comment
Share on other sites

possible issue I've noticed for a while but never remember to mention: when you create a New Mission Plan it doesn't make a MAT file with the bodies from the .ini file you have set to load in the KSPTOT appsOptions file. Instead it loads the same body data as the last opened MAT file.

Link to comment
Share on other sites

so it seems the latest prerelease has removed the option to enable/disable parallel optimization but now automatically attempts to start it when you load a file, if it's not already started. However it does not attempt a start when you first open LVD. So in order to enable it for a new file you have to save and then re-open it. But does that mean on any systems that can't support this feature every time you open a new LVD case file it will attempt a start?

Link to comment
Share on other sites

  • 2 weeks later...
On 11/27/2019 at 9:56 AM, Drew Kerman said:

possible issue I've noticed for a while but never remember to mention: when you create a New Mission Plan it doesn't make a MAT file with the bodies from the .ini file you have set to load in the KSPTOT appsOptions file. Instead it loads the same body data as the last opened MAT file.

Ah, yeah.  This is sort of by design and sort of behavior that is inherent in the way MA and LVD were written.  I certainly can change it to use whatever is in the bodies.ini file pointed to in the appOptions file if you'd like.

On 12/3/2019 at 12:31 PM, Drew Kerman said:

so it seems the latest prerelease has removed the option to enable/disable parallel optimization but now automatically attempts to start it when you load a file, if it's not already started. However it does not attempt a start when you first open LVD. So in order to enable it for a new file you have to save and then re-open it. But does that mean on any systems that can't support this feature every time you open a new LVD case file it will attempt a start?

Open up the options for the selected solver and make sure that parallel computing is enabled.  If it is, when you close the solver selection dialog box, it should start the parallel computing pool.  Is that helpful?

Link to comment
Share on other sites

1 hour ago, Arrowstar said:

I certainly can change it to use whatever is in the bodies.ini file pointed to in the appOptions file if you'd like.

yea that would be preferable because I do swap around MAT files that contain various bodies.ini info, either older files or files with planet deliberately removed so only certain ones are drawn in the plot or so I can place a vessel in the exact same orbit & position without getting a collision warning or even other ppl's files. Either way it's a bit annoying to recall what bodies I have in what file currently open before I create a new one. I generally just restart MA to make sure instead

1 hour ago, Arrowstar said:

Open up the options for the selected solver and make sure that parallel computing is enabled.  If it is, when you close the solver selection dialog box, it should start the parallel computing pool.  Is that helpful?

Ahhhh, there it is. Also holy crap that's a ton of stuff (I mean that in a good way). I didn't look that deep into the settings

Edited by Drew Kerman
Link to comment
Share on other sites

On 12/11/2019 at 4:58 PM, Drew Kerman said:

yea that would be preferable because I do swap around MAT files that contain various bodies.ini info, either older files or files with planet deliberately removed so only certain ones are drawn in the plot or so I can place a vessel in the exact same orbit & position without getting a collision warning or even other ppl's files. Either way it's a bit annoying to recall what bodies I have in what file currently open before I create a new one. I generally just restart MA to make sure instead

Done for next release. :)

Quote

Ahhhh, there it is. Also holy crap that's a ton of stuff (I mean that in a good way). I didn't look that deep into the settings

Glad you like it lol.  Took days to make those goofy UIs with all the options! :)

Link to comment
Share on other sites

18 minutes ago, Arrowstar said:

Glad you like it lol

now I just have to understand it :sticktongue: Right now tho I have no idea why I would use it all. Can you give some general use cases where I would want to start playing around in there? If possible I'll try to work up a reason to do so and give you some feedback

Link to comment
Share on other sites

2 hours ago, Drew Kerman said:

now I just have to understand it :sticktongue: Right now tho I have no idea why I would use it all. Can you give some general use cases where I would want to start playing around in there? If possible I'll try to work up a reason to do so and give you some feedback

Honestly, most of it you can leave with the stock settings.  The big things (for FMINCON) are the solver algorithm, the tolerances, and parallelization.  Everything else is less important.  Of those, the only one with a non-obvious use case is the algorithm, and you'd just change it if the current selection wasn't making any progress.  A different algorithm might solve the problem better.

Link to comment
Share on other sites

I added an "impulsive delta-v" event action to LVD this evening.  This has been on my TO DO list for a while now.  This allows Launch Vehicle Designer to model impulsive delta-v maneuvers, just like Mission Architect.  You can specify the delta-v vector in either the inertial frame or the orbit frame, and the maneuver can be set to calculate the fuel usage of the maneuver or make it a propellant-less maneuver (such as two spacecraft undocking).

Link to comment
Share on other sites

11 hours ago, Drew Kerman said:

speaking of delta-v, been meaning to ask if there's any good reason to add a means to track Dv amount & usage in LVD. In MA you can see how much Dv you are using, but not how much Dv you have

Delta-v remaining would be easy enough to do in LVD, I suppose I could base it off currently active engines and the tanks they pull from.  The problem with tracking usage is that it's not a quantity that is associated with a particular state but instead is the sum of a bunch of calculations that occur between states.  (Remember that delta-v is computed as the Isp times the natural log of the ratio of old mass to new mass.)  So I'm not sure how I would do that under the paradigm I have now.  Do you have a use case for this information?

6 hours ago, Drew Kerman said:

Got an error in LVD, file & log here

Open the Initial State and try changing the UT to 105975594. I keep it at 0 initially since then everything is always in MET

Should be an easy fix, thanks for the report!

Link to comment
Share on other sites

12 hours ago, Drew Kerman said:

Got an error in LVD, file & log here

Open the Initial State and try changing the UT to 105975594. I keep it at 0 initially since then everything is always in MET

Resolved for next release.

EDIT: By the way, I took a look at your mission script in the file you provided.  I realize I've probably never mentioned this until now, but it's not good practice to have sequential and non-sequential events with the same termination conditions.  The script propagator can get confused and only register one event (probably the sequential one).  If you have actions you want to execute at that termination condition, just put them on the sequential event and delete the non-sequential event, or put the non-sequential event just after the sequential one.  This will prevent the issue.

Edited by Arrowstar
Link to comment
Share on other sites

6 hours ago, Arrowstar said:

Do you have a use case for this information?

I just realized I shouldn't have said "usage". Don't know why I said that, actually. Really all I think would be nice additions are current Dv at the end of a given state as well as perhaps the amount of potential Dv the rocket has displayed in the editor?

1 hour ago, Arrowstar said:

it's not good practice to have sequential and non-sequential events with the same termination conditions.

Good to know, thanks. I will clean that up. It wasn't originally made that way but I had to add extra pitch points to match the ascent curve. FWIW I did an output of the Cd and it seemed to be updating okay, but just to be sure I'll remove the duplicate altitude events

Link to comment
Share on other sites

16 hours ago, Drew Kerman said:

I just realized I shouldn't have said "usage". Don't know why I said that, actually. Really all I think would be nice additions are current Dv at the end of a given state as well as perhaps the amount of potential Dv the rocket has displayed in the editor?

What is current Dv at the end of a state?  Amount remaining?

Link to comment
Share on other sites

9 hours ago, Arrowstar said:

What is current Dv at the end of a state?  Amount remaining?

yea forget amount used. Just how much the rocket still has

You could also wait until I actually do orbital missions next year and get a better idea of what would be useful. I'm just looking to get a jump on things

Also I'm done with KSP for the rest of the year. Ship out for a New Year's fireworks show in the UAE tomorrow and won't be back until 1/3

Edited by Drew Kerman
Link to comment
Share on other sites

36 minutes ago, Drew Kerman said:

yea forget amount used. Just how much the rocket still has

You could also wait until I actually do orbital missions next year and get a better idea of what would be useful. I'm just looking to get a jump on things

Okay, let's just wait until you can tell me what you need a bit better. :)

Quote

Also I'm done with KSP for the rest of the year. Ship out for a New Year's fireworks show in the UAE tomorrow and won't be back until 1/3

Alright, safe travels and merry Christmas. :)

Link to comment
Share on other sites

I've done a bit of digging through your source code, and I found the startParallelPool function where you're having the program start a parallel pool. Running just the code in that function (minus the writeOutput commands) seems to properly start a parallel pool with no exceptions thrown. My next guess is that there's something up with the permissions on my end or something like that. Will do more investigating.

Link to comment
Share on other sites

23 hours ago, Razgriz1 said:

I've done a bit of digging through your source code, and I found the startParallelPool function where you're having the program start a parallel pool. Running just the code in that function (minus the writeOutput commands) seems to properly start a parallel pool with no exceptions thrown. My next guess is that there's something up with the permissions on my end or something like that. Will do more investigating.

Okay sounds good.  Btw, I can't promise that the code will work on any release but R2017b, but if you have R2018b, check your command window to see if MATLAB is throwing any errors.

Link to comment
Share on other sites

Tonight I revamped the way objective functions work in Launch Vehicle Designer.  Before, you got to select between one of basically three functions and that was it.  Now, however, the flexibility has been increased significantly with the introduction of what I call composite objective functions.

Py9NKCo.png

The way these work is that the user can create any number of sub-functions which are evaluated at the end of a particular event, just like constraints.  Then the values of those functions at their respective events are "composited" together using one of four methods.  Here, I'm using the standard "sum" method, which would just add up all of the functions shown in the list box on the left.  (Of course, I only have the one function at the moment, but you get the idea.)  Other composition types include RSS (root sum square), the minimum of the array of values, and the maximum of the array of values.

The functions that are available for use as an objective function are identical to those available for use as a constraint, so anything you could constraint before, you can now optimize.

Long story short, this should provide a lot more flexibility to all you mission planners out there.  Please let me know if you have any questions or feedback (though I realize I haven't released it to the public yet).  Happy orbiting! :)

EDIT: Also, as of 5 minutes ago there's now a constraint in Launch Vehicle Designer for delta-v expended over the course of an event.  This can also be used as an objective function, as I mentioned above.  Use cautiously, though: it's a fairly expensive function because I have to compute the delta-v expended between each time step in order to get the math right and account for everything.  It also doesn't account for things like staging and the like at the moment, so probably best to avoid using it in events where the rocket dry mass changes due to an action at the end.

Edited by Arrowstar
Link to comment
Share on other sites

Hi everyone!

This afternoon I'm releasing KSPTOT v1.6.5 pre-release 2.  There are a few nice changes in this release:

  • LVD/MA: New mission plans now use the celestial body data that's currently loaded in the main KSPTOT GUI and not the data from the previous mission plan.
  • LVD: Added a new impulsive delta-v event action.
  • LVD: Added a new event number and total effective specific impulse (Isp) tasks to Graphical Analysis.
  • LVD: Objective functions are now "composites" of a number of sub-functions.  Those sub-functions mirror what is available for use as a constraint.
  • LVD: Added a constraint (and therefore also an objective sub-function) for the amount of delta-v expended during an event.  Listed under "event delta-v expended" or something to that effect.

I also want to give a warning: After this pre-release, mission cases created in LVD will likely not be compatible with the next pre-release.  This is because I am completely rewriting, from scratch, the way that spacecraft states are represented in LVD (and really, these are generic and could be used anywhere, but I'm starting with LVD).  This is because I want the flexibility to use any state element set (position velocity, Keplerian orbit elements, geographic elements, etc) with any reference frame (inertial, body fixed, etc) relative to any body.  Right now everything is kind of hard coded and it's a pain in the neck to convert from one state representation to another.  This new system makes everything really seamless in a way I should have been doing from the start.  What's going to break, in LVD anyway, is the way that initial states are stored under the hood.  I'm basically going to allow for much more flexibility, but that's going to mean changing data structures, so old MAT files will not carry through from this pre-release (or older) to the next pre-release and beyond.  Sorry about this inconvenience! :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...