Merge remote-tracking branch 'dynare-preprocessor-github/master' into other-master
commit
a1437ac982
|
@ -0,0 +1,62 @@
|
|||
# For checking that no file has been unduly ignored, run:
|
||||
# $ git ls-files -i --exclude-per-directory=.gitignore
|
||||
# Any file that is displayed should be removed from the ignore list
|
||||
# (possibly by an exclusion rule beginning with an exclamation mark)
|
||||
|
||||
# Generic ignore rules
|
||||
*~
|
||||
*.o
|
||||
*.a
|
||||
*.fig
|
||||
\#*\#
|
||||
|
||||
# Build system rules
|
||||
.deps
|
||||
Makefile
|
||||
Makefile.in
|
||||
configure
|
||||
config.log
|
||||
config.status
|
||||
aclocal.m4
|
||||
autom4te.cache
|
||||
config.guess
|
||||
config.sub
|
||||
depcomp
|
||||
install-sh
|
||||
/missing
|
||||
/compile
|
||||
ylwrap
|
||||
ar-lib
|
||||
|
||||
# Preprocessor
|
||||
/src/dynare_m
|
||||
/src/dynare_m.exe
|
||||
/src/DynareBison.cc
|
||||
/src/DynareBison.hh
|
||||
/src/FlexLexer.h
|
||||
/src/DynareFlex.cc
|
||||
/src/location.hh
|
||||
/src/position.hh
|
||||
/src/stack.hh
|
||||
/src/macro/MacroBison.cc
|
||||
/src/macro/MacroBison.hh
|
||||
/src/macro/MacroFlex.cc
|
||||
/src/macro/location.hh
|
||||
/src/macro/position.hh
|
||||
/src/macro/stack.hh
|
||||
/src/doc/
|
||||
|
||||
# macOS stuff
|
||||
.DS_Store
|
||||
|
||||
# Doc rules
|
||||
*.pdf
|
||||
*.aux
|
||||
*.log
|
||||
*.nav
|
||||
*.out
|
||||
*.snm
|
||||
*.toc
|
||||
*.vrb
|
||||
!/doc/macroprocessor/new-design.pdf
|
||||
!/doc/macroprocessor/old-design.pdf
|
|
@ -0,0 +1,28 @@
|
|||
language: c++
|
||||
compiler: gcc
|
||||
dist: precise
|
||||
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libboost-graph-dev
|
||||
- doxygen
|
||||
- texlive
|
||||
- texlive-formats-extra
|
||||
- texlive-fonts-extra
|
||||
- lmodern
|
||||
- latex2html
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
|
||||
git:
|
||||
depth: false
|
||||
|
||||
script:
|
||||
- autoreconf -si
|
||||
- ./configure
|
||||
- make -j
|
||||
- make pdf -j
|
||||
- make html
|
|
@ -0,0 +1,674 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
98
Makefile.am
98
Makefile.am
|
@ -1,95 +1,11 @@
|
|||
SUBDIRS = macro
|
||||
SUBDIRS = src doc
|
||||
|
||||
BUILT_SOURCES = DynareBison.hh stack.hh position.hh location.hh DynareBison.cc DynareFlex.cc FlexLexer.h
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
matlabdir = $(pkglibdir)/matlab
|
||||
EXTRA_DIST = \
|
||||
license.txt \
|
||||
COPYING
|
||||
|
||||
matlab_PROGRAMS = dynare_m
|
||||
dist-hook:
|
||||
rm -rf `find $(distdir) -name '.git*'`
|
||||
|
||||
# We don't put BUILT_SOURCES in dynare_m_SOURCES, otherwise DynareBison.o and DynareFlex.o will be linked two times (Automake translates DynareFlex.ll and DynareBison.yy into their respective .o); so BUILT_SOURCES is in EXTRA_DIST
|
||||
dynare_m_SOURCES = \
|
||||
DynareFlex.ll \
|
||||
DynareBison.yy \
|
||||
ComputingTasks.cc \
|
||||
ComputingTasks.hh \
|
||||
ModelTree.cc \
|
||||
ModelTree.hh \
|
||||
StaticModel.cc \
|
||||
StaticModel.hh \
|
||||
DynamicModel.cc \
|
||||
DynamicModel.hh \
|
||||
NumericalConstants.cc \
|
||||
NumericalConstants.hh \
|
||||
NumericalInitialization.cc \
|
||||
NumericalInitialization.hh \
|
||||
Shocks.cc \
|
||||
Shocks.hh \
|
||||
SigmaeInitialization.cc \
|
||||
SigmaeInitialization.hh \
|
||||
SymbolTable.cc \
|
||||
SymbolTable.hh \
|
||||
SymbolList.cc \
|
||||
SymbolList.hh \
|
||||
ParsingDriver.cc \
|
||||
ParsingDriver.hh \
|
||||
DataTree.cc \
|
||||
DataTree.hh \
|
||||
ModFile.cc \
|
||||
ModFile.hh \
|
||||
ConfigFile.cc \
|
||||
ConfigFile.hh \
|
||||
Statement.cc \
|
||||
Statement.hh \
|
||||
ExprNode.cc \
|
||||
ExprNode.hh \
|
||||
MinimumFeedbackSet.cc \
|
||||
MinimumFeedbackSet.hh \
|
||||
DynareMain.cc \
|
||||
DynareMain1.cc \
|
||||
DynareMain2.cc \
|
||||
CodeInterpreter.hh \
|
||||
ExternalFunctionsTable.cc \
|
||||
ExternalFunctionsTable.hh \
|
||||
SteadyStateModel.hh \
|
||||
SteadyStateModel.cc \
|
||||
WarningConsolidation.hh \
|
||||
WarningConsolidation.cc \
|
||||
ExtendedPreprocessorTypes.hh
|
||||
|
||||
|
||||
# The -I. is for <FlexLexer.h>
|
||||
dynare_m_CPPFLAGS = $(BOOST_CPPFLAGS) -I.
|
||||
dynare_m_LDFLAGS = $(BOOST_LDFLAGS)
|
||||
dynare_m_LDADD = macro/libmacro.a
|
||||
|
||||
DynareFlex.cc FlexLexer.h: DynareFlex.ll
|
||||
$(LEX) -o DynareFlex.cc DynareFlex.ll
|
||||
cp $(LEXINC)/FlexLexer.h . || test -f ./FlexLexer.h
|
||||
|
||||
DynareBison.cc DynareBison.hh location.hh stack.hh position.hh: DynareBison.yy
|
||||
$(YACC) -o DynareBison.cc DynareBison.yy
|
||||
|
||||
all-local: $(PROGRAMS)
|
||||
if [ -z "`file $(PROGRAMS) | grep x86.64`" ]; then \
|
||||
ARCH="32"; \
|
||||
else \
|
||||
ARCH="64"; \
|
||||
fi; \
|
||||
mkdir -p ../matlab/preprocessor$$ARCH ; \
|
||||
cd ../matlab/preprocessor$$ARCH && $(LN_S) -f $(abs_srcdir)/$(PROGRAMS) $(PROGRAMS) ; \
|
||||
mkdir -p ../../julia/preprocessor$$ARCH ; \
|
||||
cd ../../julia/preprocessor$$ARCH && $(LN_S) -f $(abs_srcdir)/$(PROGRAMS) $(PROGRAMS)
|
||||
|
||||
if HAVE_DOXYGEN
|
||||
html-local:
|
||||
$(DOXYGEN)
|
||||
endif
|
||||
|
||||
clean-local:
|
||||
rm -rf ../matlab/preprocessor* ../julia/preprocessor*
|
||||
rm -rf doc/html/
|
||||
|
||||
EXTRA_DIST = $(BUILT_SOURCES) Doxyfile
|
||||
|
||||
install-exec-local:
|
||||
$(MKDIR_P) $(DESTDIR)$(pkglibdir)/matlab
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
<a name="logo"/>
|
||||
<div align="center">
|
||||
<a href="http://www.dynare.org/" target="_blank">
|
||||
<img src="http://www.dynare.org/img/dynare.png" alt="Dynare Logo"></img>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
[![Build Status](https://travis-ci.org/DynareTeam/dynare-preprocessor.svg?branch=master)](https://travis-ci.org/DynareTeam/dynare-preprocessor)
|
||||
|
||||
# Dynare Preprocessor
|
||||
|
||||
The Dynare Preprocessor defines the Dynare model language. It takes in a `.mod`
|
||||
file, computes the derivatives of the model represented therein, and produces
|
||||
Matlab/Octave, C, Julia, or JSON output.
|
||||
|
||||
There is more to come here. For the moment, see the [Dynare
|
||||
repository](https://github.com/DynareTeam/dynare)
|
||||
|
||||
# License
|
||||
|
||||
Most of the source files are covered by the GNU General Public Licence version
|
||||
3 or later. There are some exceptions. See [license.txt](license.txt) for specifics.
|
|
@ -0,0 +1,130 @@
|
|||
dnl Process this file with autoconf to produce a configure script.
|
||||
|
||||
dnl Copyright (C) 2009-2018 Dynare Team
|
||||
dnl
|
||||
dnl This file is part of Dynare.
|
||||
dnl
|
||||
dnl Dynare is free software: you can redistribute it and/or modify
|
||||
dnl it under the terms of the GNU General Public License as published by
|
||||
dnl the Free Software Foundation, either version 3 of the License, or
|
||||
dnl (at your option) any later version.
|
||||
dnl
|
||||
dnl Dynare is distributed in the hope that it will be useful,
|
||||
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
dnl GNU General Public License for more details.
|
||||
dnl
|
||||
dnl You should have received a copy of the GNU General Public License
|
||||
dnl along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
AC_PREREQ([2.62])
|
||||
AC_INIT([dynare-preprocessor], [1.0-unstable])
|
||||
AC_CONFIG_SRCDIR([src/DynareMain.cc])
|
||||
AM_INIT_AUTOMAKE([1.11 -Wall -Wno-portability foreign no-dist-gzip dist-xz tar-pax])
|
||||
|
||||
AC_PROG_CC
|
||||
AC_PROG_CXX
|
||||
|
||||
AC_CANONICAL_HOST
|
||||
case ${host_os} in
|
||||
*mingw32*)
|
||||
# On mingw32, we don't want dynamic libgcc
|
||||
# Note that static-libstdc++ is only supported since GCC 4.5 (but generates no error on older versions)
|
||||
LDFLAGS="$LDFLAGS -static-libgcc -static-libstdc++ -static-libgfortran"
|
||||
have_windows="yes"
|
||||
;;
|
||||
*cygwin*)
|
||||
AC_MSG_WARN([You are compiling for the Cygwin target. This means that the preprocessor will])
|
||||
AC_MSG_WARN([not run from MATLAB unless you add the Cygwin DLL to the path.])
|
||||
AC_MSG_WARN([This is probably not what you want. Consider using a MinGW cross-compiler.])
|
||||
have_windows="yes"
|
||||
;;
|
||||
esac
|
||||
|
||||
# Use C++ for testing headers
|
||||
AC_LANG([C++])
|
||||
|
||||
CXXFLAGS="$CXXFLAGS -Wall -Wno-parentheses"
|
||||
|
||||
# If default 'ar' is not available, try to find one with a host prefix (see ticket #145)
|
||||
AC_CHECK_PROGS([AR], [ar ${host_alias}-ar])
|
||||
|
||||
AC_PROG_RANLIB
|
||||
AM_PROG_AR
|
||||
|
||||
AM_PROG_LEX
|
||||
# Hack to get lex include dir, ticket #575
|
||||
AC_PATH_PROG([LEXPATH], [$LEX])
|
||||
AC_SUBST([LEXINC], [`eval "echo $LEXPATH | sed 's|\(.*\)$LEX$|\1../include|'"`])
|
||||
|
||||
AC_CHECK_PROG([YACC], [bison], [bison])
|
||||
if test "x$YACC" = "x"; then
|
||||
unset YACC # AM_MISSING_PROG needs an unset variable: an empty variable won't do
|
||||
AM_MISSING_PROG([YACC], [bison])
|
||||
fi
|
||||
|
||||
# We need 1.36 because of unordered_{set,hash} used by Dynare++
|
||||
AX_BOOST_BASE([1.36], [], [AC_MSG_ERROR([Can't find Boost >= 1.36])])
|
||||
|
||||
CPPFLAGS_SAVED="$CPPFLAGS"
|
||||
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
|
||||
AC_CHECK_HEADERS([boost/graph/adjacency_list.hpp], [], [AC_MSG_ERROR([Can't find Boost Graph Library])])
|
||||
AC_CHECK_HEADERS([boost/algorithm/string/trim.hpp], [], [AC_MSG_ERROR([Can't find Boost String Library])])
|
||||
AC_CHECK_HEADERS([boost/algorithm/string/split.hpp], [], [AC_MSG_ERROR([Can't find Boost String Library])])
|
||||
AC_CHECK_HEADERS([boost/lexical_cast.hpp], [], [AC_MSG_ERROR([Can't find Boost Lexical Cast Header])])
|
||||
CPPFLAGS="$CPPFLAGS_SAVED"
|
||||
|
||||
# Don't use deprecated hash structures
|
||||
AC_DEFINE([BOOST_NO_HASH], [], [Don't use deprecated STL hash structures])
|
||||
|
||||
AC_CHECK_PROG([DOXYGEN], [doxygen], [doxygen])
|
||||
AM_CONDITIONAL([HAVE_DOXYGEN], [test "x$DOXYGEN" != "x"])
|
||||
|
||||
AC_CHECK_PROG([PDFLATEX], [pdflatex], [pdflatex])
|
||||
AM_CONDITIONAL([HAVE_PDFLATEX], [test "x$PDFLATEX" != "x"])
|
||||
|
||||
AC_CHECK_PROG([BIBTEX], [bibtex], [bibtex])
|
||||
AM_CONDITIONAL([HAVE_BIBTEX], [test "x$BIBTEX" != "x"])
|
||||
|
||||
if test "x$PDFLATEX" != "x" -a "x$BIBTEX" != "x"; then
|
||||
AX_LATEX_CLASS([beamer], [ax_latex_have_beamer])
|
||||
fi
|
||||
AM_CONDITIONAL([HAVE_BEAMER], [test "x$ax_latex_have_beamer" = "xyes"])
|
||||
|
||||
AC_CONFIG_FILES([Makefile
|
||||
src/Makefile
|
||||
src/macro/Makefile
|
||||
doc/Makefile
|
||||
doc/preprocessor/Makefile
|
||||
doc/macroprocessor/Makefile
|
||||
])
|
||||
|
||||
if test "x$DOXYGEN" != "x"; then
|
||||
BUILD_DYNARE_PREPROC_DOC="yes"
|
||||
else
|
||||
BUILD_DYNARE_PREPROC_DOC="no (missing doxygen)"
|
||||
fi
|
||||
|
||||
|
||||
if test "x$PDFLATEX" != "x" -a "x$ax_latex_have_beamer" = "xyes"; then
|
||||
BUILD_BEAMER_DOC="yes"
|
||||
else
|
||||
BUILD_BEAMER_DOC="no (missing one of: pdflatex, beamer)"
|
||||
fi
|
||||
|
||||
AC_MSG_NOTICE([
|
||||
|
||||
The Dynare Preprocessor is now configured to build...
|
||||
|
||||
Binaries (with "make")
|
||||
Dynare preprocessor: yes
|
||||
|
||||
PDF documentation (with "make pdf"):
|
||||
Preprocessor & Macroprocessor presentations: $BUILD_BEAMER_DOC
|
||||
|
||||
HTML documentation (with "make html"):
|
||||
Dynare preprocessor developer doc: $BUILD_DYNARE_PREPROC_DOC
|
||||
|
||||
])
|
||||
|
||||
AC_OUTPUT
|
|
@ -0,0 +1,5 @@
|
|||
SUBDIRS = preprocessor macroprocessor
|
||||
|
||||
PDF_TARGETS =
|
||||
|
||||
pdf-local: $(PDF_TARGETS)
|
|
@ -0,0 +1,16 @@
|
|||
if HAVE_PDFLATEX
|
||||
if HAVE_BEAMER
|
||||
pdf-local: macroprocessor.pdf
|
||||
endif
|
||||
endif
|
||||
|
||||
SRC = macroprocessor.tex new-design.pdf
|
||||
|
||||
EXTRA_DIST = $(SRC)
|
||||
|
||||
macroprocessor.pdf: $(SRC)
|
||||
$(PDFLATEX) macroprocessor
|
||||
$(PDFLATEX) macroprocessor
|
||||
|
||||
clean-local:
|
||||
rm -f macroprocessor.pdf *.toc *.aux *.log *.nav *.snm *.vrb *.out *~
|
|
@ -0,0 +1,624 @@
|
|||
\documentclass{beamer}
|
||||
\usepackage[utf8]{inputenc}
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage{lmodern}
|
||||
\usepackage{amsmath}
|
||||
\usepackage[copyright]{ccicons}
|
||||
|
||||
\usetheme{Boadilla}
|
||||
|
||||
\title{The Dynare Macro-processor}
|
||||
\subtitle{Dynare Summer School 2017}
|
||||
\author{Sébastien Villemot}
|
||||
%\pgfdeclareimage[height=0.6cm]{logo}{logo-ofce}
|
||||
\institute{OFCE}
|
||||
\date{June 13, 2017}
|
||||
|
||||
\AtBeginSection[]
|
||||
{
|
||||
\begin{frame}
|
||||
\frametitle{Outline}
|
||||
\tableofcontents[currentsection]
|
||||
\end{frame}
|
||||
}
|
||||
|
||||
\begin{document}
|
||||
|
||||
\begin{frame}
|
||||
\titlepage
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{Outline}
|
||||
\tableofcontents
|
||||
\end{frame}
|
||||
|
||||
\section{Overview}
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{Motivation}
|
||||
\begin{itemize}
|
||||
\item The \textbf{Dynare language} (used in MOD files) is well suited for many economic models
|
||||
\item However, as such, it lacks some useful features, such as:
|
||||
\begin{itemize}
|
||||
\item a loop mechanism for automatically repeating similar blocks of equations (such as in multi-country models)
|
||||
\item an operator for indexed sums or products inside equations
|
||||
\item a mechanism for splitting large MOD files in smaller modular files
|
||||
\item the possibility of conditionally including some equations or some runtime commands
|
||||
\end{itemize}
|
||||
\item The \textbf{Dynare Macro-language} was specifically designed to address these issues
|
||||
\item Being flexible and fairly general, it can also be helpful in other situations
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{Design of the macro-language}
|
||||
\begin{itemize}
|
||||
\item The Dynare Macro-language provides a new set of \textbf{macro-commands} which can be inserted inside MOD files
|
||||
\item Language features include:
|
||||
\begin{itemize}
|
||||
\item file inclusion
|
||||
\item loops (\textit{for} structure)
|
||||
\item conditional inclusion (\textit{if/else} structures)
|
||||
\item expression substitution
|
||||
\end{itemize}
|
||||
\item The macro-processor transforms a MOD file with macro-commands into a MOD file without macro-commands (doing text expansions/inclusions) and then feeds it to the Dynare parser
|
||||
\item The key point to understand is that the macro-processor only does \textbf{text substitution} (like the C preprocessor or the PHP language)
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{Design of Dynare}
|
||||
\includegraphics[width=0.95\linewidth]{new-design.pdf}
|
||||
\end{frame}
|
||||
|
||||
\section{Syntax}
|
||||
|
||||
\begin{frame}[fragile=singleslide]
|
||||
\frametitle{Macro Directives}
|
||||
\begin{itemize}
|
||||
\item Directives begin with an at-sign followed by a pound sign (\verb+@#+)
|
||||
\item A directive produces no output, but gives instructions to the macro-processor
|
||||
\item Main directives are:
|
||||
\begin{itemize}
|
||||
\item file inclusion: \verb+@#include+
|
||||
\item definition a variable of the macro-processor: \verb+@#define+
|
||||
\item conditional statements (\verb+@#if/@#ifdef/@#ifndef/@#else/@#endif+)
|
||||
\item loop statements (\verb+@#for/@#endfor+)
|
||||
\end{itemize}
|
||||
\item In most cases, directives occupy exactly one line of text. In case of need, two anti-slashes (\verb+\\+) at the end of the line indicates that the directive is continued on the next line.
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{Variables}
|
||||
\begin{itemize}
|
||||
\item The macro processor maintains its own list of variables (distinct of model variables and of MATLAB/Octave variables)
|
||||
\item Macro-variables can be of four types:
|
||||
\begin{itemize}
|
||||
\item integer
|
||||
\item character string (declared between \textit{double} quotes)
|
||||
\item array of integers
|
||||
\item array of strings
|
||||
\end{itemize}
|
||||
\item No boolean type:
|
||||
\begin{itemize}
|
||||
\item false is represented by integer zero
|
||||
\item true is any non-null integer
|
||||
\end{itemize}
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}[fragile=singleslide]
|
||||
\frametitle{Macro-expressions (1/2)}
|
||||
It is possible to construct macro-expressions, using standard operators.
|
||||
\begin{block}{Operators on integers}
|
||||
\begin{itemize}
|
||||
\item arithmetic operators: \texttt{+ - * /}
|
||||
\item comparison operators: \texttt{< > <= >= == !=}
|
||||
\item logical operators: \verb+&& || !+
|
||||
\item integer ranges: \texttt{1:4} is equivalent to integer array \texttt{[1,2,3,4]}
|
||||
\end{itemize}
|
||||
\end{block}
|
||||
|
||||
\begin{block}{Operators on character strings}
|
||||
\begin{itemize}
|
||||
\item comparison operators: \texttt{== !=}
|
||||
\item concatenation: \texttt{+}
|
||||
\item extraction of substrings: if \texttt{s} is a string, then one can write \texttt{s[3]} or \texttt{s[4:6]}
|
||||
\end{itemize}
|
||||
\end{block}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}[fragile=singleslide]
|
||||
\frametitle{Macro-expressions (2/2)}
|
||||
\begin{block}{Operators on arrays}
|
||||
\begin{itemize}
|
||||
\item dereferencing: if \texttt{v} is an array, then \texttt{v[2]} is its $2^{\textrm{nd}}$ element
|
||||
\item concatenation: \texttt{+}
|
||||
\item difference \texttt{-}: returns the first operand from which the elements of the second operand have been removed
|
||||
\item extraction of sub-arrays: \textit{e.g.} \texttt{v[4:6]}
|
||||
\item testing membership of an array: \texttt{in} operator \\ (example:
|
||||
\texttt{"b" in ["a", "b", "c"]} returns \texttt{1})
|
||||
\end{itemize}
|
||||
\end{block}
|
||||
|
||||
Macro-expressions can be used at two places:
|
||||
\begin{itemize}
|
||||
\item inside macro directives, directly
|
||||
\item in the body of the MOD file, between an at-sign and curly braces (like \verb+@{expr}+): the macro processor will substitute the expression with its value
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}[fragile=singleslide]
|
||||
\frametitle{Define directive}
|
||||
|
||||
The value of a macro-variable can be defined with the \verb+@#define+ directive.
|
||||
|
||||
\begin{block}{Syntax}
|
||||
\verb+@#define +\textit{variable\_name}\verb+ = +\textit{expression}
|
||||
\end{block}
|
||||
|
||||
\begin{block}{Examples}
|
||||
\begin{verbatim}
|
||||
@#define x = 5 // Integer
|
||||
@#define y = "US" // String
|
||||
@#define v = [ 1, 2, 4 ] // Integer array
|
||||
@#define w = [ "US", "EA" ] // String array
|
||||
@#define z = 3 + v[2] // Equals 5
|
||||
@#define t = ("US" in w) // Equals 1 (true)
|
||||
\end{verbatim}
|
||||
\end{block}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}[fragile=singleslide]
|
||||
\frametitle{Expression substitution}
|
||||
\framesubtitle{Dummy example}
|
||||
\begin{block}{Before macro-processing}
|
||||
\begin{verbatim}
|
||||
@#define x = [ "B", "C" ]
|
||||
@#define i = 2
|
||||
|
||||
model;
|
||||
A = @{x[i]};
|
||||
end;
|
||||
\end{verbatim}
|
||||
\end{block}
|
||||
\begin{block}{After macro-processing}
|
||||
\begin{verbatim}
|
||||
model;
|
||||
A = C;
|
||||
end;
|
||||
\end{verbatim}
|
||||
\end{block}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}[fragile=singleslide]
|
||||
\frametitle{Inclusion directive (1/2)}
|
||||
\begin{itemize}
|
||||
\item This directive simply includes the content of another file at the place where it is inserted.
|
||||
\begin{block}{Syntax}
|
||||
\verb+@#include "+\textit{filename}\verb+"+
|
||||
\end{block}
|
||||
\begin{block}{Example}
|
||||
\begin{verbatim}
|
||||
@#include "modelcomponent.mod"
|
||||
\end{verbatim}
|
||||
\end{block}
|
||||
\item Exactly equivalent to a copy/paste of the content of the included file
|
||||
\item Note that it is possible to nest includes (\textit{i.e.} to include a
|
||||
file from an included file)
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}[fragile=singleslide]
|
||||
\frametitle{Inclusion directive (2/2)}
|
||||
\begin{itemize}
|
||||
\item The filename can be given by a macro-variable (useful in loops):
|
||||
\begin{block}{Example with variable}
|
||||
\begin{verbatim}
|
||||
@#define fname = "modelcomponent.mod"
|
||||
@#include fname
|
||||
\end{verbatim}
|
||||
\end{block}
|
||||
\item Files to include are searched for in current directory. Other directories can
|
||||
be added with
|
||||
\texttt{@includepath} directive, \texttt{-I} command line option or
|
||||
\texttt{[paths]} section in config file.
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}[fragile=singleslide]
|
||||
\frametitle{Loop directive}
|
||||
\begin{block}{Syntax}
|
||||
\verb+@#for +\textit{variable\_name}\verb+ in +\textit{array\_expr} \\
|
||||
\verb+ +\textit{loop\_body} \\
|
||||
\verb+@#endfor+
|
||||
\end{block}
|
||||
\begin{block}{Example: before macro-processing}
|
||||
\small
|
||||
\begin{verbatim}
|
||||
model;
|
||||
@#for country in [ "home", "foreign" ]
|
||||
GDP_@{country} = A * K_@{country}^a * L_@{country}^(1-a);
|
||||
@#endfor
|
||||
end;
|
||||
\end{verbatim}
|
||||
\normalsize
|
||||
\end{block}
|
||||
|
||||
\begin{block}{Example: after macro-processing}
|
||||
\small
|
||||
\begin{verbatim}
|
||||
model;
|
||||
GDP_home = A * K_home^a * L_home^(1-a);
|
||||
GDP_foreign = A * K_foreign^a * L_foreign^(1-a);
|
||||
end;
|
||||
\end{verbatim}
|
||||
\normalsize
|
||||
\end{block}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}[fragile=singleslide]
|
||||
\frametitle{Conditional inclusion directives (1/2)}
|
||||
|
||||
\begin{columns}[T]
|
||||
\column{0.47\linewidth}
|
||||
\begin{block}{Syntax 1}
|
||||
\verb+@#if +\textit{integer\_expr} \\
|
||||
\verb+ +\textit{body included if expr != 0} \\
|
||||
\verb+@#endif+
|
||||
\end{block}
|
||||
|
||||
\column{0.47\linewidth}
|
||||
\begin{block}{Syntax 2}
|
||||
\verb+@#if +\textit{integer\_expr} \\
|
||||
\verb+ +\textit{body included if expr != 0} \\
|
||||
\verb+@#else+ \\
|
||||
\verb+ +\textit{body included if expr == 0} \\
|
||||
\verb+@#endif+
|
||||
\end{block}
|
||||
\end{columns}
|
||||
|
||||
\begin{block}{Example: alternative monetary policy rules}
|
||||
\scriptsize
|
||||
\begin{verbatim}
|
||||
@#define linear_mon_pol = 0 // or 1
|
||||
...
|
||||
model;
|
||||
@#if linear_mon_pol
|
||||
i = w*i(-1) + (1-w)*i_ss + w2*(pie-piestar);
|
||||
@#else
|
||||
i = i(-1)^w * i_ss^(1-w) * (pie/piestar)^w2;
|
||||
@#endif
|
||||
...
|
||||
end;
|
||||
\end{verbatim}
|
||||
\scriptsize
|
||||
\end{block}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}[fragile=singleslide]
|
||||
\frametitle{Conditional inclusion directives (2/2)}
|
||||
|
||||
\begin{columns}[T]
|
||||
\column{0.47\linewidth}
|
||||
\begin{block}{Syntax 1}
|
||||
\verb+@#ifdef +\textit{variable\_name} \\
|
||||
\verb+ +\textit{body included if variable defined} \\
|
||||
\verb+@#endif+
|
||||
\end{block}
|
||||
|
||||
\column{0.47\linewidth}
|
||||
\begin{block}{Syntax 2}
|
||||
\verb+@#ifdef +\textit{variable\_name} \\
|
||||
\verb+ +\textit{body included if variable defined} \\
|
||||
\verb+@#else+ \\
|
||||
\verb+ +\textit{body included if variable not defined} \\
|
||||
\verb+@#endif+
|
||||
\end{block}
|
||||
\end{columns}
|
||||
|
||||
\bigskip
|
||||
|
||||
There is also \verb+@#ifndef+, which is the opposite of \verb+@#ifdef+
|
||||
(\textit{i.e.} it tests whether a variable is \emph{not} defined).
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}[fragile=singleslide]
|
||||
\frametitle{Echo and error directives}
|
||||
|
||||
\begin{itemize}
|
||||
\item The echo directive will simply display a message on standard output
|
||||
\item The error directive will display the message and make Dynare stop (only makes sense inside a conditional inclusion directive)
|
||||
\end{itemize}
|
||||
|
||||
\begin{block}{Syntax}
|
||||
\verb+@#echo +\textit{string\_expr} \\
|
||||
\verb+@#error +\textit{string\_expr}
|
||||
\end{block}
|
||||
|
||||
\begin{block}{Examples}
|
||||
\begin{verbatim}
|
||||
@#echo "Information message."
|
||||
@#error "Error message!"
|
||||
\end{verbatim}
|
||||
\end{block}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{Saving the macro-expanded MOD file}
|
||||
\begin{itemize}
|
||||
\item For \textbf{debugging or learning} purposes, it is possible to save the output of the macro-processor
|
||||
\item This output is a valid MOD file, obtained after processing the macro-commands of the original MOD file
|
||||
% \item Useful to understand how the macro-processor works
|
||||
\item Just add the \texttt{savemacro} option on the Dynare command line (after the name of your MOD file)
|
||||
\item If MOD file is \texttt{filename.mod}, then the macro-expanded version will be saved in \texttt{filename-macroexp.mod}
|
||||
\item You can specify the filename for the macro-expanded version with the syntax \texttt{savemacro=mymacroexp.mod}
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
% \begin{frame}
|
||||
% \frametitle{Note on error messages}
|
||||
% \end{frame}
|
||||
|
||||
\section{Typical usages}
|
||||
|
||||
\begin{frame}[fragile=singleslide]
|
||||
\frametitle{Modularization}
|
||||
\begin{itemize}
|
||||
\item The \verb+@#include+ directive can be used to split MOD files into several modular components
|
||||
\item Example setup:
|
||||
\begin{description}
|
||||
\item[\texttt{modeldesc.mod}:] contains variable declarations, model equations and shocks declarations
|
||||
\item[\texttt{simulate.mod}:] includes \texttt{modeldesc.mod}, calibrates parameters and runs stochastic simulations
|
||||
\item[\texttt{estim.mod}:] includes \texttt{modeldesc.mod}, declares priors on parameters and runs bayesian estimation
|
||||
\end{description}
|
||||
\item Dynare can be called on \texttt{simulate.mod} and \texttt{estim.mod}
|
||||
\item But it makes no sense to run it on \texttt{modeldesc.mod}
|
||||
\item Advantage: no need to manually copy/paste the whole model (at the beginning) or changes to the model (during development)
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}[fragile=singleslide]
|
||||
\frametitle{Indexed sums or products}
|
||||
\framesubtitle{Example: moving average}
|
||||
\begin{columns}[T]
|
||||
\column{0.47\linewidth}
|
||||
\begin{block}{Before macro-processing}
|
||||
\begin{verbatim}
|
||||
@#define window = 2
|
||||
|
||||
var x MA_x;
|
||||
...
|
||||
model;
|
||||
...
|
||||
MA_x = 1/@{2*window+1}*(
|
||||
@#for i in -window:window
|
||||
+x(@{i})
|
||||
@#endfor
|
||||
);
|
||||
...
|
||||
end;
|
||||
\end{verbatim}
|
||||
\end{block}
|
||||
\column{0.47\linewidth}
|
||||
\begin{block}{After macro-processing}
|
||||
\begin{verbatim}
|
||||
var x MA_x;
|
||||
...
|
||||
model;
|
||||
...
|
||||
MA_x = 1/5*(
|
||||
+x(-2)
|
||||
+x(-1)
|
||||
+x(0)
|
||||
+x(1)
|
||||
+x(2)
|
||||
);
|
||||
...
|
||||
end;
|
||||
\end{verbatim}
|
||||
\end{block}
|
||||
\end{columns}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}[fragile=singleslide]
|
||||
\frametitle{Multi-country models}
|
||||
\framesubtitle{MOD file skeleton example}
|
||||
\scriptsize
|
||||
\begin{verbatim}
|
||||
@#define countries = [ "US", "EA", "AS", "JP", "RC" ]
|
||||
@#define nth_co = "US"
|
||||
|
||||
@#for co in countries
|
||||
var Y_@{co} K_@{co} L_@{co} i_@{co} E_@{co} ...;
|
||||
parameters a_@{co} ...;
|
||||
varexo ...;
|
||||
@#endfor
|
||||
|
||||
model;
|
||||
@#for co in countries
|
||||
Y_@{co} = K_@{co}^a_@{co} * L_@{co}^(1-a_@{co});
|
||||
...
|
||||
@# if co != nth_co
|
||||
(1+i_@{co}) = (1+i_@{nth_co}) * E_@{co}(+1) / E_@{co}; // UIP relation
|
||||
@# else
|
||||
E_@{co} = 1;
|
||||
@# endif
|
||||
@#endfor
|
||||
end;
|
||||
\end{verbatim}
|
||||
\normalsize
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{Endogeneizing parameters (1/4)}
|
||||
\begin{itemize}
|
||||
\item When doing the steady-state calibration of the model, it may be useful to consider a parameter as an endogenous (and vice-versa)
|
||||
\item Example:
|
||||
\begin{gather*}
|
||||
y = \left(\alpha^{\frac{1}{\xi}} \ell^{1-\frac{1}{\xi}} + (1-\alpha)^{\frac{1}{\xi}}k^{1-\frac{1}{\xi}}\right)^{\frac{\xi}{\xi - 1}} \\
|
||||
lab\_rat = \frac{w \ell}{p y}
|
||||
\end{gather*}
|
||||
\item In the model, $\alpha$ is a (share) parameter, and $lab\_rat$ is an endogenous variable
|
||||
\item We observe that:
|
||||
\begin{itemize}
|
||||
\item calibrating $\alpha$ is not straigthforward!
|
||||
\item on the contrary, we have real world data for $lab\_rat$
|
||||
\item it is clear that these two variables are economically linked
|
||||
\end{itemize}
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}[fragile=singleslide]
|
||||
\frametitle{Endogeneizing parameters (2/4)}
|
||||
\begin{itemize}
|
||||
\item Therefore, when computing the steady state:
|
||||
\begin{itemize}
|
||||
\item we make $\alpha$ an endogenous variable and $lab\_rat$ a parameter
|
||||
\item we impose an economically relevant value for $lab\_rat$
|
||||
\item the solution algorithm deduces the implied value for $\alpha$
|
||||
\end{itemize}
|
||||
\item We call this method ``variable flipping''
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}[fragile=singleslide]
|
||||
\frametitle{Endogeneizing parameters (3/4)}
|
||||
\framesubtitle{Example implementation}
|
||||
\begin{itemize}
|
||||
\item File \texttt{modeqs.mod}:
|
||||
\begin{itemize}
|
||||
\item contains variable declarations and model equations
|
||||
\item For declaration of \texttt{alpha} and \texttt{lab\_rat}:
|
||||
\footnotesize
|
||||
\begin{verbatim}
|
||||
@#if steady
|
||||
var alpha;
|
||||
parameter lab_rat;
|
||||
@#else
|
||||
parameter alpha;
|
||||
var lab_rat;
|
||||
@#endif
|
||||
\end{verbatim}
|
||||
\normalsize
|
||||
\end{itemize}
|
||||
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}[fragile=singleslide]
|
||||
\frametitle{Endogeneizing parameters (4/4)}
|
||||
\framesubtitle{Example implementation}
|
||||
\begin{itemize}
|
||||
\item File \texttt{steadystate.mod}:
|
||||
\begin{itemize}
|
||||
\item begins with \verb+@#define steady = 1+
|
||||
\item then with \verb+@#include "modeqs.mod"+
|
||||
\item initializes parameters (including \texttt{lab\_rat}, excluding \texttt{alpha})
|
||||
\item computes steady state (using guess values for endogenous, including \texttt{alpha})
|
||||
\item saves values of parameters and endogenous at steady-state in a file, using the \texttt{save\_params\_and\_steady\_state} command
|
||||
\end{itemize}
|
||||
\item File \texttt{simulate.mod}:
|
||||
\begin{itemize}
|
||||
\item begins with \verb+@#define steady = 0+
|
||||
\item then with \verb+@#include "modeqs.mod"+
|
||||
\item loads values of parameters and endogenous at steady-state from file, using the \texttt{load\_params\_and\_steady\_state} command
|
||||
\item computes simulations
|
||||
\end{itemize}
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}[fragile=singleslide]
|
||||
\frametitle{MATLAB/Octave loops vs macro-processor loops (1/3)}
|
||||
Suppose you have a model with a parameter $\rho$, and you want to make
|
||||
simulations for three values: $\rho = 0.8, 0.9, 1$. There are
|
||||
several ways of doing this:
|
||||
\begin{block}{With a MATLAB/Octave loop}
|
||||
\begin{verbatim}
|
||||
rhos = [ 0.8, 0.9, 1];
|
||||
for i = 1:length(rhos)
|
||||
rho = rhos(i);
|
||||
stoch_simul(order=1);
|
||||
end
|
||||
\end{verbatim}
|
||||
\end{block}
|
||||
\begin{itemize}
|
||||
\item The loop is not unrolled
|
||||
\item MATLAB/Octave manages the iterations
|
||||
\item Interesting when there are a lot of iterations
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}[fragile=singleslide]
|
||||
\frametitle{MATLAB/Octave loops vs macro-processor loops (2/3)}
|
||||
\begin{block}{With a macro-processor loop (case 1)}
|
||||
\begin{verbatim}
|
||||
rhos = [ 0.8, 0.9, 1];
|
||||
@#for i in 1:3
|
||||
rho = rhos(@{i});
|
||||
stoch_simul(order=1);
|
||||
@#endfor
|
||||
\end{verbatim}
|
||||
\end{block}
|
||||
\begin{itemize}
|
||||
\item Very similar to previous example
|
||||
\item Loop is unrolled
|
||||
\item Dynare macro-processor manages the loop index but not the data array (\texttt{rhos})
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}[fragile=singleslide]
|
||||
\frametitle{MATLAB/Octave loops vs macro-processor loops (3/3)}
|
||||
\begin{block}{With a macro-processor loop (case 2)}
|
||||
\begin{verbatim}
|
||||
@#for rho_val in [ "0.8", "0.9", "1"]
|
||||
rho = @{rho_val};
|
||||
stoch_simul(order=1);
|
||||
@#endfor
|
||||
\end{verbatim}
|
||||
\end{block}
|
||||
\begin{itemize}
|
||||
\item Advantage: shorter syntax, since list of values directly given in the loop construct
|
||||
\item Note that values are given as character strings (the macro-processor does not
|
||||
know floating point values)
|
||||
\item Inconvenient: can not reuse an array stored in a MATLAB/Octave variable
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
% \begin{frame}[fragile=singleslide]
|
||||
% \frametitle{Possible future developments}
|
||||
% \begin{itemize}
|
||||
% \item Find a nicer syntax for indexed sums/products
|
||||
% \item Implement other control structures: \texttt{elsif}, \texttt{switch/case}, \texttt{while/until} loops
|
||||
% \item Implement macro-functions (or templates), with a syntax like:
|
||||
% \small
|
||||
% \verb+@#define QUADRATIC_COST(x, x_ss, phi) = phi/2*(x/x_ss-1)^2+
|
||||
% \normalsize
|
||||
% \end{itemize}
|
||||
% \end{frame}
|
||||
|
||||
\begin{frame}
|
||||
\begin{center}
|
||||
\vfill {\LARGE Thanks for your attention!} \vfill
|
||||
{\LARGE Questions?}
|
||||
\vfill
|
||||
\end{center}
|
||||
\vfill
|
||||
\begin{columns}[T]
|
||||
\column{0.2\textwidth}
|
||||
\column{0.09\textwidth}
|
||||
|
||||
\ccbysa
|
||||
\column{0.71\textwidth}
|
||||
\tiny
|
||||
Copyright © 2008--2017 Dynare Team \\
|
||||
Licence: \href{http://creativecommons.org/licenses/by-sa/4.0/}{Creative
|
||||
Commons Attribution-ShareAlike 4.0}
|
||||
\end{columns}
|
||||
\end{frame}
|
||||
|
||||
|
||||
\end{document}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,346 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://web.resource.org/cc/"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="862.10712"
|
||||
height="382.82141"
|
||||
id="svg5540"
|
||||
sodipodi:version="0.32"
|
||||
inkscape:version="0.45.1"
|
||||
version="1.0"
|
||||
sodipodi:docbase="K:\Commun\Villemot\Macroprocessor"
|
||||
sodipodi:docname="new-design.svg"
|
||||
inkscape:output_extension="org.inkscape.output.svg.inkscape"
|
||||
inkscape:export-filename="K:\Commun\Villemot\Macroprocessor\new-design.png"
|
||||
inkscape:export-xdpi="90"
|
||||
inkscape:export-ydpi="90">
|
||||
<defs
|
||||
id="defs5542">
|
||||
<marker
|
||||
inkscape:stockid="Arrow1Lend"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="Arrow1Lend"
|
||||
style="overflow:visible">
|
||||
<path
|
||||
id="path3243"
|
||||
d="M 0,0 L 5,-5 L -12.5,0 L 5,5 L 0,0 z "
|
||||
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;marker-start:none"
|
||||
transform="matrix(-0.8,0,0,-0.8,-10,0)" />
|
||||
</marker>
|
||||
</defs>
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="0.7"
|
||||
inkscape:cx="488.94636"
|
||||
inkscape:cy="380.52134"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
width="1052.3622px"
|
||||
height="744.09448px"
|
||||
inkscape:window-width="1024"
|
||||
inkscape:window-height="712"
|
||||
inkscape:window-x="-4"
|
||||
inkscape:window-y="-4" />
|
||||
<metadata
|
||||
id="metadata5545">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Calque 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="translate(-78.642861,-39.058769)">
|
||||
<g
|
||||
id="g4418"
|
||||
transform="translate(467.50002,289.64286)">
|
||||
<text
|
||||
sodipodi:linespacing="125%"
|
||||
id="text4420"
|
||||
y="56.6479"
|
||||
x="361.42862"
|
||||
style="font-size:20px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Arial"
|
||||
xml:space="preserve"><tspan
|
||||
id="tspan4422"
|
||||
y="56.6479"
|
||||
x="361.42862"
|
||||
sodipodi:role="line">Matlab files</tspan><tspan
|
||||
id="tspan4424"
|
||||
y="81.6479"
|
||||
x="361.42862"
|
||||
sodipodi:role="line">representing</tspan><tspan
|
||||
id="tspan4426"
|
||||
y="106.6479"
|
||||
x="361.42862"
|
||||
sodipodi:role="line">the model</tspan></text>
|
||||
<path
|
||||
transform="matrix(1.0528522,0,0,1.0682674,-22.862484,-9.0197689)"
|
||||
d="M 431.42857 79.808769 A 66.428574 51.42857 0 1 1 298.57143,79.808769 A 66.428574 51.42857 0 1 1 431.42857 79.808769 z"
|
||||
sodipodi:ry="51.42857"
|
||||
sodipodi:rx="66.428574"
|
||||
sodipodi:cy="79.808769"
|
||||
sodipodi:cx="365"
|
||||
id="path4428"
|
||||
style="opacity:1;color:#000000;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
|
||||
sodipodi:type="arc" />
|
||||
</g>
|
||||
<g
|
||||
id="g4430"
|
||||
transform="translate(-555.35711,282.49999)">
|
||||
<text
|
||||
sodipodi:linespacing="125%"
|
||||
id="text4432"
|
||||
y="65.21933"
|
||||
x="691.42859"
|
||||
style="font-size:20px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Arial"
|
||||
xml:space="preserve"><tspan
|
||||
y="65.21933"
|
||||
x="691.42859"
|
||||
id="tspan4434"
|
||||
sodipodi:role="line">Output:</tspan><tspan
|
||||
id="tspan4436"
|
||||
y="90.21933"
|
||||
x="691.42859"
|
||||
sodipodi:role="line">Results,</tspan><tspan
|
||||
id="tspan4438"
|
||||
y="115.21933"
|
||||
x="691.42859"
|
||||
sodipodi:role="line">Graphics</tspan></text>
|
||||
<path
|
||||
d="M 747.14283 85.523056 A 54.285713 51.42857 0 1 1 638.5714,85.523056 A 54.285713 51.42857 0 1 1 747.14283 85.523056 z"
|
||||
sodipodi:ry="51.42857"
|
||||
sodipodi:rx="54.285713"
|
||||
sodipodi:cy="85.523056"
|
||||
sodipodi:cx="692.85712"
|
||||
id="path4440"
|
||||
style="opacity:1;color:#000000;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
|
||||
sodipodi:type="arc" />
|
||||
</g>
|
||||
<g
|
||||
id="g4452"
|
||||
transform="translate(-25.357118,291.07143)">
|
||||
<text
|
||||
sodipodi:linespacing="125%"
|
||||
id="text4454"
|
||||
y="68.076462"
|
||||
x="525.71436"
|
||||
style="font-size:20px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Arial"
|
||||
xml:space="preserve"><tspan
|
||||
y="68.076462"
|
||||
x="525.71436"
|
||||
id="tspan4456"
|
||||
sodipodi:role="line">Dynare</tspan><tspan
|
||||
id="tspan4458"
|
||||
y="93.076462"
|
||||
x="525.71436"
|
||||
sodipodi:role="line">Matlab routines</tspan></text>
|
||||
<rect
|
||||
y="36.951626"
|
||||
x="448.57144"
|
||||
height="75.714287"
|
||||
width="152.85715"
|
||||
id="rect4460"
|
||||
style="opacity:1;color:#000000;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
|
||||
</g>
|
||||
<path
|
||||
style="opacity:1;color:#000000;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:url(#Arrow1Lend);stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
|
||||
d="M 757.92859,365.8802 L 577.07147,365.8802"
|
||||
id="path4466"
|
||||
inkscape:connector-type="polyline"
|
||||
inkscape:connection-end="#g4452"
|
||||
inkscape:connection-start="#g4418" />
|
||||
<path
|
||||
style="opacity:1;color:#000000;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:url(#Arrow1Lend);stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
|
||||
d="M 422.21432,366.33835 L 192.78572,367.69591"
|
||||
id="path4468"
|
||||
inkscape:connector-type="polyline"
|
||||
inkscape:connection-start="#g4452"
|
||||
inkscape:connection-end="#g4430" />
|
||||
<g
|
||||
id="g6668">
|
||||
<text
|
||||
sodipodi:linespacing="125%"
|
||||
id="text4470"
|
||||
y="117.30877"
|
||||
x="143.92857"
|
||||
style="font-size:20px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Arial"
|
||||
xml:space="preserve"><tspan
|
||||
y="117.30877"
|
||||
x="143.92857"
|
||||
id="tspan4472"
|
||||
sodipodi:role="line">MOD file</tspan><tspan
|
||||
id="tspan4474"
|
||||
y="142.30877"
|
||||
x="143.92857"
|
||||
sodipodi:role="line">with macro</tspan><tspan
|
||||
id="tspan4482"
|
||||
y="167.30877"
|
||||
x="143.92857"
|
||||
sodipodi:role="line">commands</tspan></text>
|
||||
<path
|
||||
transform="matrix(1.0725676,0,0,0.999374,99.5973,-252.25554)"
|
||||
d="M 98.57143 390.52304 A 58.57143 56.42857 0 1 1 -18.57143,390.52304 A 58.57143 56.42857 0 1 1 98.57143 390.52304 z"
|
||||
sodipodi:ry="56.42857"
|
||||
sodipodi:rx="58.57143"
|
||||
sodipodi:cy="390.52304"
|
||||
sodipodi:cx="40"
|
||||
id="path4504"
|
||||
style="color:#000000;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
|
||||
sodipodi:type="arc" />
|
||||
</g>
|
||||
<g
|
||||
id="g5516"
|
||||
transform="translate(316.78572,-245.35715)">
|
||||
<text
|
||||
sodipodi:linespacing="125%"
|
||||
id="text4476"
|
||||
y="368.38019"
|
||||
x="307.14285"
|
||||
style="font-size:20px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Arial"
|
||||
xml:space="preserve"><tspan
|
||||
y="368.38019"
|
||||
x="307.14285"
|
||||
id="tspan4478"
|
||||
sodipodi:role="line">MOD file</tspan><tspan
|
||||
id="tspan4480"
|
||||
y="393.38019"
|
||||
x="307.14285"
|
||||
sodipodi:role="line">without macro</tspan><tspan
|
||||
id="tspan4484"
|
||||
y="418.38019"
|
||||
x="307.14285"
|
||||
sodipodi:role="line">commands</tspan></text>
|
||||
<path
|
||||
transform="translate(-8.5714286,-4.2857143)"
|
||||
d="M 389.99999 391.95163 A 72.85714 65 0 1 1 244.28571,391.95163 A 72.85714 65 0 1 1 389.99999 391.95163 z"
|
||||
sodipodi:ry="65"
|
||||
sodipodi:rx="72.85714"
|
||||
sodipodi:cy="391.95163"
|
||||
sodipodi:cx="317.14285"
|
||||
id="path5475"
|
||||
style="opacity:1;color:#000000;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
|
||||
sodipodi:type="arc" />
|
||||
</g>
|
||||
<g
|
||||
id="g5510"
|
||||
transform="translate(243.92858,-236.78572)">
|
||||
<text
|
||||
sodipodi:linespacing="125%"
|
||||
id="text4486"
|
||||
y="372.66592"
|
||||
x="165.71428"
|
||||
style="font-size:20px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Arial"
|
||||
xml:space="preserve"><tspan
|
||||
id="tspan4490"
|
||||
y="372.66592"
|
||||
x="165.71428"
|
||||
sodipodi:role="line">Macro</tspan><tspan
|
||||
id="tspan4492"
|
||||
y="397.66592"
|
||||
x="165.71428"
|
||||
sodipodi:role="line">Processor</tspan></text>
|
||||
<rect
|
||||
y="339.80878"
|
||||
x="110"
|
||||
height="72.85714"
|
||||
width="115.71429"
|
||||
id="rect5477"
|
||||
style="opacity:1;color:#000000;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
|
||||
</g>
|
||||
<g
|
||||
id="g5523"
|
||||
transform="translate(372.5,-249.64286)">
|
||||
<text
|
||||
sodipodi:linespacing="125%"
|
||||
id="text4494"
|
||||
y="368.38019"
|
||||
x="455.71426"
|
||||
style="font-size:20px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Arial"
|
||||
xml:space="preserve"><tspan
|
||||
y="368.38019"
|
||||
x="455.71426"
|
||||
id="tspan4496"
|
||||
sodipodi:role="line">Parser,</tspan><tspan
|
||||
id="tspan4498"
|
||||
y="393.38019"
|
||||
x="455.71426"
|
||||
sodipodi:role="line">Analytical</tspan><tspan
|
||||
id="tspan4500"
|
||||
y="418.38019"
|
||||
x="455.71426"
|
||||
sodipodi:role="line">derivator...</tspan></text>
|
||||
<rect
|
||||
y="339.80878"
|
||||
x="395.71429"
|
||||
height="94.285713"
|
||||
width="120"
|
||||
id="rect5479"
|
||||
style="opacity:1;color:#000000;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
|
||||
</g>
|
||||
<path
|
||||
style="opacity:1;color:#000000;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:url(#Arrow1Lend);stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
|
||||
d="M 206.35715,138.3618 L 352.92858,139.13938"
|
||||
id="path5532"
|
||||
inkscape:connector-type="polyline"
|
||||
inkscape:connection-end="#g5510"
|
||||
inkscape:connection-start="#g6668" />
|
||||
<path
|
||||
style="opacity:1;color:#000000;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:url(#Arrow1Lend);stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
|
||||
d="M 470.64287,140.23901 L 551.5,141.32071"
|
||||
id="path5534"
|
||||
inkscape:connector-type="polyline"
|
||||
inkscape:connection-start="#g5510"
|
||||
inkscape:connection-end="#g5516" />
|
||||
<path
|
||||
style="opacity:1;color:#000000;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:url(#Arrow1Lend);stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
|
||||
d="M 699.21428,140.48835 L 767.21429,138.81229"
|
||||
id="path5536"
|
||||
inkscape:connector-type="polyline"
|
||||
inkscape:connection-start="#g5516"
|
||||
inkscape:connection-end="#g5523" />
|
||||
<path
|
||||
style="opacity:1;color:#000000;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:url(#Arrow1Lend);stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
|
||||
d="M 828.36474,185.45163 L 828.75359,309.8802"
|
||||
id="path5538"
|
||||
inkscape:connector-type="polyline"
|
||||
inkscape:connection-end="#g4418"
|
||||
inkscape:connection-start="#g5523" />
|
||||
<rect
|
||||
style="opacity:1;color:#000000;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:1.5, 4.5;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
|
||||
id="rect5596"
|
||||
width="634.28571"
|
||||
height="201.42857"
|
||||
x="305.71429"
|
||||
y="39.808769" />
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:20px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Arial"
|
||||
x="404.28574"
|
||||
y="232.66591"
|
||||
id="text6567"
|
||||
sodipodi:linespacing="125%"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan6569"
|
||||
x="404.28574"
|
||||
y="232.66591">Dynare preprocessor</tspan></text>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 17 KiB |
|
@ -0,0 +1,16 @@
|
|||
if HAVE_PDFLATEX
|
||||
if HAVE_BEAMER
|
||||
pdf-local: preprocessor.pdf
|
||||
endif
|
||||
endif
|
||||
|
||||
SRC = preprocessor.tex expr.png expr-sharing.png matrices.png overview.png json-preprocessor.png
|
||||
|
||||
EXTRA_DIST = $(SRC)
|
||||
|
||||
preprocessor.pdf: $(SRC)
|
||||
$(PDFLATEX) preprocessor
|
||||
$(PDFLATEX) preprocessor
|
||||
|
||||
clean-local:
|
||||
rm -f *.pdf *.toc *.aux *.log *.nav *.snm *.vrb *.out *~
|
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
|
@ -0,0 +1 @@
|
|||
<mxfile userAgent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:50.0) Gecko/20100101 Firefox/50.0" version="6.0.1.9" editor="www.draw.io" type="device"><diagram name="Page-1">7VlJc5swFP41HNsB4QUfE2fpoZ3JTA5NjirIoEZGVMg2zq+vhMSOWhI7uPWYgy19T+v3Fp6E5S7X2T2DSfSNBohYwA4yy72xAJiDqfiVwF4BM9tVQMhwoCCnAh7xK9KgrdENDlDaaMgpJRwnTdCncYx83sAgY3TXbLaipDlrAkPUAR59SLrodxzwSKHe1K7wLwiHUTGzY2vJD+i/hIxuYj2fBdxV/ijxGhZj6fZpBAO6q0HureUuGaVcldbZEhFJbUGb6ndnkJbrZijmQzp4qsMWkg0qVjwjout1gLeSdcw1J7NfG7mo6wdJHbDdRQWJUqj/q67vgRKG2tCKio0Invi+tQ4p+JTmlnMl12MnmXlFaQLjErsFludZi3khFOw05BWsJu/APcsUaM9+DkFBY9dAqE0Yv6hc7yLM0WMCfSnZCfcTWMTXRNQcUYRpojxihTMUyL1zRl/QkhLK8qFcO38khZiQGn6XPwIPGQywMKBCFtMYlWuq25Y2ty1iHGU1SNvaPaJrxNleNNFSd67tXseFia7uKicrfCyq+VeBQe3WYTlwZdqioK3b4BqzLqeBcHpd1XvMXVfSdiMJ8uka+7pcoxhlmD9pWJafCzwWa3qqV551q9LNZeUn4nyvYx7ccCogynhEQxpD8pXSRI9gVpxREyndMF/vbqHjJmQhKuOUwuTG/6guhgjkeNuMhgexPz86+46JfftfZR+civ2FMcofGl7N0fIs4xfwmvHLcUYMYN7xA9jnqdGJlOjUblTw2/Aj92RRzDY60gGpC5j0+Rah4RszkbP0uMnshB7njKdu56JsEV5BS9mLEZUNxlP260XZ4iwwOaGy3Y9Qdn+StL8ouyeMj6nsSY+y2yzHwZW8NxI1n8A0lVlTndxG7mMm9u0nw0FZkNdNghYDc6CB/A5OlfQMDxTnPmEI3K7T0pvaje5Vv49qD9S6IACz1kCKg85AuQ2U2x5mFtPRzWL4kfW9ZlHwfrGLd9tFyfTZXFW0jOHvh66ey4tFvxkd/YjV54T/9zXdMdivfRv44BOu+aro6FlwIqg+j9Sokwf1KNmYGpWp0Ph34kV0HkPb4KJr+Xoe7TZDVKvPiOo1WH2qdW9/Aw==</diagram></mxfile>
|
Binary file not shown.
After Width: | Height: | Size: 9.2 KiB |
|
@ -0,0 +1 @@
|
|||
<mxfile userAgent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:50.0) Gecko/20100101 Firefox/50.0" version="6.0.1.9" editor="www.draw.io" type="device"><diagram name="Page-1">7VhLc5swEP41HNsBKXbwMXGS9tDOZCaHJkcVZFAjIypkG+fXd4XEGzJOnJI2Yw629K0eu98+EHLwcp1/kSSNv4uQcge5Ye7gKwehczSDXw3sDTB3sQEiyUIDeTVwx56oBV2LblhIs9ZAJQRXLG2DgUgSGqgWRqQUu/awleDtXVMS0R5wFxDeR3+wUMUG9WdujX+lLIrLnT3XSn6S4DGSYpPY/RyEV8VjxGtSrmXHZzEJxa4B4WsHL6UQyrTW+ZJyTW1Jm5l3MyKt9JY0UYdM8M2ELeEbWmo85zD1MmRbzTpTlpP5741W6vJWU4dcvKghaEX2v576GiiVtAutBBgCPKl9Rw8t+JQVkXOh9XHTfFyjLCVJhV0jx/edxXkpBHZa8ho2m/fgATUBHbDnGBS1rEbgNgh+6FzuYqboXUoCLdlB+gEWqzWHngdNkqUmI1Ysp6G2XUnxSJeCC1kshd3i0RQyzhv4TfEAHkkSMgigUpaIhFY6balUNB8NN68KYqgNVKypknsYYiegMxv3ti5g293VSVbmWNzIrxIjNq2jauE6tKFho3skNeZ9TkNIetu1Nhapq2m70gQFYs0C225QTHOm7i2s2w8lnoBO983Ogx1Vpbnu/KJK7W3NIxslABJSxSISCeHfhEjtCuOOM5Zo9Z/3A1grNjKwoxa2kBIZ0apwDbtLUk4U27aXP4r98zdn3xtj3/1v2EcTsb8YrfLHltfxavkh65c3a9ev6r0/RQHz376AfZ6NJpER/XNpVJ4QW3mEp6pi7mgiHXF0QWdDucVF9MKTyIfMOIzfMeO86dztnZwN76mOr/0JfY2m8/XTydeoLqbv4Wz8N5w9fEban5w9UMWndPbZgLO7LCfhhb42gl7ASZbpQ1OT3NbRZ5zYl38Yvu4Q5PfPQIth/g/k9+CTkt3hVrAiJ4brNnY7bjO620nN26jOOl7neqDnf2Nxb6EiBCqrD4uK2eRRcfgH65tFhec6p7B4JiygW9+1muH1fTa+/gM=</diagram></mxfile>
|
Binary file not shown.
After Width: | Height: | Size: 51 KiB |
|
@ -0,0 +1 @@
|
|||
<mxfile userAgent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:51.0) Gecko/20100101 Firefox/51.0" version="6.0.3.0" editor="www.draw.io" type="device"><diagram name="Page-1">7Vxtc5s4EP41/tgMCPPij7ET96bTXDKTm2n7UcaKTYORR8iJc7/+BEgYJNnGiQw4vUxnCosEaPfZZ1cr4YEzWW2/Erhe3uE5igfAmm8Hzs0AANsCFvsvk7wVEm/kFoIFiea80U7wGP2LRE8u3URzlNYaUoxjGq3rwhAnCQppTQYJwa/1Zk84rj91DRdIETyGMFalP6I5XRbSwLV28r9QtFiKJ9sWvzKD4fOC4E3CnzcAzlP+V1xeQXEv3j5dwjl+rYic24EzIRjT4mi1naA4061QW9Fvuudq+d4EJbRJBxAA/iL0TQwezZku+GmCE/bfOB8RyvrY7CzEqyhkxxY7XtJVzMVoG9GfleNfWZMrNztLKHn7yXvkJ7trpQaya78RpW8cDnBDMRNhQpd4gRMYf8d4zW+fUoKf0QTHmOTv7Fj5H7uiKoDrJMUbEvIR8jFTSBaItwK+Uwiz0Vc6crV9RXiF2HuzBgTFkEYvdaRADrhF2W6ndHbA9b7HBsUtXmC84Te9WuF5BtuI2QB4MXvF8YywowUtR1i1Vxwzv8jM9LqMKHpcw3ycr8w16wZStDad2hN7ckhrL4hQtD2oD351yHtwj3c4wF937mMPuWxZcR3hUh9RYKAocAVDgr+g7RrmsAXWJWrU863OVApcrwkvHGEC7v2cC+waE+yI4Re/gWEmqHNWM14QJFBjBtc1zQx512tC4FulwRpHCU0rd37IBBUHA3U4iJgz3dPetuxD7dlB8Qb63o5bf5rv1odTqI13knBVqqQR1OzhYajtzH67k1asayQKNYVbIxjZvooiO+gsvASjVkP82R1bq8h3GQUEXhee7AwlT/b9g54stxdp8r72ABxsX/f893isrwTcyRKFz0z0ANO0QYA9Nax642t7yl5/zAJ4XJHz3NpIuAUWqFvF9dV4CzTxdmgk3p6Yh1ufIQ8XpFgjylFnRDmyTrPBJyVKjVE6IkrXOo0o5fadE6U6M/mHwCR9wmR12WTpeJJl2iVL508ky5HGL63uyLLdwlFfyVJnlG7I0pNd8ghZyu07J8uRQpYTvFpvaJQsLpssXSDNxNsly6BNR7X7QZZCm1W/9Ixnlu/y08A5zU/l9sCzjfodcFutD/QYIMB4jaYTgDicSY0BxGt1XtRngPifAyB80c8YQCwlcv8gLAwz0f2Gsgh+oXHbC7qc5KhFtjtIYzhjHe9DChm4wPTbJo7goFjXapId9XRhS6fXs61sqXNy1mec/xMEcOkKBaNhewr11Lx9FiUwf78LV6PjtYnLofEoa9WiLGinqjGd8jA7h+myfNPs5AFSikiSS4DVeDktcDWRuBeBWCyEcLzwhWJTYVWMu+JYpSsJTxIhwcoey8ItDwz8VISH4uzq6kr0Z4LZzhmPuicDxjo7DDez9/homXhJsXqa/zH5gsB5xCAgrnGsC/FNRFBII5zkl0jmiuO0QObIjOdLhhwCNSAF9pkCvS2Wfip2XjPUZkXiL+kahdET8/HMiLKdCFoTlLJRw1w5wMJPg8vc6lJmACIjGLYYwJgZNY4m6ymZX2cbCzMviGGaZrRbU0+VO2vMt58g91U338GXtRU0Aaij7FjRrntAuaeRqGbjyh7vOrKXRF3eke4zku5TKEG5z+kbbaTnWLXp1cenS0BH7G3gTbstyzASa9VxgcRa6Ob1q77A064XZz2v2U6no7ARZZhj8HxXyc5XAfP5d+26mkTQNl6SaZ6wt1pY7+sKmNYqHS2B2XLB5khhTG7f9RJYqctKZHiAJM1XwC6yhCbtCm+3giYCTVWbmsR6ghM2oLRIoZnjnJpC91Hvjoi80qJRTfG6oGpG8Wrt8mMJzn7S0pc6DjFn893gnia5br4bvJ3sRd6n7ViSAZumL7YtcVsgvYuh7Freli6eY261Si3wGgaf43hec/D5Stw2VRgTldcqPoN+wdOTduSV+8ZOzq4leA5H0o0MwdMTk7NzrbZryuWfFJ5As5G0Z/CUtzG6cvjrOzyNr/WLJZA/AJ6aD0L+h6dheJreaeCr7KlL6b9HM5KvQB5f2niNVjHMZ+oVBFczcz6P12X5h+tux6sbJ+Tz8swTqEuTQLdCIVaCP1bpUEnh5i1h42Gyh2wVAocoTdm4gXW7ReGGwlmjmVMbyk8ZtCmviwDnPNZwVVtYGlsErgFbiE9Udba4yz57rlijD1PXHXiaFw2Of/d8tpqBmPX8WZVV3XfPHX6wegDiEt08Lpl43jvGV0gnhjMUj8sfB5GeZIKSpMqnrTqNH2icpmz4sY9BTvwgp8nelUO/HQDOVAsvc9PGSebJ5fLA07ia25preYprfXu8/3vQ/n4BBdoa1e1Fuy1Xvc64X4Cd7n6Pp8hZdz965Nz+Bw==</diagram></mxfile>
|
Binary file not shown.
After Width: | Height: | Size: 28 KiB |
|
@ -0,0 +1 @@
|
|||
<mxfile userAgent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:50.0) Gecko/20100101 Firefox/50.0" version="6.0.1.9" editor="www.draw.io" type="device"><diagram name="Page-1">5ZhNj5swEIZ/DXeMycdem/3oYbetlErdPbowMe4aJnLMQvrra2BIQr2pKnXFqoRDYr8e2+PHk1coAV/l9Z0R2+wBU9BBFKZ1wK+DKFouQvfZCPtOWES8E6RRaSexo7BWP4FEmidLlcJuEGgRtVXboZhgUUBiB5owBqth2Ab1cNetkOAJ60RoX/2mUpvRsWbhUf8ISmb9ziykke8ieZYGy4L2CyK+aZ9uOBf9WhS/y0SK1YnEbwK+Moi2a+X1CnSDtsfWzbs9M3rI20Bh/2bCFaVh9/3RIXUkqFtg4b4+tOeBZkboegnmKqF2ZnPtmsw1oVb2keSm/dTrhTX7x9POE0Udzt50foC1eyoEUVp0EhqbocRC6HvELa2wswafYYUaTZsvD9vHjXQnadI/y4KkHZYmoaiIqksYCRTFD/fgyhswB5ezCzGghVUvw9UFFZo8xB1huwbxPnNZ4ZvDZ+fgh/8L/Hgk+LT1i9AlLfogrFG1fyVaO9dpbqLKlIX1VrTZV873hndwHs5GaX2i37aP06URqXJ8+jG6ccoMjIX6zzR9TjQh6g2Y/Le3m+poZmxJWnZiZL3B/QtZ7pG9xwqMk74aJQpZatF0poT7akibsRFxM+YzvCwLj30XmY1l4dGlW/gr8OcjwY89o/mEJhd6YuYSz97TXfilF/jML/DlWO4SX7q1vwJ/MRL8mecu633erOLwTstgfn99GfVtce5h/nworIlxnrN35LzwOH/BnWp/MVF4DRtVOI4TA86iIXAejwh86b+dgBTTBh7PxwPuuse/ydqxk78i+c0v</diagram></mxfile>
|
Binary file not shown.
After Width: | Height: | Size: 54 KiB |
|
@ -0,0 +1 @@
|
|||
<mxfile userAgent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:51.0) Gecko/20100101 Firefox/51.0" version="6.0.2.15" editor="www.draw.io" type="device"><diagram name="Page-1">7Vtbc9o4FP41PG7HkrGBx0JK9yGZZoadafuo2AJ7a1seWQTor98jW/JNpCWNsYFsJjORjo9uR5/OTcrIXsT7z5ykwQPzaTTClr8f2XcjjJGFLfgjKYeC4rqzgrDhoa+YKsIq/El1S0Xdhj7NGoyCsUiEaZPosSShnmjQCOds12Rbs6g5ako21CCsPBKZ1K+hL4KCOnWsiv43DTeBHhlZ6ssT8X5sONsmarwRttf5T/E5JrovxZ8FxGe7Gsn+NLIXnDFRlOL9gkZStlpsRbvlC1/LeXOaiFMauE7R4plEW7X2u0MCzYH2yGnKmUezjPERdiPocP4kSxtZUvMXBy2zbBfGEUmgNg9EHAERQXHNErFSTBbUvSCM/HtyYFs5v0yAvHRtHjAe/gR+ohvDZy4UOrArewujaMEimI99l7BirLLRSnamhuE0g2aPWg6oJN2TTOipsCgiaRY+5ZOTLDHhmzCZMyFYrJj0qpbmyD7JAuqXU+XsB9UcsO1W/lMKqr4lapeeKRd0XyOpLfpMWUwFPwCL/jpVcDk0j8muwuZYswQ1XNpInwl1HjZl1xUmoKBgcRwiU2xsNfXhtKiqEkaO+VIaHotDT0mwBga6D8W3Wvm7ZPngyFoCs/qmWuSV6lt5RuS3f6kQBwUJshUMSIyLgG1YQqJ7xtI/34+MbbmnVqjWDPjbUMU1sQuaXPwvN43TiIjwualK3rID2DijH2LmS70Wwhb8/mRCb6A45S7tglDQVUryZe5Adzf3xxDacokWaNENiO0Whh0TxGh8BMSa700YNiQYE4+zv+g+JTlssXUDInWc/iQ6cTvXCkoTKL2AGlqhUhLftWIeQCugI2oBOUOpBWTqBTB4WZhsTgDwa2Hrzj+i5bJlgivvphs4O008u0c0BD6C53EXeJ68Rzw7R/A8GQzPpi8aJoJyWHI+XAoeHKwGBmWJiXC27lGJW9Zy2ZVzZ49bhhH3aBgn0/cI+8kR2E8Hg/3EgP0ioBDJQARGsuxGdDma9anMnc5Rffkhi0ZwI2ZBXaM6b/qRc3KoMaQMFHVW6/lREiowjGdNMOBpKyvxG/6p09r9YgIVFsqVnHbizHDgH06SbM14fFunrlcXSmcg3pctmZmnDo8HsyUz05awON2KPCi4ZmQ7uGVP7D6R/R7tiRZmHdk6jT+wPXGnr7MnbX4069agTLtPhlwnPnDnXvQw+MAd46P75MKV4qPz5MIg+HCtTuGhJVWz2l85mGAgfdkKsN43YrP79UaRIaPb90a159k4c1bXZ+7ke6uxgetXJPTIGlhH8o5fOrA50ynO62Uk9RzU9jh6TOphM6P0QEREnqDhF0+QZ6lZZI70vPLs8qZrYjXlafd41XXk9hDazPNfa1WcPmwtr1qe5QOWPgTqmlHqPExIPr8rF+Okz9z97B1aOJ3RbOTuO49KT94CjZg3WTihk48v8F2JjTvm3Z3tQYd9Zuxbv8A+Ggr7ton9ywi4y71vZedeCqhQW2/a3UZU2tv6Hx7DqUbbUI3ly9IH+fjqNW9LLzG6xW0MH3t+da7odtZ9dHv5GSUN5obtx0MBfGp6sbC+4qIFCpTIu8T8Vcpgbw27tPaodSd7xseGUK1ewBfav/o3A/vTfw==</diagram></mxfile>
|
|
@ -0,0 +1,820 @@
|
|||
\documentclass{beamer}
|
||||
%\documentclass[draft]{beamer}
|
||||
%\documentclass[handout]{beamer}
|
||||
|
||||
|
||||
\mode<handout>
|
||||
{
|
||||
\usepackage{pgfpages}
|
||||
\pgfpagesuselayout{4 on 1}[a4paper,border shrink=3mm,landscape]
|
||||
\usetheme{Madrid}
|
||||
\usecolortheme{seagull}
|
||||
}
|
||||
|
||||
\mode<beamer>
|
||||
{
|
||||
\usetheme{Madrid}
|
||||
\setbeamercovered{transparent}
|
||||
}
|
||||
|
||||
|
||||
\usepackage[english]{babel}
|
||||
\usepackage[utf8]{inputenc}
|
||||
|
||||
\usepackage{times}
|
||||
\usepackage[copyright]{ccicons}
|
||||
|
||||
\title{The Dynare Preprocessor}
|
||||
|
||||
\author[S. Villemot, H.Bastani]{Sébastien Villemot \and Houtan Bastani}
|
||||
|
||||
\institute{CEPREMAP}
|
||||
|
||||
\date{1 February 2017}
|
||||
|
||||
\AtBeginSection[]
|
||||
{
|
||||
\begin{frame}{Outline}
|
||||
\tableofcontents[currentsection]
|
||||
\end{frame}
|
||||
}
|
||||
|
||||
\begin{document}
|
||||
|
||||
\begin{frame}
|
||||
\titlepage
|
||||
|
||||
\begin{columns}[T]
|
||||
\column{0.2\textwidth}
|
||||
\column{0.09\textwidth}
|
||||
|
||||
\ccbysa
|
||||
\column{0.71\textwidth}
|
||||
\tiny
|
||||
Copyright © 2007--2017 Dynare Team \\
|
||||
Licence: \href{http://creativecommons.org/licenses/by-sa/4.0/}{Creative
|
||||
Commons Attribution-ShareAlike 4.0}
|
||||
\end{columns}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{Overview}
|
||||
\begin{center}
|
||||
\includegraphics[width=11cm]{overview.png}
|
||||
\end{center}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}{Outline}
|
||||
\tableofcontents
|
||||
\end{frame}
|
||||
|
||||
\section{Invoking the preprocessor}
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{Calling Dynare}
|
||||
\begin{itemize}
|
||||
\item Dynare is called from the host language platform with the syntax \texttt{dynare <<filename>>.mod}
|
||||
\item This call can be followed by certain options:
|
||||
\begin{itemize}
|
||||
\item Some of these options impact host language platform functionality, \textit{e.g.} \texttt{nograph} prevents graphs from being displayed in Matlab
|
||||
\item Some cause differences in the output created by default, \textit{e.g.} \texttt{notmpterms} prevents temporary terms from being written to the static/dynamic files
|
||||
\item While others impact the functionality of the macroprocessor or the preprocessor, \textit{e.g.} \texttt{nostrict} shuts off certain checks that the preprocessor does by defalut
|
||||
\end{itemize}
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\section{Parsing}
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{Parsing overview}
|
||||
\begin{itemize}
|
||||
\item Parsing is the action of transforming an input text (a \texttt{mod} file in our case) into a data structure suitable for computation
|
||||
\item The parser consists of three components:
|
||||
\begin{itemize}
|
||||
\item the \alert{lexical analyzer}, which recognizes the ``words'' of the \texttt{mod} file (analog to the \textit{vocabulary} of a language)
|
||||
\item the \alert{syntax analyzer}, which recognizes the ``sentences'' of the \texttt{mod} file (analog to the \textit{grammar} of a language)
|
||||
\item the \alert{parsing driver}, which coordinates the whole process and constructs the data structure using the results of the lexical and syntax analyses
|
||||
\end{itemize}
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{Lexical analysis}
|
||||
\begin{itemize}
|
||||
\item The lexical analyzer recognizes the ``words'' (or \alert{lexemes}) of the language
|
||||
\item Defined in \texttt{DynareFlex.ll}, it is transformed into C++ source code by the program \texttt{flex}
|
||||
\item This file details the list of known lexemes (described by regular expressions) and the associated \alert{token} for each of them
|
||||
\item For punctuation (semicolon, parentheses, \ldots), operators (+, -, \ldots) or fixed keywords (\textit{e.g.} \texttt{model}, \texttt{varexo}, \ldots), the token is simply an integer uniquely identifying the lexeme
|
||||
\item For variable names or numbers, the token also contains the associated string for further processing
|
||||
%\item \textit{Note:} the list of tokens can be found at the beginning of \texttt{DynareBison.yy}
|
||||
\item When invoked, the lexical analyzer reads the next characters of the input, tries to recognize a lexeme, and either produces an error or returns the associated token
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}[fragile]
|
||||
\frametitle{Lexical analysis}
|
||||
\framesubtitle{An example}
|
||||
\begin{itemize}
|
||||
\item Suppose the \texttt{mod} file contains the following:
|
||||
\begin{verbatim}
|
||||
model;
|
||||
x = log(3.5);
|
||||
end;
|
||||
\end{verbatim}
|
||||
\item Before lexical analysis, it is only a sequence of characters
|
||||
\item The lexical analysis produces the following stream of tokens:
|
||||
|
||||
\begin{footnotesize}
|
||||
\begin{verbatim}
|
||||
MODEL
|
||||
SEMICOLON
|
||||
NAME "x"
|
||||
EQUAL
|
||||
LOG
|
||||
LEFT_PARENTHESIS
|
||||
FLOAT_NUMBER "3.5"
|
||||
RIGHT_PARENTHESIS
|
||||
SEMICOLON
|
||||
END
|
||||
SEMICOLON
|
||||
\end{verbatim}
|
||||
\end{footnotesize}
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{Syntax analysis}
|
||||
\framesubtitle{In Dynare}
|
||||
\begin{itemize}
|
||||
\item The \texttt{mod} file grammar is described in \texttt{DynareBison.yy}, which is transformed into C++ source code by the program \texttt{bison}
|
||||
\item The grammar tells a story which looks like:
|
||||
\begin{itemize}
|
||||
\item A \texttt{mod} file is a list of statements
|
||||
\item A statement can be a \texttt{var} statement, a \texttt{varexo} statement, a \texttt{model} block, an \texttt{initval} block, \ldots
|
||||
\item A \texttt{var} statement begins with the token \texttt{VAR}, then a list of \texttt{NAME}s, then a semicolon
|
||||
\item A \texttt{model} block begins with the token \texttt{MODEL}, then a semicolon, then a list of equations separated by semicolons, then an \texttt{END} token
|
||||
\item An equation can be either an expression, or an expression followed by an \texttt{EQUAL} token and another expression
|
||||
\item An expression can be a \texttt{NAME}, or a \texttt{FLOAT\_NUMBER}, or an expression followed by a \texttt{PLUS} and another expression, \ldots
|
||||
\end{itemize}
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}[fragile]
|
||||
\frametitle{Syntax analysis}
|
||||
Using the list of tokens produced by lexical analysis, the syntax analyzer determines which ``sentences'' are valid in the language, according to a \alert{grammar} composed of \alert{rules}.
|
||||
\begin{block}{A grammar for lists of additive and multiplicative expressions}
|
||||
\begin{footnotesize}
|
||||
\begin{verbatim}
|
||||
%start expression_list;
|
||||
|
||||
expression_list := expression SEMICOLON
|
||||
| expression_list expression SEMICOLON;
|
||||
|
||||
expression := expression PLUS expression
|
||||
| expression TIMES expression
|
||||
| LEFT_PAREN expression RIGHT_PAREN
|
||||
| INT_NUMBER;
|
||||
\end{verbatim}
|
||||
\end{footnotesize}
|
||||
\end{block}
|
||||
\begin{itemize}
|
||||
\item \texttt{(1+3)*2; 4+5;} will pass the syntax analysis without error
|
||||
\item \texttt{1++2;} will fail the syntax analysis, even though it has passed the lexical analysis
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{Semantic actions}
|
||||
\begin{itemize}
|
||||
\item So far we have only described how to accept valid \texttt{mod} files and to reject others
|
||||
\item But validating is not enough: one needs to do something with the parsed \texttt{mod} file
|
||||
\item Every grammar rule can have a \alert{semantic action} associated with it: C/C++ code enclosed by curly braces
|
||||
\item Every rule can return a semantic value (referenced by \texttt{\$\$} in the action)
|
||||
\item In the action, it is possible to refer to semantic values returned by components of the rule (using \texttt{\$1}, \texttt{\$2}, \ldots)
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}[fragile]
|
||||
\frametitle{Semantic actions}
|
||||
\framesubtitle{An example}
|
||||
\begin{block}{A simple calculator which prints its results}
|
||||
\begin{footnotesize}
|
||||
\begin{verbatim}
|
||||
%start expression_list
|
||||
%type <int> expression
|
||||
|
||||
expression_list := expression SEMICOLON
|
||||
{ cout << $1 << endl; }
|
||||
| expression_list expression SEMICOLON
|
||||
{ cout << $2 << endl; };
|
||||
|
||||
expression := expression PLUS expression
|
||||
{ $$ = $1 + $3; }
|
||||
| expression TIMES expression
|
||||
{ $$ = $1 * $3; }
|
||||
| LEFT_PAREN expression RIGHT_PAREN
|
||||
{ $$ = $2; }
|
||||
| INT_NUMBER
|
||||
{ $$ = $1; };
|
||||
\end{verbatim}
|
||||
\end{footnotesize}
|
||||
\end{block}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{Parsing driver}
|
||||
|
||||
The class \texttt{ParsingDriver} has the following roles:
|
||||
\begin{itemize}
|
||||
\item It opens the \texttt{mod} file and launches the lexical and syntaxic analyzers on it
|
||||
\item It implements most of the semantic actions of the grammar
|
||||
\item By doing so, it creates an object of type \texttt{ModFile}, which is the data structure representing the \texttt{mod} file
|
||||
\item Or, if there is a parsing error (unknown keyword, undeclared symbol, syntax error), it displays the line and column numbers where the error occurred and exits
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\section{Data structure representing a \texttt{mod} file}
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{The \texttt{ModFile} class}
|
||||
\begin{itemize}
|
||||
\item This class is the internal data structure used to store all the information contained in a \texttt{mod} file
|
||||
\item One instance of the class represents one \texttt{mod} file
|
||||
\item The class contains the following elements (as class members):
|
||||
\begin{itemize}
|
||||
\item a symbol table, numerical constants table, external functions table
|
||||
\item trees of expressions: dynamic model, static model, original model, ramsey dynamic model, steady state model, trend dynamic model, \ldots
|
||||
\item the list of the statements (parameter initializations, \texttt{shocks} block, \texttt{check}, \texttt{steady}, \texttt{simul}, \ldots)
|
||||
\item model-specification and user-preference variables: \texttt{block}, \texttt{bytecode}, \texttt{use\_dll}, \texttt{no\_static}, \ldots
|
||||
\item an evaluation context (containing \texttt{initval} and parameter values)
|
||||
\end{itemize}
|
||||
\item An instance of \texttt{ModFile} is the output of the parsing process (return value of \texttt{ParsingDriver::parse()})
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{The symbol table (1/3)}
|
||||
\begin{itemize}
|
||||
\item A \alert{symbol} is simply the name of a variable (endogenous, exogenous, local, auxiliary, etc), parameter, external function, \ldots basically everything that is not recognized as a Dynare keyword
|
||||
\item \alert{SymbolTable} is a simple class used to maintain the list of the symbols used in the \texttt{mod} file
|
||||
\item For each symbol, it stores:
|
||||
\begin{itemize}
|
||||
\item its name, tex\_name, and long\_name (strings, some of which can be empty)
|
||||
\item its type (an enumerator defined in \texttt{CodeInterpreter.hh})
|
||||
\item a unique integer identifier (also has a unique identifier by type)
|
||||
\end{itemize}
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{The symbol table (2/3)}
|
||||
Existing types of symbols:
|
||||
\begin{itemize}
|
||||
\item Endogenous variables
|
||||
\item Exogenous variables
|
||||
\item Exogenous deterministic variables
|
||||
\item Parameters
|
||||
\item Local variables inside model: declared with a pound sign (\#) construction
|
||||
\item Local variables outside model: no declaration needed (\textit{e.g.} lhs symbols in equations from \texttt{steady\_state\_model} block, expression outside of model block, \ldots)
|
||||
\item External functions
|
||||
\item Trend variables
|
||||
\item Log Trend variables
|
||||
\item Unused Endogenous variables (created when \texttt{nostrict} option is passed)
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{The symbol table (3/3)}
|
||||
\begin{itemize}
|
||||
\item Symbol table filled in:
|
||||
\begin{itemize}
|
||||
\item using the \texttt{var}, \texttt{varexo}, \texttt{varexo\_det}, \texttt{parameter}, \texttt{external\_function}, \texttt{trend\_var}, and \texttt{log\_trend\_var} declarations
|
||||
\item using pound sign (\#) constructions in the model block
|
||||
\item on the fly during parsing: local variables outside models or unknown functions when an undeclared symbol is encountered
|
||||
\item during the creation of auxiliary variables in the transform pass
|
||||
\end{itemize}
|
||||
\item Roles of the symbol table:
|
||||
\begin{itemize}
|
||||
\item permits parcimonious and more efficient representation of expressions (no need to duplicate or compare strings, only handle a pair of integers)
|
||||
\item ensures that a given symbol is used with only one type
|
||||
\end{itemize}
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{Expression trees (1/3)}
|
||||
\begin{itemize}
|
||||
\item The data structure used to store expressions is essentially a \alert{tree}
|
||||
\item Graphically, the tree representation of $(1+z)*\log(y)$ is:
|
||||
\begin{center}
|
||||
\includegraphics[width=6cm]{expr.png}
|
||||
\end{center}
|
||||
\item No need to store parentheses
|
||||
\item Each circle represents a \alert{node}
|
||||
\item A non external function node has at most one parent and at most three children (an external function node has as many children as arguments)
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{Expression trees (2/3)}
|
||||
\begin{itemize}
|
||||
\item A tree node is represented by an instance of the abstract class \texttt{ExprNode}
|
||||
\item This class has 5 sub-classes, corresponding to the 5 types of non-external-function nodes:
|
||||
\begin{itemize}
|
||||
\item \texttt{NumConstNode} for constant nodes: contains the identifier of the numerical constants it represents
|
||||
\item \texttt{VariableNode} for variable/parameters nodes: contains the identifier of the variable or parameter it represents
|
||||
\item \texttt{UnaryOpNode} for unary operators (\textit{e.g.} unary minus, $\log$, $\sin$): contains an enumerator representing the operator, and a pointer to its child
|
||||
\item \texttt{BinaryOpNode} for binary operators (\textit{e.g.} $+$, $*$, pow): contains an enumerator representing the operator, and pointers to its two children
|
||||
\item \texttt{TrinaryOpNode} for trinary operators (\textit{e.g.} $normcdf$, $normpdf$): contains an enumerator representing the operator and pointers to its three children
|
||||
\end{itemize}
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{Expression trees (3/3)}
|
||||
\begin{itemize}
|
||||
\item The abstract class \texttt{ExprNode} has an abstract sub-class called \texttt{AbstractExternalFunctionNode}
|
||||
\item This abstract sub-class has 3 sub-classes, corresponding to the 3 types of external function nodes:
|
||||
\begin{itemize}
|
||||
\item \texttt{ExternalFunctionNode} for external functions. Contains the identifier of the external function and a vector of its arguments
|
||||
\item \texttt{FirstDerivExternalFunctionNode} for the first derivative of an external function. In addition to the information contained in \texttt{ExternalFunctionNode}, contains the index w.r.t. which this node is the derivative.
|
||||
\item \texttt{SecondDerivExternalFunctionNode} for the second derivative of an external function. In addition to the information contained in \texttt{FirstDerivExternalFunctionNode}, contains the index w.r.t. which this node is the second derivative.
|
||||
\end{itemize}
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{Classes \texttt{DataTree} and \texttt{ModelTree}}
|
||||
\begin{itemize}
|
||||
\item Class \texttt{DataTree} is a container for storing a set of expression trees
|
||||
\item Class \texttt{ModelTree} is a sub-class container of \texttt{DataTree}, specialized for storing a set of model equations.
|
||||
\item In the code, we use \texttt{ModelTree}-derived classes: \texttt{DynamicModel} (the model with lags) and \texttt{StaticModel} (the model without lags)
|
||||
\item Class \texttt{ModFile} contains:
|
||||
\begin{itemize}
|
||||
\item one instance of \texttt{DataTree} for storing all expressions outside model block
|
||||
\item several instances of \texttt{DynamicModel}, one each for storing the equations of the model block for the original model, modified model, original Ramsey model, the Ramsey FOCs, etc.
|
||||
\item one instance of \texttt{StaticModel} for storing the equations of model block without lags
|
||||
\end{itemize}
|
||||
\item Expression storage is optimized through three mechanisms:
|
||||
\begin{itemize}
|
||||
\item symbolic simplification rules
|
||||
\item sub-expression sharing
|
||||
\item pre-computing of numerical constants
|
||||
\end{itemize}
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{Constructing expression trees}
|
||||
\begin{itemize}
|
||||
\item Class \texttt{DataTree} contains a set of methods for constructing expression trees
|
||||
\item Construction is done bottom-up, node by node:
|
||||
\begin{itemize}
|
||||
\item one method for adding a constant node (\texttt{AddPossiblyNegativeConstant(double)})
|
||||
\item one method for a log node (\texttt{AddLog(arg)})
|
||||
\item one method for a plus node (\texttt{AddPlus(arg1, arg2)})
|
||||
\end{itemize}
|
||||
\item These methods take pointers to \texttt{ExprNode}, allocate the memory for the node, construct it, and return its pointer
|
||||
\item These methods are called:
|
||||
\begin{itemize}
|
||||
\item from \texttt{ParsingDriver} in the semantic actions associated to the parsing of expressions
|
||||
\item during symbolic derivation, to create derivatives expressions
|
||||
\item when creating the static model from the dynamic model
|
||||
\item \ldots
|
||||
\end{itemize}
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{Reduction of constants and symbolic simplifications}
|
||||
\begin{itemize}
|
||||
\item The construction methods compute constants whenever possible
|
||||
\begin{itemize}
|
||||
\item Suppose you ask to construct the node $1+1$
|
||||
\item The \texttt{AddPlus()} method will return a pointer to a constant node containing 2
|
||||
\end{itemize}
|
||||
\item The construction methods also apply a set of simplification rules, such as:
|
||||
\begin{itemize}
|
||||
\item $0+0=0$
|
||||
\item $x+0 = x$
|
||||
\item $0-x = -x$
|
||||
\item $-(-x) = x$
|
||||
\item $x*0 = 0$
|
||||
\item $x/1 = x$
|
||||
\item $x^0 = 1$
|
||||
\end{itemize}
|
||||
\item When a simplification rule applies, no new node is created
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{Sub-expression sharing (1/2)}
|
||||
\begin{itemize}
|
||||
\item Consider the two following expressions: $(1+z)*\log(y)$ and $2^{(1+z)}$
|
||||
\item Expressions share a common sub-expression: $1+z$
|
||||
\item The internal representation of these expressions is:
|
||||
\begin{center}
|
||||
\includegraphics[width=7cm]{expr-sharing.png}
|
||||
\end{center}
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{Sub-expression sharing (2/2)}
|
||||
\begin{itemize}
|
||||
\item Construction methods implement a simple algorithm which achieves maximal expression sharing
|
||||
\item Algorithm uses the fact that each node has a unique memory address (pointer to the corresponding instance of \texttt{ExprNode})
|
||||
\item It maintains 9 tables which keep track of the already-constructed nodes: one table by type of node (constants, variables, unary ops, binary ops, trinary ops, external functions, first deriv of external functions, second deriv of external functions, local variables)
|
||||
\item Suppose you want to create the node $e_1+e_2$ (where $e_1$ and $e_2$ are sub-expressions):
|
||||
\begin{itemize}
|
||||
\item the algorithm searches the binary ops table for the tuple equal to (address of $e_1$, address of $e_2$, op code of +) (it is the \alert{search key})
|
||||
\item if the tuple is found in the table, the node already exists and its memory address is returned
|
||||
\item otherwise, the node is created and is added to the table with its search key
|
||||
\end{itemize}
|
||||
\item Maximum sharing is achieved because expression trees are constructed bottom-up
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{Final remarks about expressions}
|
||||
\begin{itemize}
|
||||
\item Storage of negative constants
|
||||
\begin{itemize}
|
||||
\item class \texttt{NumConstNode} only accepts positive constants
|
||||
\item a negative constant is stored as a unary minus applied to a positive constant
|
||||
\item this is a kind of identification constraint to avoid having two ways of representing negative constants: $(-2)$ and $-(2)$
|
||||
\end{itemize}
|
||||
\item Widely used constants
|
||||
\begin{itemize}
|
||||
\item class \texttt{DataTree} has attributes containing pointers to constants: $0$, $1$, $2$, $-1$, \texttt{NaN}, $\infty$, $-\infty$, and $\pi$
|
||||
\item these constants are used in many places (in simplification rules, in derivation algorithm\ldots)
|
||||
\item sub-expression sharing algorithm ensures that these constants will never be duplicated
|
||||
\end{itemize}
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{List of statements}
|
||||
\begin{itemize}
|
||||
\item A statement is represented by an instance of a subclass of the abstract class \texttt{Statement}
|
||||
\item Three groups of statements:
|
||||
\begin{itemize}
|
||||
\item initialization statements (parameter initialization with $p = \ldots$, \texttt{initval}, \texttt{histval}, or \texttt{endval} block)
|
||||
\item shocks blocks (\texttt{shocks}, \texttt{mshocks}, \ldots)
|
||||
\item computing tasks (\texttt{steady}, \texttt{check}, \texttt{simul}, \ldots)
|
||||
\end{itemize}
|
||||
\item Each type of statement has its own class (\textit{e.g.} \texttt{InitValStatement}, \texttt{SimulStatement}, \ldots)
|
||||
\item The class \texttt{ModFile} stores a list of pointers of type \texttt{Statement*}, corresponding to the statements of the \texttt{mod} file, in their order of declaration
|
||||
\item Heavy use of polymorphism in the check pass, computing pass, and when writing outputs: abstract class \texttt{Statement} provides a virtual method for these 3 actions
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{Evaluation context}
|
||||
\begin{itemize}
|
||||
\item The \texttt{ModFile} class contains an \alert{evaluation context}
|
||||
\item It is a map associating a numerical value to some symbols
|
||||
\item Filled in with \texttt{initval} block values and parameter initializations
|
||||
\item Used during equation normalization (in the block decomposition), for finding non-zero entries in the jacobian
|
||||
\item Used in testing that trends are compatible with a balanced growth path, for finding non-zero cross partials of equations with respect to trend variables and endogenous varibales
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\section{Check pass}
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{Error checking during parsing}
|
||||
\begin{itemize}
|
||||
\item Some errors in the \texttt{mod} file can be detected during parsing:
|
||||
\begin{itemize}
|
||||
\item syntax errors
|
||||
\item use of undeclared symbols in model block, initval block\ldots
|
||||
\item use of a symbol incompatible with its type (\textit{e.g.} parameter in initval, local variable used both in model and outside model)
|
||||
\item multiple shock declarations for the same variable
|
||||
\end{itemize}
|
||||
\item But some other checks can only be done when parsing is completed\ldots
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{Check pass}
|
||||
\begin{itemize}
|
||||
\item The check pass is implemented through the method \texttt{ModFile::checkPass()}
|
||||
\item Performs many checks. Examples include:
|
||||
\begin{itemize}
|
||||
\item check there is at least one equation in the model (except if doing a standalone BVAR estimation)
|
||||
\item checks for coherence in statements (\textit{e.g.} options passed to statements do not conflict with each other, required options have been passed)
|
||||
\item checks for coherence among statements (\textit{e.g.} if \texttt{osr} statement is present, ensure \texttt{osr\_params} and \texttt{optim\_weights} statements are present)
|
||||
\item checks for coherence between statements and attributes of \texttt{mod} file (\textit{e.g.} \texttt{use\_dll} is not used with \texttt{block} or \texttt{bytecode})
|
||||
\end{itemize}
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\section{Transform pass}
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{Transform pass (1/2)}
|
||||
\begin{itemize}
|
||||
\item The transform pass is implemented through the method \texttt{ModFile::transformPass(bool nostrict)}
|
||||
\item It makes necessary transformations (notably to the dynamic model, symbol table, and statements list) preparing the \texttt{ModFile} object for the computing pass. Examples of transformations include:
|
||||
\begin{itemize}
|
||||
\item creation of auxiliary variables and equations for leads, lags, expectation operator, differentiated forward variables, etc.
|
||||
\item detrending of model equations if nonstationary variables are present
|
||||
\item decreasing leads/lags of predetermined variables by one period
|
||||
\item addition of FOCs of Langrangian for Ramsey problem
|
||||
\item addition of \texttt{dsge\_prior\_weight} initialization before all other statements if estimating a DSGE-VAR where the weight of the DSGE prior of the VAR is calibrated
|
||||
\end{itemize}
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{Transform pass (2/2)}
|
||||
\begin{itemize}
|
||||
\item It then freezes the symbol table, meaning that no more symbols can be created on the \texttt{ModFile} object
|
||||
\item Finally checks are performed on the transformed model. Examples include:
|
||||
\begin{itemize}
|
||||
\item same number of endogenous varibables as equations (not done in certain situations, \textit{e.g.} Ramsey, discretionary policy, etc.)
|
||||
\item correspondence among variables and statements, \textit{e.g.} Ramsey policy, identification, perfect foresight solver, and simul are incompatible with deterministic exogenous variables
|
||||
\item correspondence among statements, \textit{e.g.} for DSGE-VAR without \texttt{bayesian\_irf} option, the number of shocks must be greater than or equal to the number of observed variables
|
||||
\end{itemize}
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
|
||||
\section{Computing pass}
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{Overview of the computing pass}
|
||||
\begin{itemize}
|
||||
\item Computing pass implemented in \texttt{ModFile::computingPass()}
|
||||
\item Creates Static model from Dynamic (by removing leads/lags)
|
||||
\item Determines which derivatives to compute
|
||||
\item Then calls \texttt{DynamicModel::computingPass()} which computes:
|
||||
\begin{itemize}
|
||||
\item leag/lag variable incidence matrix
|
||||
\item symbolic derivatives w.r.t. endogenous, exogenous, and parameters, if needed
|
||||
\item equation normalization + block decomposition
|
||||
\item temporary terms
|
||||
\item computes equation cross references, if desired
|
||||
\end{itemize}
|
||||
\item NB: analagous operations for Static model are performed by \texttt{StaticModel::computingPass()}
|
||||
\item Asserts that equations declared linear are indeed linear (by checking that Hessian == 0)
|
||||
\item Finally, calls \texttt{Statement::computingPass()} on all statements
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{Model Variables}
|
||||
\begin{itemize}
|
||||
\item In the context of class \texttt{ModelTree}, a \alert{variable} is a pair (symbol, lag)
|
||||
\item The symbol must correspond to a variable of type endogenous, exogenous, deterministic exogenous variable, or parameter
|
||||
\item The \texttt{SymbolTable} class keeps track of valid symbols while the \texttt{variable\_node\_map} keeps track of model variables (symbol, lag pairs stored in \texttt{VariableNode} objects)
|
||||
\item After the computing pass, the \texttt{DynamicModel} class writes the leag/lag incidence matrix:
|
||||
\begin{itemize}
|
||||
\item three rows: the first row indicates $t-1$, the second row $t$, and the third row $t+1$
|
||||
\item one column for every endogenous symbol in order of declaration; NB: includes endogenous auxiliary variables created during the transform pass
|
||||
\item elements of the matrix are either 0 (if the variable does not appear in the model) or correspond to the variable's column in the Jacobian of the dynamic model
|
||||
\end{itemize}
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{Static versus dynamic model}
|
||||
\begin{itemize}
|
||||
\item The static model is simply the dynamic model without leads and lags
|
||||
\item Static model used to characterize the steady state
|
||||
\item The jacobian of the static model is used in the (Matlab) solver for determining the steady state
|
||||
\end{itemize}
|
||||
\begin{block}{Example}
|
||||
\begin{itemize}
|
||||
\item suppose dynamic model is $2x_t \cdot x_{t-1} = 0$
|
||||
\item static model is $2x^2 = 0$, whose derivative w.r.t. $x$ is $4x$
|
||||
\item dynamic derivative w.r.t. $x_t$ is $2x_{t-1}$, and w.r.t. $x_{t-1}$ is $2x_t$
|
||||
\item removing leads/lags from dynamic derivatives and summing over the two partial derivatives w.r.t. $x_t$ and $x_{t-1}$ gives $4x$
|
||||
\end{itemize}
|
||||
\end{block}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{Which derivatives to compute?}
|
||||
\begin{itemize}
|
||||
\item In deterministic mode:
|
||||
\begin{itemize}
|
||||
\item static jacobian w.r.t. endogenous variables only
|
||||
\item dynamic jacobian w.r.t. endogenous variables only
|
||||
\end{itemize}
|
||||
\item In stochastic mode:
|
||||
\begin{itemize}
|
||||
\item static jacobian w.r.t. endogenous variables only
|
||||
\item dynamic jacobian w.r.t. endogenous, exogenous, and deterministic exogenous variables
|
||||
\item dynamic hessian w.r.t. endogenous, exogenous, and deterministic exogenous variables
|
||||
\item possibly dynamic 3rd derivatives (if \texttt{order} option $\geq 3$)
|
||||
\item possibly dynamic jacobian and/or hessian w.r.t. parameters (if \texttt{identification} or analytic derivs needed for \texttt{estimation} and \texttt{params\_derivs\_order} $>0$)
|
||||
\end{itemize}
|
||||
\item For Ramsey policy: the same as above, but with one further order of derivation than declared by the user with \texttt{order} option (the derivation order is determined in the check pass, see \texttt{RamseyPolicyStatement::checkPass()})
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{Derivation algorithm (1/2)}
|
||||
\begin{itemize}
|
||||
\item Derivation of the model implemented in \texttt{ModelTree::computeJacobian()}, \texttt{ModelTree::computeHessian()}, \texttt{ModelTree::computeThirdDerivatives()}, and \texttt{ModelTree::computeParamsDerivatives()}
|
||||
\item Simply call \texttt{ExprNode::getDerivative(deriv\_id)} on each equation node
|
||||
\item Use of polymorphism:
|
||||
\begin{itemize}
|
||||
\item for a constant or variable node, derivative is straightforward ($0$ or $1$)
|
||||
\item for a unary, binary, trinary op nodes and external function nodes, recursively calls method \texttt{computeDerivative()} on children to construct derivative
|
||||
\end{itemize}
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{Derivation algorithm (2/2)}
|
||||
\framesubtitle{Optimizations}
|
||||
\begin{itemize}
|
||||
\item Caching of derivation results
|
||||
\begin{itemize}
|
||||
\item method \texttt{ExprNode::getDerivative(deriv\_id)} memorizes its result in a member attribute (\texttt{derivatives}) the first time it is called
|
||||
\item the second time it is called (with the same argument), it simply returns the cached value without recomputation
|
||||
\item caching is useful because of sub-expression sharing
|
||||
\end{itemize}
|
||||
\item Efficiently finds symbolic derivatives equal to $0$
|
||||
\begin{itemize}
|
||||
\item consider the expression $x+y^2$
|
||||
\item without any computation, you know its derivative w.r.t. $z$ is zero
|
||||
\item each node stores in an attribute (\texttt{non\_null\_derivatives}) the set of variables which appear in the expression it represents ($\{x,y\}$ in the example)
|
||||
\item this set is computed in \texttt{prepareForDerivation()}
|
||||
\item when \texttt{getDerivative(deriv\_id)} is called, immediately returns zero if \texttt{deriv\_id} is not in that set
|
||||
\end{itemize}
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}[fragile]
|
||||
\frametitle{Temporary terms (1/2)}
|
||||
\begin{itemize}
|
||||
\item When the preprocessor writes equations and derivatives in its outputs, it takes advantage of sub-expression sharing
|
||||
\item In Matlab static and dynamic output files, equations are preceded by a list of \alert{temporary terms}
|
||||
\item These terms are variables containing expressions shared by several equations or derivatives
|
||||
\item Using these terms greatly enhances the computing speed of the model residual, jacobian, hessian, or third derivative
|
||||
\end{itemize}
|
||||
\begin{block}{Example}
|
||||
\begin{columns}[t]
|
||||
\begin{column}{6cm}
|
||||
The equations:
|
||||
\begin{verbatim}
|
||||
residual(0)=x+y^2-z^3;
|
||||
residual(1)=3*(x+y^2)+1;
|
||||
\end{verbatim}
|
||||
\end{column}
|
||||
\begin{column}{4.8cm}
|
||||
Can be optimized in:
|
||||
\begin{verbatim}
|
||||
T1=x+y^2;
|
||||
residual(0)=T1-z^3;
|
||||
residual(1)=3*T1+1;
|
||||
\end{verbatim}
|
||||
\end{column}
|
||||
\end{columns}
|
||||
\end{block}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{Temporary terms (2/2)}
|
||||
\begin{itemize}
|
||||
\item Expression storage in the preprocessor implements maximal sharing but this is not optimal for the Matlab output files, because creating a temporary variable also has a cost (in terms of CPU and of memory)
|
||||
\item Computation of temporary terms implements a trade-off between:
|
||||
\begin{itemize}
|
||||
\item cost of duplicating sub-expressions
|
||||
\item cost of creating new variables
|
||||
\end{itemize}
|
||||
\item Algorithm uses a recursive cost calculation, which marks some nodes as being ``temporary''
|
||||
\item \textit{Problem}: redundant with optimizations done by the C/C++ compiler (when Dynare is in DLL mode) $\Rightarrow$ compilation very slow on big models
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{The special case of Ramsey policy}
|
||||
\begin{itemize}
|
||||
\item For most statements, the method \texttt{computingPass()} is a no-op\ldots
|
||||
\item \ldots except for \texttt{planner\_objective} statement, which serves to declare planner objective when doing optimal policy under commitment
|
||||
\item Class \texttt{PlannerObjectiveStatement} contains an instance of \texttt{ModelTree}, which stores the objective function (\texttt{i.e.} only one equation in the tree)
|
||||
\item During the computing pass, triggers the computation of the first and second order (static) derivatives of the objective
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\section{Writing outputs}
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{Output overview}
|
||||
\begin{itemize}
|
||||
\item Implemented in \texttt{ModFile::writeOutputFiles()}
|
||||
\item If \texttt{mod} file is \texttt{model.mod}, all created filenames will begin with \texttt{model}
|
||||
\item Main output file is \texttt{model.m}, containing:
|
||||
\begin{itemize}
|
||||
\item general initialization commands
|
||||
\item symbol table output (from \texttt{SymbolTable::writeOutput()})
|
||||
\item lead/lag incidence matrix (from \texttt{DynamicModel::writeDynamicMFile()})
|
||||
\item call to Matlab functions corresponding to the statements of the \texttt{mod} file (written by calling \texttt{Statement::writeOutput()} on all statements through polymorphism)
|
||||
\end{itemize}
|
||||
\item Subsidiary output files:
|
||||
\begin{itemize}
|
||||
\item one for the static model
|
||||
\item one for the dynamic model
|
||||
\item one for the auxiliary variables
|
||||
\item one for the steady state file (if relevant)
|
||||
\item one for the planner objective (if relevant)
|
||||
\end{itemize}
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{Model output files}
|
||||
Three possible output types:
|
||||
\begin{itemize}
|
||||
\item Matlab/Octave mode: static and dynamic files in Matlab
|
||||
\item Julia mode: static and dynamic files in Julia
|
||||
\item DLL mode:
|
||||
\begin{itemize}
|
||||
\item static and dynamic files in C++ source code (with corresponding headers)
|
||||
\item compiled through \texttt{mex} to allow execution from within Matlab
|
||||
\end{itemize}
|
||||
\item Sparse DLL mode:
|
||||
\begin{itemize}
|
||||
\item static file in Matlab
|
||||
\item two possibilities for dynamic file:
|
||||
\begin{itemize}
|
||||
\item by default, a C++ source file (with header) and a binary file, to be read from the C++ code
|
||||
\item or, with \texttt{no\_compiler} option, a binary file in custom format, executed from Matlab through \texttt{simulate} DLL
|
||||
\item the second option serves to bypass compilation of C++ file which can be very slow
|
||||
\end{itemize}
|
||||
\end{itemize}
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\section{Proposed Changes}
|
||||
|
||||
\newcounter{sauvegardeenumi}
|
||||
\newcommand{\asuivre}{\setcounter{sauvegardeenumi}{\theenumi}}
|
||||
\newcommand{\suite}{\setcounter{enumi}{\thesauvegardeenumi}}
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{Proposed changes with addition of Julia support (1/2)}
|
||||
\begin{enumerate}
|
||||
\item Julia output is provided upon parsing of \texttt{mod} file, everything else done in Julia
|
||||
\begin{itemize}
|
||||
\item Pros: very few changes to the preprocessor
|
||||
\item Cons: repeated code (same checks, transformations, computations done in preprocessor and Julia); potential code divergence/two parallel projects
|
||||
\end{itemize}
|
||||
\item Dump preprocessor altogether: do everything with Julia
|
||||
\begin{itemize}
|
||||
\item Pros: simple to distribute, move away from C++ (no contributions, requires more expertise)
|
||||
\item Cons: Matlab/Octave users must also download Julia, a big project, speed (?)
|
||||
\end{itemize}
|
||||
\asuivre
|
||||
\end{enumerate}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{Proposed changes with addition of Julia support (2/2)}
|
||||
\begin{enumerate}
|
||||
\suite
|
||||
\item Create libraries out of the preprocessor
|
||||
\begin{itemize}
|
||||
\item Pros: Dynare interaction similar across HLPs, preprocessor used as is
|
||||
\item Cons: difficult for outsiders to contribute, big project, not much benefit in speed when compared to\ldots
|
||||
\end{itemize}
|
||||
\item Write \texttt{mod} file from HLP then call preprocessor; option to output JSON file representing \texttt{ModFile} object at every step of the preprocessor
|
||||
\begin{itemize}
|
||||
\item Pros: Dynare interaction similar across HLPs, preprocessor used as is, minimal amount of work, easy incremental step, allows users to support any given HPL given the JSON output
|
||||
\item Cons: unnecessary processing when certain changes made in host language, keeps defaults of current preprocessor, speed (?)
|
||||
\end{itemize}
|
||||
\item Other ideas?
|
||||
\end{enumerate}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{Using HLP \texttt{mod} file objects (1/2)}
|
||||
\begin{center}
|
||||
\includegraphics[width=11cm]{json-preprocessor.png}
|
||||
\end{center}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{Using HLP \texttt{mod} file objects (2/2)}
|
||||
\begin{itemize}
|
||||
\item Allows interactivity for all HLPs; requires only
|
||||
\begin{itemize}
|
||||
\item A definition of a mod file class in the HLP
|
||||
\item A library function that converts an HLP mod file object to a \texttt{mod} file
|
||||
\end{itemize}
|
||||
\item Allows users to use Dynare with any HPL. Standard JSON output can be read in any HPL; user can use it construct desired HPL objects and work with model in their language of preference
|
||||
\item Easy first step
|
||||
\item No divergence of codebase: don't need to repeat code (checks, transformations, etc.) across platforms
|
||||
\item Creates \texttt{mod} files that can be used on other host language platforms
|
||||
\item Adds one more HLP library to distribute
|
||||
\item Need to design/implement classes that will store processed dynare \texttt{mod} file in various HLPs
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\end{document}
|
|
@ -0,0 +1,2 @@
|
|||
NB: .png files made on https://www.draw.io. They can be edited by loading the .xml file with the same name
|
||||
|
|
@ -0,0 +1,102 @@
|
|||
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
||||
Upstream-Name: Dynare-preprocessor
|
||||
Upstream-Contact: Dynare Team, whose members in 2018 are:
|
||||
Stéphane Adjemian <stephane.adjemian@univ-lemans.fr>
|
||||
Houtan Bastani <houtan@dynare.org>
|
||||
Michel Juillard <michel.juillard@mjui.fr>
|
||||
Frédéric Karamé <frederic.karame@univ-lemans.fr>
|
||||
Junior Maih <junior.maih@gmail.com>
|
||||
Ferhat Mihoubi <fmihoubi@univ-evry.fr>
|
||||
Johannes Pfeifer <jpfeifer@gmx.de>
|
||||
Marco Ratto <marco.ratto@ec.europa.eu>
|
||||
Sébastien Villemot <sebastien.villemot@sciencespo.fr>
|
||||
Source: http://www.dynare.org
|
||||
|
||||
Files: *
|
||||
Copyright: 1996-2018 Dynare Team
|
||||
License: GPL-3+
|
||||
|
||||
Files: m4/ax_boost_base.m4
|
||||
Copyright: 2008 Thomas Porschberg <thomas@randspringer.de>
|
||||
2009 Peter Adolphs
|
||||
License: permissive-autoconf
|
||||
|
||||
Files: m4/ax_latex_class.m4 m4/ax_tex_test.m4
|
||||
Copyright: 2008 Boretti Mathieu <boretti@eig.unige.ch>
|
||||
2009 Dynare Team
|
||||
License: LGPL-2.1+
|
||||
|
||||
License: GPL-3+
|
||||
Dynare is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
.
|
||||
Dynare is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
License: GPL-3+ with Autoconf exception
|
||||
This program is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation, either version 3 of the License, or (at your
|
||||
option) any later version.
|
||||
.
|
||||
This program is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
Public License for more details.
|
||||
.
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
.
|
||||
As a special exception, the respective Autoconf Macro's copyright owner
|
||||
gives unlimited permission to copy, distribute and modify the configure
|
||||
scripts that are the output of Autoconf when processing the Macro. You
|
||||
need not follow the terms of the GNU General Public License when using
|
||||
or distributing such scripts, even though portions of the text of the
|
||||
Macro appear in them. The GNU General Public License (GPL) does govern
|
||||
all other use of the material that constitutes the Autoconf Macro.
|
||||
.
|
||||
This special exception to the GPL applies to versions of the Autoconf
|
||||
Macro released by the Autoconf Archive. When you make and distribute a
|
||||
modified version of the Autoconf Macro, you may extend this special
|
||||
exception to the GPL to apply to your modified version as well.
|
||||
|
||||
License: LGPL-2.1+
|
||||
This library is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or (at
|
||||
your option) any later version.
|
||||
.
|
||||
This library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
||||
General Public License for more details.
|
||||
.
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
License: LGPL-3+
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
.
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
License: permissive-autoconf
|
||||
Copying and distribution of this file, with or without modification, are
|
||||
permitted in any medium without royalty provided the copyright notice
|
||||
and this notice are preserved. This file is offered as-is, without any
|
||||
warranty.
|
|
@ -0,0 +1,260 @@
|
|||
# ===========================================================================
|
||||
# http://www.gnu.org/software/autoconf-archive/ax_boost_base.html
|
||||
# ===========================================================================
|
||||
#
|
||||
# SYNOPSIS
|
||||
#
|
||||
# AX_BOOST_BASE([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# Test for the Boost C++ libraries of a particular version (or newer)
|
||||
#
|
||||
# If no path to the installed boost library is given the macro searchs
|
||||
# under /usr, /usr/local, /opt and /opt/local and evaluates the
|
||||
# $BOOST_ROOT environment variable. Further documentation is available at
|
||||
# <http://randspringer.de/boost/index.html>.
|
||||
#
|
||||
# This macro calls:
|
||||
#
|
||||
# AC_SUBST(BOOST_CPPFLAGS) / AC_SUBST(BOOST_LDFLAGS)
|
||||
#
|
||||
# And sets:
|
||||
#
|
||||
# HAVE_BOOST
|
||||
#
|
||||
# LICENSE
|
||||
#
|
||||
# Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de>
|
||||
# Copyright (c) 2009 Peter Adolphs
|
||||
#
|
||||
# Copying and distribution of this file, with or without modification, are
|
||||
# permitted in any medium without royalty provided the copyright notice
|
||||
# and this notice are preserved. This file is offered as-is, without any
|
||||
# warranty.
|
||||
|
||||
#serial 21
|
||||
|
||||
AC_DEFUN([AX_BOOST_BASE],
|
||||
[
|
||||
AC_ARG_WITH([boost],
|
||||
[AS_HELP_STRING([--with-boost@<:@=ARG@:>@],
|
||||
[use Boost library from a standard location (ARG=yes),
|
||||
from the specified location (ARG=<path>),
|
||||
or disable it (ARG=no)
|
||||
@<:@ARG=yes@:>@ ])],
|
||||
[
|
||||
if test "$withval" = "no"; then
|
||||
want_boost="no"
|
||||
elif test "$withval" = "yes"; then
|
||||
want_boost="yes"
|
||||
ac_boost_path=""
|
||||
else
|
||||
want_boost="yes"
|
||||
ac_boost_path="$withval"
|
||||
fi
|
||||
],
|
||||
[want_boost="yes"])
|
||||
|
||||
|
||||
AC_ARG_WITH([boost-libdir],
|
||||
AS_HELP_STRING([--with-boost-libdir=LIB_DIR],
|
||||
[Force given directory for boost libraries. Note that this will override library path detection, so use this parameter only if default library detection fails and you know exactly where your boost libraries are located.]),
|
||||
[
|
||||
if test -d "$withval"
|
||||
then
|
||||
ac_boost_lib_path="$withval"
|
||||
else
|
||||
AC_MSG_ERROR(--with-boost-libdir expected directory name)
|
||||
fi
|
||||
],
|
||||
[ac_boost_lib_path=""]
|
||||
)
|
||||
|
||||
if test "x$want_boost" = "xyes"; then
|
||||
boost_lib_version_req=ifelse([$1], ,1.20.0,$1)
|
||||
boost_lib_version_req_shorten=`expr $boost_lib_version_req : '\([[0-9]]*\.[[0-9]]*\)'`
|
||||
boost_lib_version_req_major=`expr $boost_lib_version_req : '\([[0-9]]*\)'`
|
||||
boost_lib_version_req_minor=`expr $boost_lib_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
|
||||
boost_lib_version_req_sub_minor=`expr $boost_lib_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
|
||||
if test "x$boost_lib_version_req_sub_minor" = "x" ; then
|
||||
boost_lib_version_req_sub_minor="0"
|
||||
fi
|
||||
WANT_BOOST_VERSION=`expr $boost_lib_version_req_major \* 100000 \+ $boost_lib_version_req_minor \* 100 \+ $boost_lib_version_req_sub_minor`
|
||||
AC_MSG_CHECKING(for boostlib >= $boost_lib_version_req)
|
||||
succeeded=no
|
||||
|
||||
dnl On 64-bit systems check for system libraries in both lib64 and lib.
|
||||
dnl The former is specified by FHS, but e.g. Debian does not adhere to
|
||||
dnl this (as it rises problems for generic multi-arch support).
|
||||
dnl The last entry in the list is chosen by default when no libraries
|
||||
dnl are found, e.g. when only header-only libraries are installed!
|
||||
libsubdirs="lib"
|
||||
ax_arch=`uname -m`
|
||||
case $ax_arch in
|
||||
x86_64|ppc64|s390x|sparc64|aarch64)
|
||||
libsubdirs="lib64 lib lib64"
|
||||
;;
|
||||
esac
|
||||
|
||||
dnl first we check the system location for boost libraries
|
||||
dnl this location ist chosen if boost libraries are installed with the --layout=system option
|
||||
dnl or if you install boost with RPM
|
||||
if test "$ac_boost_path" != ""; then
|
||||
BOOST_CPPFLAGS="-I$ac_boost_path/include"
|
||||
for ac_boost_path_tmp in $libsubdirs; do
|
||||
if test -d "$ac_boost_path"/"$ac_boost_path_tmp" ; then
|
||||
BOOST_LDFLAGS="-L$ac_boost_path/$ac_boost_path_tmp"
|
||||
break
|
||||
fi
|
||||
done
|
||||
elif test "$cross_compiling" != yes; then
|
||||
for ac_boost_path_tmp in /usr /usr/local /opt /opt/local ; do
|
||||
if test -d "$ac_boost_path_tmp/include/boost" && test -r "$ac_boost_path_tmp/include/boost"; then
|
||||
for libsubdir in $libsubdirs ; do
|
||||
if ls "$ac_boost_path_tmp/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi
|
||||
done
|
||||
BOOST_LDFLAGS="-L$ac_boost_path_tmp/$libsubdir"
|
||||
BOOST_CPPFLAGS="-I$ac_boost_path_tmp/include"
|
||||
break;
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
dnl overwrite ld flags if we have required special directory with
|
||||
dnl --with-boost-libdir parameter
|
||||
if test "$ac_boost_lib_path" != ""; then
|
||||
BOOST_LDFLAGS="-L$ac_boost_lib_path"
|
||||
fi
|
||||
|
||||
CPPFLAGS_SAVED="$CPPFLAGS"
|
||||
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
|
||||
export CPPFLAGS
|
||||
|
||||
LDFLAGS_SAVED="$LDFLAGS"
|
||||
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
|
||||
export LDFLAGS
|
||||
|
||||
AC_REQUIRE([AC_PROG_CXX])
|
||||
AC_LANG_PUSH(C++)
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
||||
@%:@include <boost/version.hpp>
|
||||
]], [[
|
||||
#if BOOST_VERSION >= $WANT_BOOST_VERSION
|
||||
// Everything is okay
|
||||
#else
|
||||
# error Boost version is too old
|
||||
#endif
|
||||
]])],[
|
||||
AC_MSG_RESULT(yes)
|
||||
succeeded=yes
|
||||
found_system=yes
|
||||
],[
|
||||
])
|
||||
AC_LANG_POP([C++])
|
||||
|
||||
|
||||
|
||||
dnl if we found no boost with system layout we search for boost libraries
|
||||
dnl built and installed without the --layout=system option or for a staged(not installed) version
|
||||
if test "x$succeeded" != "xyes"; then
|
||||
_version=0
|
||||
if test "$ac_boost_path" != ""; then
|
||||
if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
|
||||
for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
|
||||
_version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
|
||||
V_CHECK=`expr $_version_tmp \> $_version`
|
||||
if test "$V_CHECK" = "1" ; then
|
||||
_version=$_version_tmp
|
||||
fi
|
||||
VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
|
||||
BOOST_CPPFLAGS="-I$ac_boost_path/include/boost-$VERSION_UNDERSCORE"
|
||||
done
|
||||
fi
|
||||
else
|
||||
if test "$cross_compiling" != yes; then
|
||||
for ac_boost_path in /usr /usr/local /opt /opt/local ; do
|
||||
if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
|
||||
for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
|
||||
_version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
|
||||
V_CHECK=`expr $_version_tmp \> $_version`
|
||||
if test "$V_CHECK" = "1" ; then
|
||||
_version=$_version_tmp
|
||||
best_path=$ac_boost_path
|
||||
fi
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
||||
VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
|
||||
BOOST_CPPFLAGS="-I$best_path/include/boost-$VERSION_UNDERSCORE"
|
||||
if test "$ac_boost_lib_path" = ""; then
|
||||
for libsubdir in $libsubdirs ; do
|
||||
if ls "$best_path/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi
|
||||
done
|
||||
BOOST_LDFLAGS="-L$best_path/$libsubdir"
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "x$BOOST_ROOT" != "x"; then
|
||||
for libsubdir in $libsubdirs ; do
|
||||
if ls "$BOOST_ROOT/stage/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi
|
||||
done
|
||||
if test -d "$BOOST_ROOT" && test -r "$BOOST_ROOT" && test -d "$BOOST_ROOT/stage/$libsubdir" && test -r "$BOOST_ROOT/stage/$libsubdir"; then
|
||||
version_dir=`expr //$BOOST_ROOT : '.*/\(.*\)'`
|
||||
stage_version=`echo $version_dir | sed 's/boost_//' | sed 's/_/./g'`
|
||||
stage_version_shorten=`expr $stage_version : '\([[0-9]]*\.[[0-9]]*\)'`
|
||||
V_CHECK=`expr $stage_version_shorten \>\= $_version`
|
||||
if test "$V_CHECK" = "1" -a "$ac_boost_lib_path" = "" ; then
|
||||
AC_MSG_NOTICE(We will use a staged boost library from $BOOST_ROOT)
|
||||
BOOST_CPPFLAGS="-I$BOOST_ROOT"
|
||||
BOOST_LDFLAGS="-L$BOOST_ROOT/stage/$libsubdir"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
|
||||
export CPPFLAGS
|
||||
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
|
||||
export LDFLAGS
|
||||
|
||||
AC_LANG_PUSH(C++)
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
||||
@%:@include <boost/version.hpp>
|
||||
]], [[
|
||||
#if BOOST_VERSION >= $WANT_BOOST_VERSION
|
||||
// Everything is okay
|
||||
#else
|
||||
# error Boost version is too old
|
||||
#endif
|
||||
]])],[
|
||||
AC_MSG_RESULT(yes)
|
||||
succeeded=yes
|
||||
found_system=yes
|
||||
],[
|
||||
])
|
||||
AC_LANG_POP([C++])
|
||||
fi
|
||||
|
||||
if test "$succeeded" != "yes" ; then
|
||||
if test "$_version" = "0" ; then
|
||||
AC_MSG_NOTICE([[We could not detect the boost libraries (version $boost_lib_version_req_shorten or higher). If you have a staged boost library (still not installed) please specify \$BOOST_ROOT in your environment and do not give a PATH to --with-boost option. If you are sure you have boost installed, then check your version number looking in <boost/version.hpp>. See http://randspringer.de/boost for more documentation.]])
|
||||
else
|
||||
AC_MSG_NOTICE([Your boost libraries seems to old (version $_version).])
|
||||
fi
|
||||
# execute ACTION-IF-NOT-FOUND (if present):
|
||||
ifelse([$3], , :, [$3])
|
||||
else
|
||||
AC_SUBST(BOOST_CPPFLAGS)
|
||||
AC_SUBST(BOOST_LDFLAGS)
|
||||
AC_DEFINE(HAVE_BOOST,,[define if the Boost library is available])
|
||||
# execute ACTION-IF-FOUND (if present):
|
||||
ifelse([$2], , :, [$2])
|
||||
fi
|
||||
|
||||
CPPFLAGS="$CPPFLAGS_SAVED"
|
||||
LDFLAGS="$LDFLAGS_SAVED"
|
||||
fi
|
||||
|
||||
])
|
|
@ -0,0 +1,68 @@
|
|||
# ===========================================================================
|
||||
# http://www.nongnu.org/autoconf-archive/ax_latex_class.html
|
||||
# ===========================================================================
|
||||
#
|
||||
# OBSOLETE MACRO
|
||||
#
|
||||
# Deprecated because of licensing issues. The Lesser GPL imposes licensing
|
||||
# restrictions on the generated configure script unless it is augmented
|
||||
# with an Autoconf Exception clause.
|
||||
#
|
||||
# SYNOPSIS
|
||||
#
|
||||
# AX_LATEX_CLASS(CLASSNAME,VARIABLETOSET[,ACTION-IF-FOUND[,ACTION-IF-NOT-FOUND]])
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# This macros test is class CLASSNAME exists and work and set
|
||||
# VARIABLETOSET to yes or no If ACTION-IF-FOUND (and ACTION-IF-NOT-FOUND)
|
||||
# are set, do the correct action
|
||||
#
|
||||
# LICENSE
|
||||
#
|
||||
# Copyright (c) 2008 Boretti Mathieu <boretti@eig.unige.ch>
|
||||
# Copyright (c) 2009 Dynare Team
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation; either version 2.1 of the License, or (at
|
||||
# your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
AC_DEFUN([AX_LATEX_CLASS],[
|
||||
AC_CACHE_CHECK([for usability of class $1],[ac_cv_latex_class_]translit($1,[-],[_]),[
|
||||
AX_LATEX_TEST([\documentclass{$1}
|
||||
\begin{document}
|
||||
\end{document}],[ac_cv_latex_class_]translit($1,[-],[_]))
|
||||
])
|
||||
$2=$[ac_cv_latex_class_]translit($1,[-],[_]) ; export $2;
|
||||
AC_SUBST($2)
|
||||
ifelse($#,2,[],$#,3,[
|
||||
if test "[$]$2" = "yes" ;
|
||||
then
|
||||
$3
|
||||
fi
|
||||
],$#,4,[
|
||||
ifelse($3,[],[
|
||||
if test "[$]$2" = "no" ;
|
||||
then
|
||||
$4
|
||||
fi
|
||||
],[
|
||||
if test "[$]$2" = "yes" ;
|
||||
then
|
||||
$3
|
||||
else
|
||||
$4
|
||||
fi
|
||||
])
|
||||
])
|
||||
|
||||
])
|
|
@ -0,0 +1,56 @@
|
|||
# ===========================================================================
|
||||
# http://www.nongnu.org/autoconf-archive/ax_latex_test.html
|
||||
# ===========================================================================
|
||||
#
|
||||
# OBSOLETE MACRO
|
||||
#
|
||||
# Deprecated because of licensing issues. The Lesser GPL imposes licensing
|
||||
# restrictions on the generated configure script unless it is augmented
|
||||
# with an Autoconf Exception clause.
|
||||
#
|
||||
# SYNOPSIS
|
||||
#
|
||||
# AX_LATEX_TEST(FILEDATA,VARIABLETOSET,[NOCLEAN])
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# This macros execute the latex application with FILEDATA as input and set
|
||||
# VARIABLETOSET the yes or no depending of the result if NOCLEAN is set,
|
||||
# the folder used for the test is not delete after testing.
|
||||
#
|
||||
# The macro assumes that the variable PDFLATEX is set.
|
||||
#
|
||||
# LICENSE
|
||||
#
|
||||
# Copyright (c) 2008 Boretti Mathieu <boretti@eig.unige.ch>
|
||||
# Copyright (c) 2009 Dynare Team
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation; either version 2.1 of the License, or (at
|
||||
# your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
AC_DEFUN([AX_LATEX_TEST],[
|
||||
rm -rf conftest.dir/.acltx
|
||||
AS_MKDIR_P([conftest.dir/.acltx])
|
||||
cd conftest.dir/.acltx
|
||||
m4_ifval([$2],[$2="no"; export $2;])
|
||||
cat > conftest.tex << ACLEOF
|
||||
$1
|
||||
ACLEOF
|
||||
cat conftest.tex | $PDFLATEX 2>&1 1>output m4_ifval([$2],[&& $2=yes])
|
||||
cd ..
|
||||
cd ..
|
||||
sed 's/^/| /' conftest.dir/.acltx/conftest.tex >&5
|
||||
echo "$as_me:$LINENO: executing cat conftest.tex | $PDFLATEX" >&5
|
||||
sed 's/^/| /' conftest.dir/.acltx/output >&5
|
||||
m4_ifval([$3],,[rm -rf conftest.dir/.acltx])
|
||||
])
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2003-2017 Dynare Team
|
||||
* Copyright (C) 2003-2018 Dynare Team
|
||||
*
|
||||
* This file is part of Dynare.
|
||||
*
|
||||
|
@ -341,8 +341,7 @@ main(int argc, char **argv)
|
|||
}
|
||||
|
||||
if (!nopreprocessoroutput)
|
||||
cout << "Starting Dynare (version " << PACKAGE_VERSION << ")." << endl
|
||||
<< "Starting preprocessing of the model file ..." << endl;
|
||||
cout << "Starting preprocessing of the model file ..." << endl;
|
||||
|
||||
// Construct basename (i.e. remove file extension if there is one)
|
||||
string basename = argv[1];
|
|
@ -0,0 +1,84 @@
|
|||
SUBDIRS = macro
|
||||
|
||||
BUILT_SOURCES = DynareBison.hh stack.hh position.hh location.hh DynareBison.cc DynareFlex.cc FlexLexer.h
|
||||
|
||||
bin_PROGRAMS = dynare_m
|
||||
|
||||
# We don't put BUILT_SOURCES in dynare_m_SOURCES, otherwise DynareBison.o and DynareFlex.o will be linked two times (Automake translates DynareFlex.ll and DynareBison.yy into their respective .o); so BUILT_SOURCES is in EXTRA_DIST
|
||||
dynare_m_SOURCES = \
|
||||
DynareFlex.ll \
|
||||
DynareBison.yy \
|
||||
ComputingTasks.cc \
|
||||
ComputingTasks.hh \
|
||||
ModelTree.cc \
|
||||
ModelTree.hh \
|
||||
StaticModel.cc \
|
||||
StaticModel.hh \
|
||||
DynamicModel.cc \
|
||||
DynamicModel.hh \
|
||||
NumericalConstants.cc \
|
||||
NumericalConstants.hh \
|
||||
NumericalInitialization.cc \
|
||||
NumericalInitialization.hh \
|
||||
Shocks.cc \
|
||||
Shocks.hh \
|
||||
SigmaeInitialization.cc \
|
||||
SigmaeInitialization.hh \
|
||||
SymbolTable.cc \
|
||||
SymbolTable.hh \
|
||||
SymbolList.cc \
|
||||
SymbolList.hh \
|
||||
ParsingDriver.cc \
|
||||
ParsingDriver.hh \
|
||||
DataTree.cc \
|
||||
DataTree.hh \
|
||||
ModFile.cc \
|
||||
ModFile.hh \
|
||||
ConfigFile.cc \
|
||||
ConfigFile.hh \
|
||||
Statement.cc \
|
||||
Statement.hh \
|
||||
ExprNode.cc \
|
||||
ExprNode.hh \
|
||||
MinimumFeedbackSet.cc \
|
||||
MinimumFeedbackSet.hh \
|
||||
DynareMain.cc \
|
||||
DynareMain1.cc \
|
||||
DynareMain2.cc \
|
||||
CodeInterpreter.hh \
|
||||
ExternalFunctionsTable.cc \
|
||||
ExternalFunctionsTable.hh \
|
||||
SteadyStateModel.hh \
|
||||
SteadyStateModel.cc \
|
||||
WarningConsolidation.hh \
|
||||
WarningConsolidation.cc \
|
||||
ExtendedPreprocessorTypes.hh
|
||||
|
||||
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
EXTRA_DIST = \
|
||||
Doxyfile \
|
||||
$(BUILT_SOURCES)
|
||||
|
||||
# The -I. is for <FlexLexer.h>
|
||||
dynare_m_CPPFLAGS = $(BOOST_CPPFLAGS) -I.
|
||||
dynare_m_LDFLAGS = $(BOOST_LDFLAGS)
|
||||
dynare_m_LDADD = macro/libmacro.a
|
||||
|
||||
DynareFlex.cc FlexLexer.h: DynareFlex.ll
|
||||
$(LEX) -o DynareFlex.cc DynareFlex.ll
|
||||
cp $(LEXINC)/FlexLexer.h . || test -f ./FlexLexer.h
|
||||
|
||||
DynareBison.cc DynareBison.hh location.hh stack.hh position.hh: DynareBison.yy
|
||||
$(YACC) -o DynareBison.cc DynareBison.yy
|
||||
|
||||
all-local: $(PROGRAMS)
|
||||
|
||||
if HAVE_DOXYGEN
|
||||
html-local:
|
||||
$(DOXYGEN)
|
||||
endif
|
||||
|
||||
clean-local:
|
||||
rm -rf doc/html/
|
Loading…
Reference in New Issue