Optimizer/Fmincon Trouble

Post here for assistance in troubleshooting a problem using GMAT

Optimizer/Fmincon Trouble

Postby cheetham » Tue Jul 28, 2009 12:17 am

Hello,

Not sure if this is a bug or just a set-up issue. I am running MATLAB 2009a and cannot get the Fmincon/optimizer to work. I receive an error message of:

Interpreting scripts from the file.
***** file: C:\NWO - Boulder\GMAT Scripts\occ_trial_optimize.script
Running mission...
**** ERROR **** Interface Exception Thrown: Error returned from try,
fminconexist = exist('fmincon');
catch
errormsg = lasterr;
end
*** Mission run failed.


My script is set up as

Create FminconOptimizer SQP1;
GMAT SQP1.DiffMaxChange = 0.000001; % Real number
GMAT SQP1.DiffMinChange = 0.0000000001; % Real number
GMAT SQP1.MaxFunEvals = 3000; % Real number
GMAT SQP1.MaxIter = 2000; % Real number
GMAT SQP1.TolX = 0.0001; % Real number **independent variables tolerance
GMAT SQP1.TolFun = 0.000001; % Real number **cost function tolerance
GMAT SQP1.TolCon = 0.00001; % Real number **contraint function tolerance
GMAT SQP1.DerivativeCheck = Off; % {On, Off}
GMAT SQP1.Diagnostics = On; % {On, Off}
GMAT SQP1.Display = Iter % {Iter, Off, Notify, Final}
GMAT SQP1.GradObj = Off; % {On, Off}
GMAT SQP1.GradConstr = Off; % {On, Off}
GMAT SQP1.SourceType = 'MATLAB\R2009a';


Without the last line i get an error
Interpreting scripts from the file.
***** file: C:\NWO - Boulder\GMAT Scripts\occ_trial_optimize.script
Running mission...
**** ERROR **** Interface Exception Thrown: Error returned from try,
path('./matlab/', path)
catch
errormsg = lasterr;
end
*** Mission run failed.
===> Total Run Time: 4.704000 seconds


I have my matlab path set to open all the Matlab folders in the GMAT folder where I run the program from.

Appreciate your help - if its a bug and not just a stupid mistake I'd be glad to submit this all as a bug report

-brad
cheetham
 
Posts: 9
Joined: Wed Jul 15, 2009 8:11 pm

Re: Optimizer/Fmincon Trouble

Postby shughes » Tue Jul 28, 2009 2:18 pm

Hey Brad,

For starters, can you try to run fmincon directly in the command window that GMAT opens up. One simple test is to try typing "fmincon" at the prompt. That should either tell you the function doesn't exist, (there's a matlab setup problem), or it will tell you you don't have the right number of inputs, (which means that matlab found fmincon and there is a GMAT problem).

Steve
shughes
 
Posts: 443
Joined: Mon Jun 09, 2008 6:27 pm

Re: Optimizer/Fmincon Trouble

Postby cheetham » Tue Jul 28, 2009 4:46 pm

Steve,

Thanks for the tip. Using that I was able to troubleshoot the problem. I discovered that while MATLAB that I had running had the GMAT files in its path, GMAT wasn't find it. So I added the path in the GMAT opened command window and it loaded - started to run - and I got this error

********************************************************
*** Performing FminconOptimizer Optimization (using "SQP1")
*** 4 variables; 6 equality constraints; 0 inequality constraints
Variables: OccVar.A1Epoch, B1.Element1, B1.Element2, B1.Element3
Equality Constraints: OccVar.EarthMJ2000Eq.X, OccVar.EarthMJ2000Eq.Y, OccVar.EarthMJ2000Eq.Z, OccVar.EarthMJ2000Eq.VX, OccVar.EarthMJ2000Eq.VY, OccVar.EarthMJ2000Eq.VZ
********************************************************
********************************************************
*** Optimizer Text File
***
*** Using Fmincon Optimization
***
*** 4 variables
*** 6 equality constraints
***
*** 0 inequality constraints
***
*** Variables:
*** OccVar.A1Epoch
*** B1.Element1
*** B1.Element2
*** B1.Element3
***
*** Equality Constraints:
*** OccVar.EarthMJ2000Eq.X
*** OccVar.EarthMJ2000Eq.Y
*** OccVar.EarthMJ2000Eq.Z
*** OccVar.EarthMJ2000Eq.VX
*** OccVar.EarthMJ2000Eq.VY
*** OccVar.EarthMJ2000Eq.VZ
***
*** Inequality Constraints:
***
********************************************************
SQP1 Iteration 1; External Run
Variables: OccVar.A1Epoch = 0, B1.Element1 = 0, B1.Element2 = 0, B1.Element3 = 0
Iteration 1
Variable Values: [ 0 0 0 0 ]
**** ERROR **** CoordinateSystem exception: Object referenced axes definition does not result in an orthogonal system

