ImperialCollegeLondon / ICLOCS

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

Bug at Example BangBang Discrete #16

Closed adolfogra closed 3 years ago

adolfogra commented 3 years ago

During the execution of BangBang Discrete example was found a bug.

BUG

Error found at evaluation of path constraint function ( "g" function). It was due to, one of assignments is not protect.

Line 31 of g.m file

if strcmp(vdat.discretization,'euler') || strcmp(vdat.discretization,'discrete')
    c(end,:)=0;
end

If the "c" variable is empty, the assignment of c(end.:) = 0 will result an error in line describe above.

Suggestion of solution:

if strcmp(vdat.discretization,'euler') || strcmp(vdat.discretization,'discrete')
  if ~isempty(c) 
   c(end,:)=0;
  end
end

Matlab prompt message

Warning: Error encountered when evaluating const function

In directCollocation (line 253) In constraintFunction (line 42) In checkDynamics (line 29) In transcribeOCP_eachPhase (line 1600) In transcribeOCP (line 44) In solveMyProblem (line 323) In main_Bangbang (line 27) Output argument "solution" (and maybe others) not assigned during call to "directCollocation". Error in constraintFunction (line 42) constraints=directCollocation('const',z,data,1); Error in checkDynamics (line 29) constraintFunction(z0,data); Error in transcribeOCP_eachPhase (line 1600) data=checkDynamics( infoNLP.z0,data ); Error in transcribeOCP (line 44) [infoNLP,data,options]=transcribeOCP_eachPhase(problem,guess,options); Error in solveMyProblem (line 323) [infoNLP,data,options]=transcribeOCP(problem,guess,options); % Format for NLP solver Error in main_Bangbang (line 27) [solution,MRHistory]=solveMyProblem( problem,guess,options);

yuanbonie commented 3 years ago

Thank you! The change was integrated in the latest version.