Skip to content
This repository has been archived by the owner. It is now read-only.

Make sure _dynamic-file from block returns with proper arguments #1245

Open
JohannesPfeifer opened this issue Jun 27, 2016 · 6 comments

Comments

Projects
None yet
4 participants
@JohannesPfeifer
Copy link
Contributor

commented Jun 27, 2016

Currently, there are a few return statements where varargout has not been set, leading to crashes instead of proper switching to homotopy.

@houtanb

This comment has been minimized.

Copy link
Member

commented Nov 29, 2016

First draft fix in e410043. This should fix the bug, but leaving open so @FerhatMihoubi can confirm and close if he agrees.

@JohannesPfeifer

This comment has been minimized.

Copy link
Contributor Author

commented Nov 29, 2016

@houtanb I just recognize that there are two different output syntaxes.
In the if(length(varargin)>0) there is nothing to do, because we always have

varargout{1}=residual;
varargout{2}=dr;

The problem is in the other case where we would have

  oo_.endo_simul = y';
  varargout{1} = oo_;

Thus, the proper initialization would be
varargout{1} = oo_;

@houtanb

This comment has been minimized.

Copy link
Member

commented Nov 29, 2016

@JohannesPfeifer precisely. I thought we were creating a 3rd syntax to differentiate from these two. varargout{1} = NaN will be returned when one of the error conditions is satisfied and disp(['Inf or Nan value during the evaluation of block X']); is printed. You're saying that this difference is of no value?

@JohannesPfeifer

This comment has been minimized.

Copy link
Contributor Author

commented Nov 29, 2016

@houtanb Unfortunately not. The call in perfect_foresight_solver_core.m is
oo_ = feval([M_.fname '_dynamic'], options_, M_, oo_);
Therefore, if we output NaN, we simply overwrite oo_, which breaks all subsequent code. If I see it correctly, the subsequent code relies on
maxerror = oo_.deterministic_simulation.error;
Thus, we should preface the return statements by something like

oo_.deterministic_simulation.error=100;
varargout{1} = oo_;
@JohannesPfeifer

This comment has been minimized.

Copy link
Contributor Author

commented Nov 29, 2016

@houtanb Yes, but the varargin only refers to input arguments after the first three. Thus, this is a different syntax where oo_ is not requested as the output. In fact, the comment to the if-clause is %it is a simple evaluation of the dynamic model for time _it. In that case, the output is the residual, but it is always set. The problem only occurs when the desired output is oo_

@houtanb houtanb added this to the 4.5 milestone Mar 17, 2017

@JohannesPfeifer

This comment has been minimized.

Copy link
Contributor Author

commented Apr 3, 2017

Last status: @FerhatMihoubi needs to check whether the issue has been completely closed by 5f85d3a

@stepan-a stepan-a removed this from the 4.5 milestone Apr 21, 2017

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.