rotMatrix =
0.1705580574430309 0.9853066816942013 -0.008982875373728074
-0.935724820435855 0.1591053045997863 -0.3148087712827318
-0.3087539626653343 0.06209867194208953 0.9491126094797586


I cannot figure out this error - I tried this script in 4 different builds. Searching in bugzilla i saw this occurred due to a bug before but was resolved earlier this year.

Any help would be great. Thank you!
cheetham
 
Posts: 9
Joined: Wed Jul 15, 2009 8:11 pm

Re: Optimizer/Fmincon Trouble

Postby shughes » Tue Jul 28, 2009 5:25 pm

There is a check in GMAT that that the norm of a rotation matrix is 1. This makes sure that there is not a numerical issue that means the axes are not orthogonal to each other. For some reason, this matrix is breaking the tolerance (norm = 1.00000000000683) . I suspect it is the rotation matrix used in calculating the maneuver. I thought this was fixed, but may not be in the build you are using.

One way to avoid this issue is to use the MJ2000Eq axes for your maneuver (assuming I'm correct in where the issue is arrising). Can you try that and let me know if it works... is using an inertial system for you maneuver an issue?

you might check with Edwin to see when that bug was fixed and what build date you need to avoid it.
shughes
 
Posts: 443
Joined: Mon Jun 09, 2008 6:27 pm

Re: Optimizer/Fmincon Trouble

Postby cheetham » Tue Jul 28, 2009 5:54 pm

I changed the burn format to
Create ImpulsiveBurn B1;
GMAT B1.CoordinateSystem = EarthMJ2000Eq;
GMAT B1.Element1 = 0;
GMAT B1.Element2 = 0;
GMAT B1.Element3 = 0;


Which if I understand you correctly was what you were suggesting. The format of the burn is irrelevant - i just need the total delta_v required. I tried a few other coordinate systems to no avail. I'm running the 7/20/2009 build but also tried the original script in 7/8/2009, 6/17/2009, and 6/4/2009 and had no luck.

As always, thank you for your help. I'll ping Edwin and see if he has any additional insight into a solution.
cheetham
 
Posts: 9
Joined: Wed Jul 15, 2009 8:11 pm

Re: Optimizer/Fmincon Trouble

Postby space_egd » Wed Jul 29, 2009 1:47 pm

Sadly my skills in the fmincon/optimizer area are a bit lacking. Steve is the GMAT expert on the optimizers.

I'm not sure if I'm reading your post correctly but why is OccVar.A1Epoch = 0. Something doesn't seem right there.

Whenever I get the rotMatrix error, I was usually trying to achieve values that never varied.

You can email your script to me and Steve and maybe we can spot something if there is a scripting problem.
space_egd
 
Posts: 357
Joined: Sun Jun 08, 2008 9:02 pm
Location: MD

Re: Optimizer/Fmincon Trouble

Postby shughes » Wed Jul 29, 2009 2:15 pm

do you mind posting your script?
shughes
 
Posts: 443
Joined: Mon Jun 09, 2008 6:27 pm

Re: Optimizer/Fmincon Trouble

Postby cheetham » Wed Jul 29, 2009 3:56 pm

Edwin,

I think you were onto something. When I changed the way I am calling out the epoch it runs. But there is something wrong with my set-up because it doesn't seem to be optimizing. It doesn't look like its applying the constraints. Also, every other time i run it I again get the rotMatrix error and it crashes (might be because I need to reset a variable)

I've posted the script. Thank you both for your help!

-brad
Attachments
occ_trial_optimize.script
(14.62 KiB) Downloaded 267 times
cheetham
 
Posts: 9
Joined: Wed Jul 15, 2009 8:11 pm


Return to Troubleshooting

Who is online

Users browsing this forum: No registered users and 2 guests

cron