ImperialCollegeLondon / ICLOCS

Imperial College London Optimal Control Software (ICLOCS)
MIT License
76 stars 44 forks source link

postSolveAnalysis issue #7

Closed VishnuDevA7 closed 4 years ago

VishnuDevA7 commented 4 years ago

With multiphase problems, when the solver converges to a point of infeasibility, the "postSolveAnalysis.m" called from "runPostSolveTasks.m" throws an error. I have pasted the output and the error from my command window below :


Number of Iterations....: 2450

                               (scaled)                 (unscaled)

Objective...............: 0.0000000000000000e+00 0.0000000000000000e+00 Dual infeasibility......: 6.3501789486174881e-05 6.3501789486174881e-05 Constraint violation....: 9.9790206920754663e-03 9.9790206920754663e-03 Complementarity.........: 4.0379369118151650e-09 4.0379369118151650e-09 Overall NLP error.......: 9.9790206920754663e-03 9.9790206920754663e-03

Number of objective function evaluations = 5683 Number of objective gradient evaluations = 158 Number of equality constraint evaluations = 5684 Number of inequality constraint evaluations = 5684 Number of equality constraint Jacobian evaluations = 2454 Number of inequality constraint Jacobian evaluations = 2454 Number of Lagrangian Hessian evaluations = 0 Total CPU secs in IPOPT (w/o function evaluations) = 350.029 Total CPU secs in NLP function evaluations = 1497.321

EXIT: Converged to a point of local infeasibility. Problem may be infeasible. Index exceeds matrix dimensions. Error in postSolveAnalysis>estimateError (line 701) R(ii) = 0.5h(ii)(F(1,kk)+2*... Error in postSolveAnalysis (line 550) [Error, ErrorRelative,T_error]=estimateError(solution,p,t0,tf,n,m,f,M,ns,dataNLP); Error in runPostSolveTasks (line 22) [solution.phaseSol{i}]=postSolveAnalysis(problem.phases{i},solution.phaseSol{i},options.phaseoptions{i},data.phasedata{i}); Error in solveMyProblem (line 75) [solution] = runPostSolveTasks(problem,solution,options,data); % Output solutions Error in main_eLeg_ThreePhase (line 6) [solution,MRHistory]=solveMyProblem( problem,guess,options);

yuanbonie commented 4 years ago

In cases NLP solver do not terminate successfully, there is no guarantee that the solution can actually be postprocessed. I have changed the code just now to show a customized error message instead.

VishnuDevA7 commented 4 years ago

After yesterday's update whenever the EXIT statement from IPOPT is not "Optimal solution found", the solveMyProblem.m file throws an error.


Number of equality constraint evaluations = 777 Number of inequality constraint evaluations = 777 Number of equality constraint Jacobian evaluations = 375 Number of inequality constraint Jacobian evaluations = 375 Number of Lagrangian Hessian evaluations = 0 Total CPU secs in IPOPT (w/o function evaluations) = 962.518 Total CPU secs in NLP function evaluations = 367.589

EXIT: Solved To Acceptable Level. Error using solveMyProblem (line 31) Error encountered when post-processing the solution. Please ensure the NLP solve has been terminated successfully, and the error tolerances have been correctly configured Error in main_ThreePhase (line 5) [solution,MRHistory]=solveMyProblem( problem,guess,options);


I remember this error was thrown previously only when the EXIT statement was "Problem is infeasible". However, since yesterday's update when the EXIT statements are "Solved to Acceptable Level" or "Restoration Phase failed" , the same error is thrown. I also verified this by changing my local branch to the previous commit and this error is not reproduced.

yuanbonie commented 4 years ago

Hi Vishnu,

I think there is a change a few versions back to allow arbitary interfacing of phases, and that may cause some of the phase duration (tf-t0) to be pushed to zero thus leading to postpocessing issues. Before I am able to make an update to the postpocessing workflow to handle this, please add a boundary constraint to make sure tf-t0 for each phase is lower bounded by a small value, say 0.01.

I would guess this is the cause of the error you see, please give it a try and let me know :)

Cheers, Yuanbo

VishnuDevA7 commented 4 years ago

Hi, I already seem to have had them in the constraints :

blc_linear=[xf{1}(1:12)-x0{2}(1:12);xf{2}(1:12)-x0{3}(1:12);uf{1}(1:7)-u0{2}(1:7);uf{2}(1:7)-u0{3}(1:7);tf(1)-t0(2);tf(2)-t0(3)];

problem.mp.constraints.bll.linear=zeros(1,40); problem.mp.constraints.blu.linear=zeros(1,40); problem.mp.constraints.blTol.linear=1e-9*ones(1,40);

Is this fine ? Or should I change the tf-t0 constraint from 0 to 0.01 ?

VishnuDevA7 commented 4 years ago

Or do you mean within each phase, you want me too add this constraint "tf - t0" and test ?

yuanbonie commented 4 years ago

I mean the latter, i.e. inside each phase add constraint tf-t0>0.01, for example. This avoids case of tf-t0=0, where the postpocessing script can not handle currently.

VishnuDevA7 commented 4 years ago

Yes, I repeated the same problem with the constraints tf-t0 in every phase. IPOPT exists with EXIT : Restoration Phase failed but the error that came from solveMyProblem is not reproduced.

VishnuDevA7 commented 4 years ago

It seems that the problem is back once again! Just a small change in one bound constraint leads to this error reappearing. Any suggestions ?


Restoration phase is called at point that is almost feasible, with constraint violation 4.542702e-06. Abort.

Number of Iterations....: 562

                               (scaled)                 (unscaled)

Objective...............: -2.6075113426874220e-05 -5.4446168177349966e+02 Dual infeasibility......: 1.5355370325122260e-03 3.2062797252702763e+04 Constraint violation....: 3.2311758320142489e-08 1.1481898380775062e-01 Complementarity.........: 2.1550057917194211e-09 4.4997621233045612e-02 Overall NLP error.......: 2.0225301959153901e-04 3.2062797252702763e+04

Number of objective function evaluations = 2675 Number of objective gradient evaluations = 562 Number of equality constraint evaluations = 2675 Number of inequality constraint evaluations = 2675 Number of equality constraint Jacobian evaluations = 564 Number of inequality constraint Jacobian evaluations = 564 Number of Lagrangian Hessian evaluations = 0 Total CPU secs in IPOPT (w/o function evaluations) = 93.904 Total CPU secs in NLP function evaluations = 809.668

EXIT: Restoration Failed!

Error using solveMyProblem (line 31) Error encountered when post-processing the solution. Please ensure the NLP solve has been terminated successfully, and the error tolerances have been correctly configured Error in main_eLeg_ThreePhase (line 10) [solution,MRHistory]=solveMyProblem( problem,guess,options);

yuanbonie commented 4 years ago

Hi Vishnu,

Sorry for the late reply. Please update to the latest github version and let me know whether the postprocess will now run but with a warning on redundant phases.

Cheers, Yuanbo

VishnuDevA7 commented 4 years ago

Yes, the error is not reproduced anymore.