Uploaded image for project: 'GMAT'
  1. GMAT
  2. GMT-2475

Provide a parameter to check convergence status of a VF13 optimizer

    Details

      Description

      For users putting logic around an Optimize loop (such as a surrounding For loop), it's helpful to have a flag to check whether or not the optimizer has converged or not. This would look like VF13ad1.Converged = true or false.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

              Hide
              rqureshi Rizwan Qureshi added a comment -

              comment from Bugzilla:

              ------- Comment #1 From Steven Hughes 2012-01-30 13:38:46 -------

              I would suggest putting a field like this on all iterative solvers.

              However, this is not P1 for R2012a so deprioritizing.

              Show
              rqureshi Rizwan Qureshi added a comment - comment from Bugzilla: ------- Comment #1 From Steven Hughes 2012-01-30 13:38:46 ------- I would suggest putting a field like this on all iterative solvers. However, this is not P1 for R2012a so deprioritizing.
              Hide
              djcinsb Darrel Conway added a comment -

              P3 to move it to R2013b or later

              Show
              djcinsb Darrel Conway added a comment - P3 to move it to R2013b or later
              Hide
              djcinsb Darrel Conway added a comment -

              Hmm, I'm partway into doing this, but then I thought of a potential issue. Suppose we have this scripting:

              Target DC;
                 Vary DC(TOI.Element1 = 0.5);
                 Maneuver TOI(DefaultSC);
                 Propagate DefaultProp(DefaultSC) {DefaultSC.Apoapsis};
                 Achieve DC(DefaultSC.Earth.RMAG = 42165, {Tolerance = 0.1});
              EndTarget;
              Target DC;
                 Vary DC(GOI.Element1 = 0.5, {Perturbation = 0.0001, Lower = 0, Upper = 3.14159, MaxStep = 0.2});
                 Maneuver GOI(DefaultSC);
                 Achieve DC(DefaultSC.ECC = 0, {Tolerance = 0.1});
              EndTarget
              
              Report rf DC.SolverStatus;
              

              What should be reported if the first loop converges but the second one does not converge? Since DC is cloned in the mission control sequence, should I look for the solver named to match the one on the parameter that is in a command "closest but earlier" than the Report line or something?

              That's what I'll try initially, anyway.

              Show
              djcinsb Darrel Conway added a comment - Hmm, I'm partway into doing this, but then I thought of a potential issue. Suppose we have this scripting: Target DC; Vary DC(TOI.Element1 = 0.5); Maneuver TOI(DefaultSC); Propagate DefaultProp(DefaultSC) {DefaultSC.Apoapsis}; Achieve DC(DefaultSC.Earth.RMAG = 42165, {Tolerance = 0.1}); EndTarget; Target DC; Vary DC(GOI.Element1 = 0.5, {Perturbation = 0.0001, Lower = 0, Upper = 3.14159, MaxStep = 0.2}); Maneuver GOI(DefaultSC); Achieve DC(DefaultSC.ECC = 0, {Tolerance = 0.1}); EndTarget Report rf DC.SolverStatus; What should be reported if the first loop converges but the second one does not converge? Since DC is cloned in the mission control sequence, should I look for the solver named to match the one on the parameter that is in a command "closest but earlier" than the Report line or something? That's what I'll try initially, anyway.
              Hide
              djcinsb Darrel Conway added a comment -

              I have such a parameter now. If I run with it set in these locations in the script:

              BeginMissionSequence;
              Report Status vf.SolverStatus;
              
              Optimize vf {SolveMode = Solve, ExitMode = DiscardAndContinue};
              ...   
              
                 Report Status vf.SolverStatus;
              EndOptimize;  % For optimizer vf
              
              Report Status vf.SolverStatus;
              

              the output is:

              vf.SolverStatus           
              Initialized               
              vf.SolverStatus           
              Initialized               
              Running                   
              Running                   
              Running                   
              Running                   
              Running                   
              Running                   
              Running                   
              Running                   
              Running                   
              Running                   
              Running                   
              Converged                 
              vf.SolverStatus           
              Converged                 
              

              Similar results for a DC. The estimators need to set the status flag, and then they will behave similarly.

              Right now it's only hooked up and checked in the Report command. Do String comparisons work in the control logic? An initial check indicates that it does not work; I see this:

              1: **** ERROR **** Interpreter Exception: Command Exception: A value of "vf.SolverStatus" of base type "String" on command "ConditionalBranch" is not an allowed value.
              The allowed values are: [ Object Property (Real), Real Number, Variable, Array Element, or Parameter ].  in line:
                 "  96: If vf.SolverStatus ~= 'Converged'"
              

              I could hook up numerical versions, but that is less user friendly. Suggestions?

              Show
              djcinsb Darrel Conway added a comment - I have such a parameter now. If I run with it set in these locations in the script: BeginMissionSequence; Report Status vf.SolverStatus; Optimize vf {SolveMode = Solve, ExitMode = DiscardAndContinue}; ... Report Status vf.SolverStatus; EndOptimize; % For optimizer vf Report Status vf.SolverStatus; the output is: vf.SolverStatus Initialized vf.SolverStatus Initialized Running Running Running Running Running Running Running Running Running Running Running Converged vf.SolverStatus Converged Similar results for a DC. The estimators need to set the status flag, and then they will behave similarly. Right now it's only hooked up and checked in the Report command. Do String comparisons work in the control logic? An initial check indicates that it does not work; I see this: 1: **** ERROR **** Interpreter Exception: Command Exception: A value of "vf.SolverStatus" of base type "String" on command "ConditionalBranch" is not an allowed value. The allowed values are: [ Object Property (Real), Real Number, Variable, Array Element, or Parameter ]. in line: " 96: If vf.SolverStatus ~= 'Converged'" I could hook up numerical versions, but that is less user friendly. Suggestions?
              Hide
              djcinsb Darrel Conway added a comment -

              I added a second parameter, "SolverState", that returns a real number. It returns 0 before the solver has been run, +1 for convergence, -1 for "too many iterations", and -2 (can be overridden in derived classes) for other failures. I've checked this parameter in report commands and in an If command; the script (a modification of the Hohmann transfer) is attached.

              I'm marking the issue as "resolved", though there are a couple of things that need to happen for that to actually be true:

              1. The code needs to be committed to the GSFC repo. That can't happen until the government shutdown ends.
              2. Someone needs to build test cases and see if I missed any pieces. (ANd these tests need to be incorporated into the test system...)
              Show
              djcinsb Darrel Conway added a comment - I added a second parameter, "SolverState", that returns a real number. It returns 0 before the solver has been run, +1 for convergence, -1 for "too many iterations", and -2 (can be overridden in derived classes) for other failures. I've checked this parameter in report commands and in an If command; the script (a modification of the Hohmann transfer) is attached. I'm marking the issue as "resolved", though there are a couple of things that need to happen for that to actually be true: The code needs to be committed to the GSFC repo. That can't happen until the government shutdown ends. Someone needs to build test cases and see if I missed any pieces. (ANd these tests need to be incorporated into the test system...)
              Hide
              djcinsb Darrel Conway added a comment -

              Script for the Hohmann transfer with truncated number of iterations. This script fires a maneuver is SolverState < 0, which is the case with the iteration count of 5 in the script. Raise it to the default (25), and the extra maneuver does not fire.

              Show
              djcinsb Darrel Conway added a comment - Script for the Hohmann transfer with truncated number of iterations. This script fires a maneuver is SolverState < 0, which is the case with the iteration count of 5 in the script. Raise it to the default (25), and the extra maneuver does not fire.
              Hide
              djcinsb Darrel Conway added a comment -

              See notes on progress. I'm holding off on reassigning this issue until I can commit the code to the Git repo.

              Show
              djcinsb Darrel Conway added a comment - See notes on progress. I'm holding off on reassigning this issue until I can commit the code to the Git repo.
              Hide
              djcinsb Darrel Conway added a comment -

              The code is now in Jazz

              Show
              djcinsb Darrel Conway added a comment - The code is now in Jazz
              Hide
              shughes Steven Hughes added a comment -

              Darrel, I assume you meant the code is in Git?

              Show
              shughes Steven Hughes added a comment - Darrel, I assume you meant the code is in Git?
              Hide
              djcinsb Darrel Conway added a comment - - edited

              No. The code changes were committed before the Jazz repo was moved to Git. The changes were committed to Git (for base code updates) and Jazz (for VF13 specifics). Once Jazz was moved to Git, these changes came along, but that happened after the bug fix.

              The earlier Git comment was for the base code piece. I could not commit that piece at the time because of the government shutdown.

              Show
              djcinsb Darrel Conway added a comment - - edited No. The code changes were committed before the Jazz repo was moved to Git. The changes were committed to Git (for base code updates) and Jazz (for VF13 specifics). Once Jazz was moved to Git, these changes came along, but that happened after the bug fix. The earlier Git comment was for the base code piece. I could not commit that piece at the time because of the government shutdown.
              Hide
              shughes Steven Hughes added a comment -

              Nice. I like it!

              Show
              shughes Steven Hughes added a comment - Nice. I like it!
              Hide
              shughes Steven Hughes added a comment -

              This script shows that the numeric parameter works for a Differential Corrector.
              1) Add string parameter test to the DC test case
              2) Test numberic and string parameter for vf13ad
              3) Test numeric and string parameter for fmincon
              4) Doc all of this

              Show
              shughes Steven Hughes added a comment - This script shows that the numeric parameter works for a Differential Corrector. 1) Add string parameter test to the DC test case 2) Test numberic and string parameter for vf13ad 3) Test numeric and string parameter for fmincon 4) Doc all of this
              Hide
              jjkparker Joel Parker added a comment -

              Reassigning to Steve Cooley based on conversation with Steve Hughes - and because Cooley is the feature lead!

              Marking as Scheduled too to it shows up on the to-do list.

              Show
              jjkparker Joel Parker added a comment - Reassigning to Steve Cooley based on conversation with Steve Hughes - and because Cooley is the feature lead! Marking as Scheduled too to it shows up on the to-do list.
              Hide
              dcooley Steve Cooley added a comment - - edited

              Developed regression test, Optimize_vf13_cvg_status, to test output fields, SolverStatus and SolverState.

              Developed analogous test for the Target command, Target_DC_cvg_status.

              Show
              dcooley Steve Cooley added a comment - - edited Developed regression test, Optimize_vf13_cvg_status, to test output fields, SolverStatus and SolverState. Developed analogous test for the Target command, Target_DC_cvg_status.
              Hide
              dcooley Steve Cooley added a comment - - edited

              Updated Target and Optimize command engineering spec and XML on 4/8/14.

              Show
              dcooley Steve Cooley added a comment - - edited Updated Target and Optimize command engineering spec and XML on 4/8/14.

                People

                • Votes:
                  0 Vote for this issue
                  Watchers:
                  4 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:

                    Time Tracking

                    Estimated:
                    Original Estimate - Not Specified
                    Not Specified
                    Remaining:
                    Time Spent - 2 days Remaining Estimate - 2 days
                    2d
                    Logged:
                    Time Spent - 2 days Remaining Estimate - 2 days
                    2d