diff --git a/.gitignore b/.gitignore index 9242e59..267e3f8 100755 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,8 @@ # Binary files /bin +/test/performance/boost/bin +/test/performance/boost/obj # 3rd-party libraries. /3rd-party/gtest/usr/ @@ -33,4 +35,5 @@ Makefile /autom4te.cache # Log files -SBG.log +*.log + diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..4ee4cee --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,20 @@ +# Changelog + +## [3.0.0] - 2024-10-09 +### Added +- Implemented Ordered Sets of one-dimensional, compact MDIs. +- Implemented novel versions of Maximum Matching, SCC and Topological Sort of SBG algorithms. +- Implemented Minimum Vertex Cut Set SBG algorithm for Tearing. +- Implemented JSON output for client code. + +## [2.0.0] - 2023-06-05 +### Added +- Implemented parser and pretty-printer for SBG structures. +- Implemented Strongly Connected Components SBG algorithm for the detection of algebraic loops. +- Implemented Topological Sort SBG algorithm for vertical equation ordering. + +## [1.0.0] - 2022-04-04 +### Added +- Implemented SBG structures. +- Implemented Connected Components SBG algorithm for model flattening. +- Implemented Maximum Matching SBG algorithm for horizontal equation ordering. diff --git a/Makefile.in b/Makefile.in index 00d7850..1c778d9 100755 --- a/Makefile.in +++ b/Makefile.in @@ -87,7 +87,7 @@ doc: @mkdir -p $(ROOT)/doc/html @mkdir -p $(ROOT)/doc/latex doxygen sbg/SBG.doxyfile - doxygen sbg/util/UTIL.doxyfile + doxygen util/UTIL.doxyfile test: lib-gtest $(SBG_TEST) diff --git a/README.md b/README.md index 7aec175..36e58b5 100755 --- a/README.md +++ b/README.md @@ -5,6 +5,8 @@ Set-based graphs (SB-Graphs) are graphs in which the vertices and edges are grou * Connected Components * Matching * Strongly Connected Components (SCC) + * Topological Sort + * Minimum Vertex Cut Set This library defines data structures to represent SB-Graphs, and implements the aforementioned algorithms. The related publications can be used as documentation of the code. @@ -12,11 +14,13 @@ This new approach was used in the flatter and causalization stage of the Modelic ## Related Publications -[1] Denise Marzorati, Joaquin Fernández, Ernesto Kofman. Connected Components in Undirected Set--Based Graphs. Applications in Object--Oriented Model Manipulation Applied Mathematics and Computation, Volume 418, 2022, 126842,ISSN 0096-3003, https://doi.org/10.1016/j.amc.2021.126842. +[1] Denise Marzorati, Joaquín Fernández, and Ernesto Kofman. 2024. Efficient Matching in Large DAE Models. ACM Trans. Math. Softw. Just Accepted (June 2024). https://doi.org/10.1145/3674831 -[2] Ernesto Kofman, Joaquín Fernández, Denise Marzorati. Compact sparse symbolic Jacobian computation in large systems of ODEs Applied Mathematics and Computation, Volume 403, 2021, 126181, ISSN 0096-3003, https://doi.org/10.1016/j.amc.2021.126181. +[2] Denise Marzorati, Joaquin Fernández, Ernesto Kofman. Connected Components in Undirected Set--Based Graphs. Applications in Object--Oriented Model Manipulation Applied Mathematics and Computation, Volume 418, 2022, 126842,ISSN 0096-3003, https://doi.org/10.1016/j.amc.2021.126842. -[3] Pablo Zimmermann, Joaquin Fernandez, Ernesto Kofman. +[3] Ernesto Kofman, Joaquín Fernández, Denise Marzorati. Compact sparse symbolic Jacobian computation in large systems of ODEs Applied Mathematics and Computation, Volume 403, 2021, 126181, ISSN 0096-3003, https://doi.org/10.1016/j.amc.2021.126181. + +[4] Pablo Zimmermann, Joaquin Fernandez, Ernesto Kofman. **Set-based graph methods for fast equation sorting in large DAE systems** EOOLT '19: Proceedings of the 9th International Workshop on Equation-based Object-oriented Modeling Languages and Tools 2019 @@ -110,3 +114,12 @@ Please see the file called LICENSE. ## Bug Reporting Report bugs to: marzorati@cifasis-conicet.gov.ar or fernandez@cifasis-conicet.gov.ar + +# Changelog + +## [3.0.0] - 2024-10-09 +### Added +- Implemented Ordered Sets of one-dimensional, compact MDIs. +- Implemented novel versions of Maximum Matching, SCC and Topological Sort of SBG algorithms. +- Implemented Cut Set SBG algorithm for Tearing. +- Implemented JSON output for client code. diff --git a/ast/statement.cpp b/ast/statement.cpp index ebc4505..5c704ba 100755 --- a/ast/statement.cpp +++ b/ast/statement.cpp @@ -41,7 +41,8 @@ ConfigDims::ConfigDims(Util::NAT nmbr_dims) : nmbr_dims_() { if (nmbr_dims > 0) set_nmbr_dims(nmbr_dims); - else Util::ERROR("AST::ConfigDims: Should have ate least one dimension"); + else + Util::ERROR("ConfigDims: dimension should be greater than 0\n"); } member_imp(ConfigDims, Util::NAT, nmbr_dims); diff --git a/deploy/linux/README.md b/deploy/linux/README.md new file mode 100644 index 0000000..f08ee73 --- /dev/null +++ b/deploy/linux/README.md @@ -0,0 +1,23 @@ +**Release procedure** + +- Checkout `sb-graph-release` branch. +- Create branch `release-X.X.X`. +- Merge `sb-graph-dev` -> `sb-graph-release`. +- Update `version` file to `X.X.X`. +- Run `update.sh`. +- Commit update changes with `-n`. +- Update `CHANGELOG` and `README.md` files. +- Commit changes with `-n`. +- Push branch. +- Merge pushed branch in `sb-graph-release` with `--squash`. +- Push `sb-graph-release` branch. +- Merge `sb-graph-release` in `sb-graph-dev`. + +**Github Realease** + +- Select Releases -> Draft a new release. +- Choose the corresponding version tag of the new release. +- Select sb-graph-release as the target branch. +- Update release title and description. +- Upload deb files. +- Publish the release. diff --git a/deploy/linux/build.sh b/deploy/linux/build.sh new file mode 100755 index 0000000..958d93d --- /dev/null +++ b/deploy/linux/build.sh @@ -0,0 +1,110 @@ +#!/bin/bash +#=================================================================================== +# +# FILE: build.sh +# +# USAGE: build.sh +# +# DESCRIPTION: Build the Linux deb package for Set Based Graph Library. +# +# PARAMETERS: --- +# OPTIONS: --- +# REQUIREMENTS: --- +# NOTES: --- +# AUTHOR: Joaquin Fernandez, joaquin.f.fernandez@gmail.com +# PROJECT: Set Based Graph Library +# VERSION: 3.0.0 +#=================================================================================== + +LIB_NAME=sb-graph-lib + +rm -rf $LIB_NAME-*.deb + +cd ../../ +ARCH=`uname -m` +echo "Retrieving latest from Git"; +git pull + +# Set library version +VER=`cat ./deploy/linux/version` + +# Set OS config files. +CONTROL_FILE="control.amd64" +PACKAGE_NAME=$LIB_NAME-$VER +SYSTEM_VERSION=`lsb_release -d` +if [[ "$SYSTEM_VERSION" == *"22.04"* ]]; then + CONTROL_FILE="control.amd64.u22" + PACKAGE_NAME=$PACKAGE_NAME-u22 +fi + +# Set solver branch +BRANCH=`git rev-parse --abbrev-ref HEAD` + +# If build from development branch, update package name to unstable. +if [ "$BRANCH" != "sb-graph-release" ]; then + PACKAGE_NAME=$PACKAGE_NAME-unstable +fi + +PACKAGE_NAME=$PACKAGE_NAME.deb + +echo "Building SB Graph DEB package for $ARCH version $VER"; +echo "Building Binaries"; +autoconf +./configure +make clean +make + +echo "Creating temp folders..." +rm -rf tmp_deb +rm -rf tmp +mkdir tmp_deb +mkdir tmp +echo "Done." + +echo "Export repo to temp folder..." +CHECKOUT_PATH=./tmp/ +mkdir -p $CHECKOUT_PATH +git checkout-index -a -f --prefix=$CHECKOUT_PATH +echo "Done." + +echo "Export tmp files to deb container..." + +USER_FOLDER=usr +INSTALL_FOLDER=$USER_FOLDER/local +INCLUDE=include +LIB=lib +BIN=bin + +cp -r ./deploy/linux/deb/* ./tmp_deb/ +chmod 0755 tmp_deb/DEBIAN/post* +mkdir ./tmp_deb/$USER_FOLDER +mkdir ./tmp_deb/$INSTALL_FOLDER +mkdir ./tmp_deb/$INSTALL_FOLDER/$BIN +mkdir ./tmp_deb/$INSTALL_FOLDER/$INCLUDE +mkdir ./tmp_deb/$INSTALL_FOLDER/$INCLUDE/sb-graph +mkdir ./tmp_deb/$INSTALL_FOLDER/$INCLUDE/sb-graph/ast +mkdir ./tmp_deb/$INSTALL_FOLDER/$INCLUDE/sb-graph/eval +mkdir ./tmp_deb/$INSTALL_FOLDER/$INCLUDE/sb-graph/parser +mkdir ./tmp_deb/$INSTALL_FOLDER/$INCLUDE/sb-graph/sbg +mkdir ./tmp_deb/$INSTALL_FOLDER/$INCLUDE/sb-graph/util +mkdir ./tmp_deb/$INSTALL_FOLDER/$LIB + +cat ./tmp_deb/DEBIAN/$CONTROL_FILE | awk -v VERSION="$VER" '{ if(index($0,"Version:")>=1) print "Version: " VERSION ; else print $0;}' > ./tmp_deb/DEBIAN/control +rm ./tmp_deb/DEBIAN/$CONTROL_FILE + +cp bin/sbg-eval ./tmp_deb/$INSTALL_FOLDER/$BIN +cp bin/sbg-parser ./tmp_deb/$INSTALL_FOLDER/$BIN +cp lib/libsbgraph.a ./tmp_deb/$INSTALL_FOLDER/$LIB +cp -r ./tmp/ast/*.hpp ./tmp_deb/$INSTALL_FOLDER/$INCLUDE/sb-graph/ast +cp -r ./tmp/eval/*.hpp ./tmp_deb/$INSTALL_FOLDER/$INCLUDE/sb-graph/eval +cp -r ./tmp/parser/*.hpp ./tmp_deb/$INSTALL_FOLDER/$INCLUDE/sb-graph/parser +cp -r ./tmp/sbg/*.hpp ./tmp_deb/$INSTALL_FOLDER/$INCLUDE/sb-graph/sbg +cp -r ./tmp/util/*.hpp ./tmp_deb/$INSTALL_FOLDER/$INCLUDE/sb-graph/util + +chmod 0644 `find tmp_deb/ -iname *.hpp` +chmod 0755 `find tmp_deb/ -type d` +fakeroot dpkg -b tmp_deb $LIB_NAME.deb +mv $LIB_NAME.deb ./deploy/linux/$PACKAGE_NAME +rm -rf tmp_deb +rm -rf tmp +cd deploy/linux diff --git a/deploy/linux/deb/DEBIAN/control.amd64 b/deploy/linux/deb/DEBIAN/control.amd64 new file mode 100644 index 0000000..7f53368 --- /dev/null +++ b/deploy/linux/deb/DEBIAN/control.amd64 @@ -0,0 +1,9 @@ +Package: sb-graph-lib +Version: +Architecture: amd64 +Maintainer: Denise Marzorati +Installed-Size: 801758 +Section: science +Priority: extra +Homepage: https://github.com/CIFASIS/sb-graph +Description: Set Based Graph library. diff --git a/deploy/linux/deb/DEBIAN/control.amd64.u22 b/deploy/linux/deb/DEBIAN/control.amd64.u22 new file mode 100644 index 0000000..e710409 --- /dev/null +++ b/deploy/linux/deb/DEBIAN/control.amd64.u22 @@ -0,0 +1,9 @@ +Package: sb-graph-lib +Version: +Architecture: amd64 +Maintainer: Denise Marzorati +Installed-Size: 801758 +Section: science +Priority: extra +Homepage: https://github.com/CIFASIS/sb-graph +Description: Set Based Graph library. diff --git a/deploy/linux/deb/DEBIAN/postinst b/deploy/linux/deb/DEBIAN/postinst new file mode 100755 index 0000000..a3b7e37 --- /dev/null +++ b/deploy/linux/deb/DEBIAN/postinst @@ -0,0 +1,2 @@ +#!/bin/sh +# End automatically added section diff --git a/deploy/linux/deb/DEBIAN/postrm b/deploy/linux/deb/DEBIAN/postrm new file mode 100755 index 0000000..1261329 --- /dev/null +++ b/deploy/linux/deb/DEBIAN/postrm @@ -0,0 +1,3 @@ +#!/bin/sh +# Automatically added by dh_installmenu +# End automatically added section diff --git a/deploy/linux/update-version.sh b/deploy/linux/update-version.sh new file mode 100755 index 0000000..1ebe74b --- /dev/null +++ b/deploy/linux/update-version.sh @@ -0,0 +1,29 @@ +#!/bin/bash +#=================================================================================== +# +# FILE: update-version.sh +# +# USAGE: update-version.sh +# +# DESCRIPTION: Helper script to update version info in all project related files. +# +# PARAMETERS: --- +# OPTIONS: --- +# REQUIREMENTS: --- +# NOTES: --- +# AUTHOR: Joaquin Fernandez, joaquin.f.fernandez@gmail.com +# PROJECT: Set Based Graph Library +#=================================================================================== + +VER=`cat ./version` + +# Update deploy files. +sed -i "s/VERSION:.*/VERSION: $VER/" ./build.sh + +# Update doxyfiles. +sed -i "s/PROJECT_NUMBER =.*/PROJECT_NUMBER = $VER/" ../../sbg/SBG.doxyfile +sed -i "s/PROJECT_NUMBER =.*/PROJECT_NUMBER = $VER/" ../../util/UTIL.doxyfile + +# Update main bynary files version. +sed -i "s/SBG library v.*/SBG library v$VER\" << std::endl;/" ../../parser/main.cpp +sed -i "s/SBG library v.*/SBG library v$VER\" << std::endl;/" ../../eval/main.cpp \ No newline at end of file diff --git a/deploy/linux/version b/deploy/linux/version new file mode 100644 index 0000000..4a36342 --- /dev/null +++ b/deploy/linux/version @@ -0,0 +1 @@ +3.0.0 diff --git a/eval/Makefile.include b/eval/Makefile.include index 256b970..63a435f 100755 --- a/eval/Makefile.include +++ b/eval/Makefile.include @@ -10,7 +10,6 @@ EVAL := bin/sbg-eval all: $(EVAL) EVAL_SRC := \ - $(UTIL_DIR)/debug.cpp \ $(UTIL_DIR)/defs.cpp \ $(UTIL_DIR)/logger.cpp \ $(EVAL_DIR)/main.cpp \ diff --git a/eval/defs.cpp b/eval/defs.cpp index bb39984..71b58f7 100755 --- a/eval/defs.cpp +++ b/eval/defs.cpp @@ -23,6 +23,8 @@ namespace SBG { namespace Eval { +using Util::operator<<; + // Environments ---------------------------------------------------------------- VarEnv::VarEnv() : mapping_() {} @@ -41,11 +43,11 @@ MaybeVValue VarEnv::operator[](VKey k) const FuncEnv::FuncEnv() {} FuncEnvType FuncEnv::mapping_ = { - {"isEmpty", 0}, {"isMember", 1}, {"minElem", 2}, {"maxElem", 3}, {"lt", 4} - , {"compose", 5}, {"inv", 6}, {"image", 7}, {"preImage", 8}, {"dom", 9} - , {"combine", 10}, {"firstInv", 11}, {"minMap", 12}, {"reduce", 13} - , {"minAdj", 14}, {"mapInf", 15}, {"CC", 16}, {"matching", 17}, {"scc", 18} - , {"sort", 19}, {"matchSCC", 20}, {"matchSCCTS", 21}, {"cut", 22} + {"isEmpty", 0}, {"minElem", 1}, {"maxElem", 2} + , {"compose", 3}, {"inv", 4}, {"image", 5}, {"preImage", 6}, {"dom", 7} + , {"combine", 8}, {"firstInv", 9}, {"minMap", 10}, {"reduce", 11} + , {"minAdj", 12}, {"mapInf", 13}, {"CC", 14}, {"matching", 15}, {"scc", 16} + , {"sort", 17}, {"matchSCC", 18}, {"matchSCCTS", 19}, {"cut", 20} }; MaybeFValue FuncEnv::operator[](FKey k) const @@ -57,21 +59,20 @@ MaybeFValue FuncEnv::operator[](FKey k) const // Classes for pretty printing ------------------------------------------------ template -std::ostream& operator<<(std::ostream& os, const std::variant& v) +std::ostream &operator<<(std::ostream &out, const std::variant &v) { - std::visit([&os](auto&& arg) { - os << arg; - }, v); - return os; + std::visit([&out](auto&& arg) { + out << arg; + }, v); + + return out; } std::ostream &operator<<(std::ostream &out, const ExprEval &e) { out << std::get<0>(e) << "\n --> "; ExprBaseType ebt = std::get<1>(e); - auto printer = [&](auto v) { out << v; }; - std::visit(printer, ebt); - out << "\n"; + out << ebt << "\n"; return out; } diff --git a/eval/defs.hpp b/eval/defs.hpp index 12def44..6fecb7a 100755 --- a/eval/defs.hpp +++ b/eval/defs.hpp @@ -121,12 +121,15 @@ struct FuncEnv{ static FuncEnvType mapping_; }; -typedef enum { empty, member, min, max, lt, comp, inv, im, preim, dom, comb +typedef enum { empty, min, max, comp, inv, im, preim, dom, comb , first_inv, min_map, red, min_adj, inf, connected, matching, scc, ts , match_scc, match_scc_ts, cut_set } Func; // Classes for pretty printing ------------------------------------------------ +template +std::ostream &operator<<(std::ostream &out, const std::variant &v); + typedef std::tuple ExprEval; std::ostream &operator<<(std::ostream &out, const ExprEval &e); typedef std::vector ExprEvalList; diff --git a/eval/main.cpp b/eval/main.cpp index 9942723..e71ad2c 100755 --- a/eval/main.cpp +++ b/eval/main.cpp @@ -35,7 +35,7 @@ void parseEvalProgramFromFile(std::string fname, bool debug) { std::ifstream in(fname.c_str()); if (in.fail()) - SBG::Util::ERROR("Unable to open file"); + SBG::Util::ERROR("Unable to open file ", fname, "\n"); in.unsetf(std::ios::skipws); std::string str( @@ -80,17 +80,92 @@ void usage() std::cout << std::endl; std::cout << "-f, --file SBG program file used as input " << std::endl; std::cout << "-h, --help Display this information and exit" << std::endl; - std::cout << "-d, --debug Activate debug" << std::endl; + std::cout << "-d, --debug Activate debug info" << std::endl; std::cout << "-v, --version Display version information and exit" << std::endl; std::cout << std::endl; std::cout << "SBG library home page: https://github.com/CIFASIS/sb-graph" << std::endl; + + std::cout << "\nThe grammar for a SBG program can be derived from the .cpp\n" + << " files present in /parser.\n"; + std::cout << "The following rules are used to avoid ambiguities:\n"; + std::cout << " * Naturals are evaluated into md_nat (with arity equal 1).\n"; + std::cout << " * Since a natural can be parsed both into an\n"; + std::cout << " an interval or a mdi interval with arity equal to 1, it\n"; + std::cout << " will be interpreted as an interval.\n"; + std::cout << " To test operations of mdis, single elements sets can be\n"; + std::cout << " used, i.e.: {[1:1:10] x [1:1:10]} /\\ {[5:1:10] x [5:1:10]}."; + std::cout << "\n * The same situation arises for le and mdle, for which the\n"; + std::cout << " same criteria is used.\n"; + std::cout << " * In a file all elements should be of the same arity (i.e., \n"; + std::cout << " have the same number of dimensions).\n"; + + std::cout << "\n\nA comprehensive list of the available functions to call on SBG" + << " elements,\nwith a short description of the permitted arguments is"; + std::cout << " as follows:\n"; + std::cout << " - isEmpty: check if container is empty\n"; + std::cout << " --> isEmpty(interval) | isEmpty(set)\n"; + std::cout << "\n - isMember: check if an element belongs to a container\n"; + std::cout << " --> isMember(nat, interval)\n"; + std::cout << "\n - minElem: minimum element of a container\n"; + std::cout << " --> minElem(interval) | minElem(set)\n"; + std::cout << "\n - maxElem: maximum element of a container\n"; + std::cout << " --> maxElem(interval) | maxElem(set)\n"; + std::cout << "\n - compose: composition of expressions or maps\n"; + std::cout << " --> compose(lexp, lexp) | compose(mdlexp, mdlexp)\n"; + std::cout << " | compose(map, map) | compose(pw, pw)\n"; + std::cout << "\n - inv: calculate the inverse of an expression.\n"; + std::cout << " If the expression is constant in some dimension, returns\n"; + std::cout << " inf-inf there\n"; + std::cout << " --> inv(lexp) | inv(mdlexp)\n"; + std::cout << "\n - image: return the image for a set of elements of the domain"; + std::cout << "\n --> image(set, map) | image(set, pw)\n"; + std::cout << "\n - preImage: return the pre-image for a set of elements in the\n"; + std::cout << " image of the map\n"; + std::cout << " --> preImage(set, map) | preImage(set, pw)\n"; + std::cout << "\n - dom: return the whole domain of a piecewise-linear map\n"; + std::cout << " --> dom(pw)\n"; + std::cout << "\n - combine: return a new map with the union of the two domains\n"; + std::cout << " mapping to the first argument for elements in its domain\n"; + std::cout << " and to the second one for the remaining elements\n"; + std::cout << " --> combine(pw, pw)\n"; + std::cout << "\n - firstInv: calculate an inverse of a piecewise-linear map.\n"; + std::cout << " If some image y is shared by more than one element return\n"; + std::cout << " any of its pre-images.\n"; + std::cout << " --> firstInv(pw)\n"; + std::cout << "\n - minMap: return a new piecewise-linear map that maps each\n"; + std::cout << " element in both domains to the minimum image between the\n"; + std::cout << " two arguments\n"; + std::cout << " --> minMap(pw1, pw2)\n"; + std::cout << "\n - reduce: return a piecewise-linear map to which the argument\n"; + std::cout << " converges to\n"; + std::cout << " --> reduce(pw)\n"; + std::cout << "\n - minAdj: given two piecewise-linear maps with the same domain\n"; + std::cout << " for each image y = pw1(x) map to the minimum y' such that\n"; + std::cout << " y' = pw2(x)\n"; + std::cout << " --> minAdj(pw1, pw2)\n"; + std::cout << "\n - mapInf: compose the argument with itself until it converges\n"; + std::cout << " --> mapInf(pw)\n"; + std::cout << "\n - CC: calculate the connected components of a SBG\n"; + std::cout << " --> CC(sbg)\n"; + std::cout << "\n - matching: calculate a maximum matching of n copies of a SBG\n"; + std::cout << " --> matching(sbg, nat)\n"; + std::cout << "\n - scc: calculate the strongly connected components of a DSBG\n"; + std::cout << " --> scc(dsbg)\n"; + std::cout << "\n - sort: calculate a topological sort a DSBG\n"; + std::cout << " --> sort(dsbg)\n"; + std::cout << "\n - matchSCC: calculate matching+scc for n copies of a SBG\n"; + std::cout << " --> matchSCC(sbg, nat)\n"; + std::cout << "\n - matchSCCTS: calculate matching+scc+sort for n copies of a SBG\n"; + std::cout << " --> matchSCCTS(sbg, nat)\n"; + std::cout << "\n - cut: calculate a (possibly minimum) cut set for a DSBG\n"; + std::cout << " --> cut(dsbg)\n"; } void version() { - std::cout << "SBG library v3.0\n"; + std::cout << "SBG library v3.0.0" << std::endl; std::cout << "License GPLv3+: GNU GPL version 3 or later" << " \n"; std::cout << "This is free software: you are free to change and redistribute" @@ -98,6 +173,7 @@ void version() std::cout << "There is NO WARRANTY, to the extent permitted by law.\n"; } + int main(int argc, char**argv) { std::string filename; @@ -139,7 +215,7 @@ int main(int argc, char**argv) if (!filename.empty()) parseEvalProgramFromFile(filename, debug); else - SBG::Util::ERROR("A filename should be provided"); + SBG::Util::ERROR("A filename should be provided\n"); return 0; } diff --git a/eval/visitors/check_opt_conds.cpp b/eval/visitors/check_opt_conds.cpp index 39cdae1..4c1b64f 100755 --- a/eval/visitors/check_opt_conds.cpp +++ b/eval/visitors/check_opt_conds.cpp @@ -94,9 +94,7 @@ bool OptConds::operator()(AST::InterBinOp v) const return l && r; default: - std::stringstream ss; - ss << v.op(); - Util::ERROR("OptConds: InterBinOp %s not supported.", ss.str().c_str()); + Util::ERROR("OptConds: InterBinOp ", v.op(), " unsupported\n"); return false; } } @@ -125,9 +123,7 @@ bool OptConds::operator()(AST::MDInterBinOp v) const return l && r; default: - std::stringstream ss; - ss << v.op(); - Util::ERROR("OptConds: MDInterBinOp %s not supported.", ss.str().c_str()); + Util::ERROR("OptConds: MDInterBinOp ", v.op(), " unsupported\n"); return false; } } @@ -159,9 +155,7 @@ bool OptConds::operator()(AST::SetBinOp v) const return l && r; default: - std::stringstream ss; - ss << v.op(); - Util::ERROR("EvalUnordSet: SetBinOp %s not supported.", ss.str().c_str()); + Util::ERROR("EvalUnordSet: SetBinOp ", v.op(), " unsupported\n"); return false; } } diff --git a/eval/visitors/eval_base_dsbg.cpp b/eval/visitors/eval_base_dsbg.cpp index e8ba6a5..8f193b9 100755 --- a/eval/visitors/eval_base_dsbg.cpp +++ b/eval/visitors/eval_base_dsbg.cpp @@ -28,25 +28,25 @@ EvalBaseDSBG::EvalBaseDSBG(VarEnv env) : env_(env) {} LIB::BaseDSBG EvalBaseDSBG::operator()(AST::Natural v) const { - Util::ERROR("EvalBaseDSBG: trying to evaluate a Natural"); + Util::ERROR("EvalBaseDSBG: trying to evaluate Natural ", v, "\n"); return LIB::BaseDSBG(); } LIB::BaseDSBG EvalBaseDSBG::operator()(AST::MDNatural v) const { - Util::ERROR("EvalBaseDSBG: trying to evaluate a MDNatural"); + Util::ERROR("EvalBaseDSBG: trying to evaluate MDNatural ", v, "\n"); return LIB::BaseDSBG(); } LIB::BaseDSBG EvalBaseDSBG::operator()(AST::Rational v) const { - Util::ERROR("EvalBaseDSBG: trying to evaluate a Rational"); + Util::ERROR("EvalBaseDSBG: trying to evaluate Rational ", v, "\n"); return LIB::BaseDSBG(); } LIB::BaseDSBG EvalBaseDSBG::operator()(AST::Boolean v) const { - Util::ERROR("EvalBaseDSBG: trying to evaluate a Boolean"); + Util::ERROR("EvalBaseDSBG: trying to evaluate Boolean ", v, "\n"); return LIB::BaseDSBG(); } @@ -62,126 +62,126 @@ LIB::BaseDSBG EvalBaseDSBG::operator()(Util::VariableName v) const } else { - Util::ERROR("EvalBaseDSBG: variable %s is not a PWMap", v.c_str()); + Util::ERROR("EvalBaseDSBG: variable ", v, " is not a PWMap\n"); return LIB::BaseDSBG(); } } - Util::ERROR("EvalBaseDSBG: variable %s not defined", v.c_str()); + Util::ERROR("EvalBaseDSBG: variable ", v, " undefined\n"); return LIB::BaseDSBG(); } LIB::BaseDSBG EvalBaseDSBG::operator()(AST::UnaryOp v) const { - Util::ERROR("EvalBaseDSBG: trying to evaluate an arithmetic BinOp"); + Util::ERROR("EvalBaseDSBG: trying to evaluate arithmetic UnaryOp ", v, "\n"); return LIB::BaseDSBG(); } LIB::BaseDSBG EvalBaseDSBG::operator()(AST::BinOp v) const { - Util::ERROR("EvalBaseDSBG: trying to evaluate an arithmetic BinOp"); + Util::ERROR("EvalBaseDSBG: trying to evaluate arithmetic BinOp ", v, "\n"); return LIB::BaseDSBG(); } LIB::BaseDSBG EvalBaseDSBG::operator()(AST::Call v) const { - Util::ERROR("EvalBaseDSBG: trying to evaluate a Call"); + Util::ERROR("EvalBaseDSBG: trying to evaluate Call ", v, "\n"); return LIB::BaseDSBG(); } LIB::BaseDSBG EvalBaseDSBG::operator()(AST::Interval v) const { - Util::ERROR("EvalBaseDSBG: trying to evaluate an Interval"); + Util::ERROR("EvalBaseDSBG: trying to evaluate Interval ", v, "\n"); return LIB::BaseDSBG(); } LIB::BaseDSBG EvalBaseDSBG::operator()(AST::InterUnaryOp v) const { - Util::ERROR("EvalBaseDSBG: trying to evaluate an InterUnaryOp"); + Util::ERROR("EvalBaseDSBG: trying to evaluate InterUnaryOp ", v, "\n"); return LIB::BaseDSBG(); } LIB::BaseDSBG EvalBaseDSBG::operator()(AST::InterBinOp v) const { - Util::ERROR("EvalBaseDSBG: trying to evaluate an InterBinOp"); + Util::ERROR("EvalBaseDSBG: trying to evaluate InterBinOp ", v, "\n"); return LIB::BaseDSBG(); } LIB::BaseDSBG EvalBaseDSBG::operator()(AST::MultiDimInter v) const { - Util::ERROR("EvalBaseDSBG: trying to evaluate an MultiDimInter"); + Util::ERROR("EvalBaseDSBG: trying to evaluate MultiDimInter ", v, "\n"); return LIB::BaseDSBG(); } LIB::BaseDSBG EvalBaseDSBG::operator()(AST::MDInterUnaryOp v) const { - Util::ERROR("EvalBaseDSBG: trying to evaluate an MDInterUnaryOp"); + Util::ERROR("EvalBaseDSBG: trying to evaluate MDInterUnaryOp ", v, "\n"); return LIB::BaseDSBG(); } LIB::BaseDSBG EvalBaseDSBG::operator()(AST::MDInterBinOp v) const { - Util::ERROR("EvalBaseDSBG: trying to evaluate an MDInterBinOp"); + Util::ERROR("EvalBaseDSBG: trying to evaluate MDInterBinOp ", v, "\n"); return LIB::BaseDSBG(); } LIB::BaseDSBG EvalBaseDSBG::operator()(AST::Set v) const { - Util::ERROR("EvalBaseDSBG: trying to evaluate a Set"); + Util::ERROR("EvalBaseDSBG: trying to evaluate Set ", v, "\n"); return LIB::BaseDSBG(); } LIB::BaseDSBG EvalBaseDSBG::operator()(AST::SetUnaryOp v) const { - Util::ERROR("EvalBaseDSBG: trying to evaluate a SetUnaryOp"); + Util::ERROR("EvalBaseDSBG: trying to evaluate SetUnaryOp ", v, "\n"); return LIB::BaseDSBG(); } LIB::BaseDSBG EvalBaseDSBG::operator()(AST::SetBinOp v) const { - Util::ERROR("EvalBaseDSBG: trying to evaluate a SetBinOp"); + Util::ERROR("EvalBaseDSBG: trying to evaluate SetBinOp ", v, "\n"); return LIB::BaseDSBG(); } LIB::BaseDSBG EvalBaseDSBG::operator()(AST::LinearExp v) const { - Util::ERROR("EvalBaseDSBG: trying to evaluate a LinearExp"); + Util::ERROR("EvalBaseDSBG: trying to evaluate LinearExp ", v, "\n"); return LIB::BaseDSBG(); } LIB::BaseDSBG EvalBaseDSBG::operator()(AST::LExpBinOp v) const { - Util::ERROR("EvalBaseDSBG: trying to evaluate a LExpBinOp"); + Util::ERROR("EvalBaseDSBG: trying to evaluate LExpBinOp ", v, "\n"); return LIB::BaseDSBG(); } LIB::BaseDSBG EvalBaseDSBG::operator()(AST::MDLExp v) const { - Util::ERROR("EvalBaseDSBG: trying to evaluate a MDLExp"); + Util::ERROR("EvalBaseDSBG: trying to evaluate MDLExp ", v, "\n"); return LIB::BaseDSBG(); } LIB::BaseDSBG EvalBaseDSBG::operator()(AST::MDLExpBinOp v) const { - Util::ERROR("EvalBaseDSBG: trying to evaluate a MDLExpBinOp"); + Util::ERROR("EvalBaseDSBG: trying to evaluate MDLExpBinOp ", v, "\n"); return LIB::BaseDSBG(); } LIB::BaseDSBG EvalBaseDSBG::operator()(AST::LinearMap v) const { - Util::ERROR("EvalBaseDSBG: trying to evaluate a LinearMap"); + Util::ERROR("EvalBaseDSBG: trying to evaluate LinearMap ", v, "\n"); return LIB::BaseDSBG(); } LIB::BaseDSBG EvalBaseDSBG::operator()(AST::PWLMap v) const { - Util::ERROR("EvalBaseDSBG: trying to evaluate a PWLMap"); + Util::ERROR("EvalBaseDSBG: trying to evaluate PWLMap ", v, "\n"); return LIB::BaseDSBG(); } LIB::BaseDSBG EvalBaseDSBG::operator()(AST::SBG v) const { - Util::ERROR("EvalBaseDSBG: trying to evaluate a SBG"); + Util::ERROR("EvalBaseDSBG: trying to evaluate SBG ", v, "\n"); return LIB::BaseDSBG(); } diff --git a/eval/visitors/eval_base_map.cpp b/eval/visitors/eval_base_map.cpp index 1d3b392..3b1799f 100755 --- a/eval/visitors/eval_base_map.cpp +++ b/eval/visitors/eval_base_map.cpp @@ -28,25 +28,25 @@ EvalBaseMap::EvalBaseMap(VarEnv env) : env_(env) {} LIB::BaseMap EvalBaseMap::operator()(AST::Natural v) const { - Util::ERROR("EvalBaseMap: trying to evaluate a Natural"); + Util::ERROR("EvalBaseMap: trying to evaluate Natural ", v, "\n"); return LIB::BaseMap(); } LIB::BaseMap EvalBaseMap::operator()(AST::MDNatural v) const { - Util::ERROR("EvalBaseMap: trying to evaluate a MDNatural"); + Util::ERROR("EvalBaseMap: trying to evaluate MDNatural ", v, "\n"); return LIB::BaseMap(); } LIB::BaseMap EvalBaseMap::operator()(AST::Rational v) const { - Util::ERROR("EvalBaseMap: trying to evaluate a Rational"); + Util::ERROR("EvalBaseMap: trying to evaluate Rational ", v, "\n"); return LIB::BaseMap(); } LIB::BaseMap EvalBaseMap::operator()(AST::Boolean v) const { - Util::ERROR("EvalBaseMap: trying to evaluate a Boolean"); + Util::ERROR("EvalBaseMap: trying to evaluate Boolean ", v, "\n"); return LIB::BaseMap(); } @@ -62,108 +62,108 @@ LIB::BaseMap EvalBaseMap::operator()(Util::VariableName v) const } else { - Util::ERROR("EvalBaseMap: variable %s is not a linear expression", v.c_str()); + Util::ERROR("EvalBaseMap: variable ", v, " is not a linear expression\n"); return LIB::BaseMap(); } } - Util::ERROR("EvalBaseMap: variable %s not defined", v.c_str()); + Util::ERROR("EvalBaseMap: variable ", v, " undefined"); return LIB::BaseMap(); } LIB::BaseMap EvalBaseMap::operator()(AST::UnaryOp v) const { - Util::ERROR("EvalBaseMap: trying to evaluate an arithmetic UnaryOp"); + Util::ERROR("EvalBaseMap: trying to evaluate arithmetic UnaryOp ", v, "\n"); return LIB::BaseMap(); } LIB::BaseMap EvalBaseMap::operator()(AST::BinOp v) const { - Util::ERROR("EvalBaseMap: trying to evaluate an arithmetic BinOp"); + Util::ERROR("EvalBaseMap: trying to evaluate arithmetic BinOp ", v, "\n"); return LIB::BaseMap(); } LIB::BaseMap EvalBaseMap::operator()(AST::Call v) const { - Util::ERROR("EvalBaseMap: trying to evaluate a Call"); + Util::ERROR("EvalBaseMap: trying to evaluate Call ", v, "\n"); return LIB::BaseMap(); } LIB::BaseMap EvalBaseMap::operator()(AST::Interval v) const { - Util::ERROR("EvalBaseMap: trying to evaluate an Interval"); + Util::ERROR("EvalBaseMap: trying to evaluate Interval ", v, "\n"); return LIB::BaseMap(); } LIB::BaseMap EvalBaseMap::operator()(AST::InterUnaryOp v) const { - Util::ERROR("EvalBaseMap: trying to evaluate an InterUnaryOp"); + Util::ERROR("EvalBaseMap: trying to evaluate InterUnaryOp ", v, "\n"); return LIB::BaseMap(); } LIB::BaseMap EvalBaseMap::operator()(AST::InterBinOp v) const { - Util::ERROR("EvalBaseMap: trying to evaluate an InterBinOp"); + Util::ERROR("EvalBaseMap: trying to evaluate InterBinOp ", v, "\n"); return LIB::BaseMap(); } LIB::BaseMap EvalBaseMap::operator()(AST::MultiDimInter v) const { - Util::ERROR("EvalBaseMap: trying to evaluate an MultiDimInter"); + Util::ERROR("EvalBaseMap: trying to evaluate MultiDimInter ", v, "\n"); return LIB::BaseMap(); } LIB::BaseMap EvalBaseMap::operator()(AST::MDInterUnaryOp v) const { - Util::ERROR("EvalBaseMap: trying to evaluate an MDInterUnaryOp"); + Util::ERROR("EvalBaseMap: trying to evaluate MDInterUnaryOp ", v, "\n"); return LIB::BaseMap(); } LIB::BaseMap EvalBaseMap::operator()(AST::MDInterBinOp v) const { - Util::ERROR("EvalBaseMap: trying to evaluate an MDInterBinOp"); + Util::ERROR("EvalBaseMap: trying to evaluate MDInterBinOp ", v, "\n"); return LIB::BaseMap(); } LIB::BaseMap EvalBaseMap::operator()(AST::Set v) const { - Util::ERROR("EvalBaseMap: trying to evaluate a Set"); + Util::ERROR("EvalBaseMap: trying to evaluate Set ", v, "\n"); return LIB::BaseMap(); } LIB::BaseMap EvalBaseMap::operator()(AST::SetUnaryOp v) const { - Util::ERROR("EvalBaseMap: trying to evaluate a SetUnaryOp"); + Util::ERROR("EvalBaseMap: trying to evaluate SetUnaryOp ", v, "\n"); return LIB::BaseMap(); } LIB::BaseMap EvalBaseMap::operator()(AST::SetBinOp v) const { - Util::ERROR("EvalBaseMap: trying to evaluate a SetBinOp"); + Util::ERROR("EvalBaseMap: trying to evaluate SetBinOp ", v, "\n"); return LIB::BaseMap(); } LIB::BaseMap EvalBaseMap::operator()(AST::LinearExp v) const { - Util::ERROR("EvalBaseMap: trying to evaluate a LinearExp"); + Util::ERROR("EvalBaseMap: trying to evaluate LinearExp ", v, "\n"); return LIB::BaseMap(); } LIB::BaseMap EvalBaseMap::operator()(AST::LExpBinOp v) const { - Util::ERROR("EvalBaseMap: trying to evaluate a LExpBinOp"); + Util::ERROR("EvalBaseMap: trying to evaluate LExpBinOp ", v, "\n"); return LIB::BaseMap(); } -LIB::BaseMap EvalBaseMap::operator()(AST::MDLExp le) const +LIB::BaseMap EvalBaseMap::operator()(AST::MDLExp v) const { - Util::ERROR("EvalBaseMap: trying to evaluate a MDLExp"); + Util::ERROR("EvalBaseMap: trying to evaluate MDLExp ", v, "\n"); return LIB::BaseMap(); } LIB::BaseMap EvalBaseMap::operator()(AST::MDLExpBinOp v) const { - Util::ERROR("EvalBaseMap: trying to evaluate a MDLExpBinOp"); + Util::ERROR("EvalBaseMap: trying to evaluate MDLExpBinOp ", v, "\n"); return LIB::BaseMap(); } @@ -178,19 +178,19 @@ LIB::BaseMap EvalBaseMap::operator()(AST::LinearMap v) const LIB::BaseMap EvalBaseMap::operator()(AST::PWLMap v) const { - Util::ERROR("EvalBaseMap: trying to evaluate a PWLMap"); + Util::ERROR("EvalBaseMap: trying to evaluate PWLMap ", v, "\n"); return LIB::BaseMap(); } LIB::BaseMap EvalBaseMap::operator()(AST::SBG v) const { - Util::ERROR("EvalBaseMap: trying to evaluate a SBG"); + Util::ERROR("EvalBaseMap: trying to evaluate SBG ", v, "\n"); return LIB::BaseMap(); } LIB::BaseMap EvalBaseMap::operator()(AST::DSBG v) const { - Util::ERROR("EvalBaseMap: trying to evaluate a DSBG"); + Util::ERROR("EvalBaseMap: trying to evaluate DSBG ", v, "\n"); return LIB::BaseMap(); } diff --git a/eval/visitors/eval_base_pwmap.cpp b/eval/visitors/eval_base_pwmap.cpp index ea6f21e..f42d893 100755 --- a/eval/visitors/eval_base_pwmap.cpp +++ b/eval/visitors/eval_base_pwmap.cpp @@ -28,25 +28,25 @@ EvalBasePWMap::EvalBasePWMap(VarEnv env) : env_(env) {} LIB::BasePWMap EvalBasePWMap::operator()(AST::Natural v) const { - Util::ERROR("EvalBasePWMap: trying to evaluate a Natural"); + Util::ERROR("EvalBasePWMap: trying to evaluate Natural ", v, "\n"); return LIB::BasePWMap(); } LIB::BasePWMap EvalBasePWMap::operator()(AST::MDNatural v) const { - Util::ERROR("EvalBasePWMap: trying to evaluate a MDNatural"); + Util::ERROR("EvalBasePWMap: trying to evaluate MDNatural ", v, "\n"); return LIB::BasePWMap(); } LIB::BasePWMap EvalBasePWMap::operator()(AST::Rational v) const { - Util::ERROR("EvalBasePWMap: trying to evaluate a Rational"); + Util::ERROR("EvalBasePWMap: trying to evaluate Rational ", v, "\n"); return LIB::BasePWMap(); } LIB::BasePWMap EvalBasePWMap::operator()(AST::Boolean v) const { - Util::ERROR("EvalBasePWMap: trying to evaluate a Boolean"); + Util::ERROR("EvalBasePWMap: trying to evaluate Boolean ", v, "\n"); return LIB::BasePWMap(); } @@ -62,114 +62,114 @@ LIB::BasePWMap EvalBasePWMap::operator()(Util::VariableName v) const } else { - Util::ERROR("EvalBasePWMap: variable %s is not a PWMap", v.c_str()); + Util::ERROR("EvalBasePWMap: variable ", v, " is not a PWMap\n"); return LIB::BasePWMap(); } } - Util::ERROR("EvalBasePWMap: variable %s not defined", v.c_str()); + Util::ERROR("EvalBasePWMap: variable ", v, " undefined\n"); return LIB::BasePWMap(); } LIB::BasePWMap EvalBasePWMap::operator()(AST::UnaryOp v) const { - Util::ERROR("EvalBasePWMap: trying to evaluate an arithmetic BinOp"); + Util::ERROR("EvalBasePWMap: trying to evaluate arithmetic UnaryOp ", v, "\n"); return LIB::BasePWMap(); } LIB::BasePWMap EvalBasePWMap::operator()(AST::BinOp v) const { - Util::ERROR("EvalBasePWMap: trying to evaluate an arithmetic BinOp"); + Util::ERROR("EvalBasePWMap: trying to evaluate arithmetic BinOp ", v, "\n"); return LIB::BasePWMap(); } LIB::BasePWMap EvalBasePWMap::operator()(AST::Call v) const { - Util::ERROR("EvalBasePWMap: trying to evaluate a Call"); + Util::ERROR("EvalBasePWMap: trying to evaluate Call ", v, "\n"); return LIB::BasePWMap(); } LIB::BasePWMap EvalBasePWMap::operator()(AST::Interval v) const { - Util::ERROR("EvalBasePWMap: trying to evaluate an Interval"); + Util::ERROR("EvalBasePWMap: trying to evaluate Interval ", v, "\n"); return LIB::BasePWMap(); } LIB::BasePWMap EvalBasePWMap::operator()(AST::InterUnaryOp v) const { - Util::ERROR("EvalBasePWMap: trying to evaluate an InterUnaryOp"); + Util::ERROR("EvalBasePWMap: trying to evaluate InterUnaryOp ", v, "\n"); return LIB::BasePWMap(); } LIB::BasePWMap EvalBasePWMap::operator()(AST::InterBinOp v) const { - Util::ERROR("EvalBasePWMap: trying to evaluate an InterBinOp"); + Util::ERROR("EvalBasePWMap: trying to evaluate InterBinOp ", v, "\n"); return LIB::BasePWMap(); } LIB::BasePWMap EvalBasePWMap::operator()(AST::MultiDimInter v) const { - Util::ERROR("EvalBasePWMap: trying to evaluate an MultiDimInter"); + Util::ERROR("EvalBasePWMap: trying to evaluate MultiDimInter ", v, "\n"); return LIB::BasePWMap(); } LIB::BasePWMap EvalBasePWMap::operator()(AST::MDInterUnaryOp v) const { - Util::ERROR("EvalBasePWMap: trying to evaluate an MDInterUnaryOp"); + Util::ERROR("EvalBasePWMap: trying to evaluate MDInterUnaryOp ", v, "\n"); return LIB::BasePWMap(); } LIB::BasePWMap EvalBasePWMap::operator()(AST::MDInterBinOp v) const { - Util::ERROR("EvalBasePWMap: trying to evaluate an MDInterBinOp"); + Util::ERROR("EvalBasePWMap: trying to evaluate MDInterBinOp ", v, "\n"); return LIB::BasePWMap(); } LIB::BasePWMap EvalBasePWMap::operator()(AST::Set v) const { - Util::ERROR("EvalBasePWMap: trying to evaluate a Set"); + Util::ERROR("EvalBasePWMap: trying to evaluate Set ", v, "\n"); return LIB::BasePWMap(); } LIB::BasePWMap EvalBasePWMap::operator()(AST::SetUnaryOp v) const { - Util::ERROR("EvalBasePWMap: trying to evaluate a SetUnaryOp"); + Util::ERROR("EvalBasePWMap: trying to evaluate SetUnaryOp ", v, "\n"); return LIB::BasePWMap(); } LIB::BasePWMap EvalBasePWMap::operator()(AST::SetBinOp v) const { - Util::ERROR("EvalBasePWMap: trying to evaluate a SetBinOp"); + Util::ERROR("EvalBasePWMap: trying to evaluate SetBinOp ", v, "\n"); return LIB::BasePWMap(); } LIB::BasePWMap EvalBasePWMap::operator()(AST::LinearExp v) const { - Util::ERROR("EvalBasePWMap: trying to evaluate a LinearExp"); + Util::ERROR("EvalBasePWMap: trying to evaluate LinearExp ", v, "\n"); return LIB::BasePWMap(); } LIB::BasePWMap EvalBasePWMap::operator()(AST::LExpBinOp v) const { - Util::ERROR("EvalBasePWMap: trying to evaluate a LExpBinOp"); + Util::ERROR("EvalBasePWMap: trying to evaluate LExpBinOp ", v, "\n"); return LIB::BasePWMap(); } LIB::BasePWMap EvalBasePWMap::operator()(AST::MDLExp v) const { - Util::ERROR("EvalBasePWMap: trying to evaluate a MDLExp"); + Util::ERROR("EvalBasePWMap: trying to evaluate MDLExp ", v, "\n"); return LIB::BasePWMap(); } LIB::BasePWMap EvalBasePWMap::operator()(AST::MDLExpBinOp v) const { - Util::ERROR("EvalBasePWMap: trying to evaluate a MDLExpBinOp"); + Util::ERROR("EvalBasePWMap: trying to evaluate MDLExpBinOp ", v, "\n"); return LIB::BasePWMap(); } LIB::BasePWMap EvalBasePWMap::operator()(AST::LinearMap v) const { - Util::ERROR("EvalBasePWMap: trying to evaluate a LinearMap"); + Util::ERROR("EvalBasePWMap: trying to evaluate LinearMap ", v, "\n"); return LIB::BasePWMap(); } @@ -186,13 +186,13 @@ LIB::BasePWMap EvalBasePWMap::operator()(AST::PWLMap v) const LIB::BasePWMap EvalBasePWMap::operator()(AST::SBG v) const { - Util::ERROR("EvalBasePWMap: trying to evaluate a SBG"); + Util::ERROR("EvalBasePWMap: trying to evaluate SBG ", v, "\n"); return LIB::BasePWMap(); } LIB::BasePWMap EvalBasePWMap::operator()(AST::DSBG v) const { - Util::ERROR("EvalBasePWMap: trying to evaluate a DSBG"); + Util::ERROR("EvalBasePWMap: trying to evaluate DSBG ", v, "\n"); return LIB::BasePWMap(); } diff --git a/eval/visitors/eval_base_sbg.cpp b/eval/visitors/eval_base_sbg.cpp index bae8d9c..2910a52 100755 --- a/eval/visitors/eval_base_sbg.cpp +++ b/eval/visitors/eval_base_sbg.cpp @@ -28,25 +28,25 @@ EvalBaseSBG::EvalBaseSBG(VarEnv env) : env_(env) {} LIB::BaseSBG EvalBaseSBG::operator()(AST::Natural v) const { - Util::ERROR("EvalBaseSBG: trying to evaluate a Natural"); + Util::ERROR("EvalBaseSBG: trying to evaluate Natural ", v, "\n"); return LIB::BaseSBG(); } LIB::BaseSBG EvalBaseSBG::operator()(AST::MDNatural v) const { - Util::ERROR("EvalBaseSBG: trying to evaluate a MDNatural"); + Util::ERROR("EvalBaseSBG: trying to evaluate MDNatural ", v, "\n"); return LIB::BaseSBG(); } LIB::BaseSBG EvalBaseSBG::operator()(AST::Rational v) const { - Util::ERROR("EvalBaseSBG: trying to evaluate a Rational"); + Util::ERROR("EvalBaseSBG: trying to evaluate Rational ", v, "\n"); return LIB::BaseSBG(); } LIB::BaseSBG EvalBaseSBG::operator()(AST::Boolean v) const { - Util::ERROR("EvalBaseSBG: trying to evaluate a Boolean"); + Util::ERROR("EvalBaseSBG: trying to evaluate Boolean ", v, "\n"); return LIB::BaseSBG(); } @@ -62,120 +62,120 @@ LIB::BaseSBG EvalBaseSBG::operator()(Util::VariableName v) const } else { - Util::ERROR("EvalBaseSBG: variable %s is not a PWMap", v.c_str()); + Util::ERROR("EvalBaseSBG: variable ", v, " is not a PWMap\n"); return LIB::BaseSBG(); } } - Util::ERROR("EvalBaseSBG: variable %s not defined", v.c_str()); + Util::ERROR("EvalBaseSBG: variable ", v, " undefined\n"); return LIB::BaseSBG(); } LIB::BaseSBG EvalBaseSBG::operator()(AST::UnaryOp v) const { - Util::ERROR("EvalBaseSBG: trying to evaluate an arithmetic BinOp"); + Util::ERROR("EvalBaseSBG: trying to evaluate arithmetic UnaryOp ", v, "\n"); return LIB::BaseSBG(); } LIB::BaseSBG EvalBaseSBG::operator()(AST::BinOp v) const { - Util::ERROR("EvalBaseSBG: trying to evaluate an arithmetic BinOp"); + Util::ERROR("EvalBaseSBG: trying to evaluate arithmetic BinOp ", v, "\n"); return LIB::BaseSBG(); } LIB::BaseSBG EvalBaseSBG::operator()(AST::Call v) const { - Util::ERROR("EvalBaseSBG: trying to evaluate a Call"); + Util::ERROR("EvalBaseSBG: trying to evaluate Call ", v, "\n"); return LIB::BaseSBG(); } LIB::BaseSBG EvalBaseSBG::operator()(AST::Interval v) const { - Util::ERROR("EvalBaseSBG: trying to evaluate an Interval"); + Util::ERROR("EvalBaseSBG: trying to evaluate Interval ", v, "\n"); return LIB::BaseSBG(); } LIB::BaseSBG EvalBaseSBG::operator()(AST::InterUnaryOp v) const { - Util::ERROR("EvalBaseSBG: trying to evaluate an InterUnaryOp"); + Util::ERROR("EvalBaseSBG: trying to evaluate InterUnaryOp ", v, "\n"); return LIB::BaseSBG(); } LIB::BaseSBG EvalBaseSBG::operator()(AST::InterBinOp v) const { - Util::ERROR("EvalBaseSBG: trying to evaluate an InterBinOp"); + Util::ERROR("EvalBaseSBG: trying to evaluate InterBinOp ", v, "\n"); return LIB::BaseSBG(); } LIB::BaseSBG EvalBaseSBG::operator()(AST::MultiDimInter v) const { - Util::ERROR("EvalBaseSBG: trying to evaluate an MultiDimInter"); + Util::ERROR("EvalBaseSBG: trying to evaluate MultiDimInter ", v, "\n"); return LIB::BaseSBG(); } LIB::BaseSBG EvalBaseSBG::operator()(AST::MDInterUnaryOp v) const { - Util::ERROR("EvalBaseSBG: trying to evaluate an MDInterUnaryOp"); + Util::ERROR("EvalBaseSBG: trying to evaluate MDInterUnaryOp ", v, "\n"); return LIB::BaseSBG(); } LIB::BaseSBG EvalBaseSBG::operator()(AST::MDInterBinOp v) const { - Util::ERROR("EvalBaseSBG: trying to evaluate an MDInterBinOp"); + Util::ERROR("EvalBaseSBG: trying to evaluate MDInterBinOp ", v, "\n"); return LIB::BaseSBG(); } LIB::BaseSBG EvalBaseSBG::operator()(AST::Set v) const { - Util::ERROR("EvalBaseSBG: trying to evaluate a Set"); + Util::ERROR("EvalBaseSBG: trying to evaluate Set ", v, "\n"); return LIB::BaseSBG(); } LIB::BaseSBG EvalBaseSBG::operator()(AST::SetUnaryOp v) const { - Util::ERROR("EvalBaseSBG: trying to evaluate a SetUnaryOp"); + Util::ERROR("EvalBaseSBG: trying to evaluate SetUnaryOp ", v, "\n"); return LIB::BaseSBG(); } LIB::BaseSBG EvalBaseSBG::operator()(AST::SetBinOp v) const { - Util::ERROR("EvalBaseSBG: trying to evaluate a SetBinOp"); + Util::ERROR("EvalBaseSBG: trying to evaluate SetBinOp ", v, "\n"); return LIB::BaseSBG(); } LIB::BaseSBG EvalBaseSBG::operator()(AST::LinearExp v) const { - Util::ERROR("EvalBaseSBG: trying to evaluate a LinearExp"); + Util::ERROR("EvalBaseSBG: trying to evaluate LinearExp ", v, "\n"); return LIB::BaseSBG(); } LIB::BaseSBG EvalBaseSBG::operator()(AST::LExpBinOp v) const { - Util::ERROR("EvalBaseSBG: trying to evaluate a LExpBinOp"); + Util::ERROR("EvalBaseSBG: trying to evaluate LExpBinOp ", v, "\n"); return LIB::BaseSBG(); } LIB::BaseSBG EvalBaseSBG::operator()(AST::MDLExp v) const { - Util::ERROR("EvalBaseSBG: trying to evaluate a MDLExp"); + Util::ERROR("EvalBaseSBG: trying to evaluate MDLExp ", v, "\n"); return LIB::BaseSBG(); } LIB::BaseSBG EvalBaseSBG::operator()(AST::MDLExpBinOp v) const { - Util::ERROR("EvalBaseSBG: trying to evaluate a MDLExpBinOp"); + Util::ERROR("EvalBaseSBG: trying to evaluate MDLExpBinOp ", v, "\n"); return LIB::BaseSBG(); } LIB::BaseSBG EvalBaseSBG::operator()(AST::LinearMap v) const { - Util::ERROR("EvalBaseSBG: trying to evaluate a LinearMap"); + Util::ERROR("EvalBaseSBG: trying to evaluate LinearMap ", v, "\n"); return LIB::BaseSBG(); } LIB::BaseSBG EvalBaseSBG::operator()(AST::PWLMap v) const { - Util::ERROR("EvalBaseSBG: trying to evaluate a PWLMap"); + Util::ERROR("EvalBaseSBG: trying to evaluate PWLMap ", v, "\n"); return LIB::BaseSBG(); } @@ -195,7 +195,7 @@ LIB::BaseSBG EvalBaseSBG::operator()(AST::SBG v) const LIB::BaseSBG EvalBaseSBG::operator()(AST::DSBG v) const { - Util::ERROR("EvalBaseSBG: trying to evaluate a DSBG"); + Util::ERROR("EvalBaseSBG: trying to evaluate DSBG ", v, "\n"); return LIB::BaseSBG(); } diff --git a/eval/visitors/eval_canon_dsbg.cpp b/eval/visitors/eval_canon_dsbg.cpp index fb21b71..d0defed 100755 --- a/eval/visitors/eval_canon_dsbg.cpp +++ b/eval/visitors/eval_canon_dsbg.cpp @@ -28,25 +28,25 @@ EvalCanonDSBG::EvalCanonDSBG(VarEnv env) : env_(env) {} LIB::CanonDSBG EvalCanonDSBG::operator()(AST::Natural v) const { - Util::ERROR("EvalCanonDSBG: trying to evaluate a Natural"); + Util::ERROR("EvalCanonDSBG: trying to evaluate Natural ", v, "\n"); return LIB::CanonDSBG(); } LIB::CanonDSBG EvalCanonDSBG::operator()(AST::MDNatural v) const { - Util::ERROR("EvalCanonDSBG: trying to evaluate a MDNatural"); + Util::ERROR("EvalCanonDSBG: trying to evaluate MDNatural ", v, "\n"); return LIB::CanonDSBG(); } LIB::CanonDSBG EvalCanonDSBG::operator()(AST::Rational v) const { - Util::ERROR("EvalCanonDSBG: trying to evaluate a Rational"); + Util::ERROR("EvalCanonDSBG: trying to evaluate Rational ", v, "\n"); return LIB::CanonDSBG(); } LIB::CanonDSBG EvalCanonDSBG::operator()(AST::Boolean v) const { - Util::ERROR("EvalCanonDSBG: trying to evaluate a Boolean"); + Util::ERROR("EvalCanonDSBG: trying to evaluate Boolean ", v, "\n"); return LIB::CanonDSBG(); } @@ -62,126 +62,126 @@ LIB::CanonDSBG EvalCanonDSBG::operator()(Util::VariableName v) const } else { - Util::ERROR("EvalCanonDSBG: variable %s is not a PWMap", v.c_str()); + Util::ERROR("EvalCanonDSBG: variable " , v, " is not a PWMap\n"); return LIB::CanonDSBG(); } } - Util::ERROR("EvalCanonDSBG: variable %s not defined", v.c_str()); + Util::ERROR("EvalCanonDSBG: variable ", v, " undefined\n"); return LIB::CanonDSBG(); } LIB::CanonDSBG EvalCanonDSBG::operator()(AST::UnaryOp v) const { - Util::ERROR("EvalCanonDSBG: trying to evaluate an arithmetic BinOp"); + Util::ERROR("EvalCanonDSBG: trying to evaluate arithmetic UnaryOp ", v, "\n"); return LIB::CanonDSBG(); } LIB::CanonDSBG EvalCanonDSBG::operator()(AST::BinOp v) const { - Util::ERROR("EvalCanonDSBG: trying to evaluate an arithmetic BinOp"); + Util::ERROR("EvalCanonDSBG: trying to evaluate arithmetic BinOp ", v, "\n"); return LIB::CanonDSBG(); } LIB::CanonDSBG EvalCanonDSBG::operator()(AST::Call v) const { - Util::ERROR("EvalCanonDSBG: trying to evaluate a Call"); + Util::ERROR("EvalCanonDSBG: trying to evaluate Call ", v, "\n"); return LIB::CanonDSBG(); } LIB::CanonDSBG EvalCanonDSBG::operator()(AST::Interval v) const { - Util::ERROR("EvalCanonDSBG: trying to evaluate an Interval"); + Util::ERROR("EvalCanonDSBG: trying to evaluate Interval ", v, "\n"); return LIB::CanonDSBG(); } LIB::CanonDSBG EvalCanonDSBG::operator()(AST::InterUnaryOp v) const { - Util::ERROR("EvalCanonDSBG: trying to evaluate an InterUnaryOp"); + Util::ERROR("EvalCanonDSBG: trying to evaluate InterUnaryOp ", v, "\n"); return LIB::CanonDSBG(); } LIB::CanonDSBG EvalCanonDSBG::operator()(AST::InterBinOp v) const { - Util::ERROR("EvalCanonDSBG: trying to evaluate an InterBinOp"); + Util::ERROR("EvalCanonDSBG: trying to evaluate InterBinOp ", v, "\n"); return LIB::CanonDSBG(); } LIB::CanonDSBG EvalCanonDSBG::operator()(AST::MultiDimInter v) const { - Util::ERROR("EvalCanonDSBG: trying to evaluate an MultiDimInter"); + Util::ERROR("EvalCanonDSBG: trying to evaluate MultiDimInter ", v, "\n"); return LIB::CanonDSBG(); } LIB::CanonDSBG EvalCanonDSBG::operator()(AST::MDInterUnaryOp v) const { - Util::ERROR("EvalCanonDSBG: trying to evaluate an MDInterUnaryOp"); + Util::ERROR("EvalCanonDSBG: trying to evaluate MDInterUnaryOp ", v, "\n"); return LIB::CanonDSBG(); } LIB::CanonDSBG EvalCanonDSBG::operator()(AST::MDInterBinOp v) const { - Util::ERROR("EvalCanonDSBG: trying to evaluate an MDInterBinOp"); + Util::ERROR("EvalCanonDSBG: trying to evaluate MDInterBinOp ", v, "\n"); return LIB::CanonDSBG(); } LIB::CanonDSBG EvalCanonDSBG::operator()(AST::Set v) const { - Util::ERROR("EvalCanonDSBG: trying to evaluate a Set"); + Util::ERROR("EvalCanonDSBG: trying to evaluate Set ", v, "\n"); return LIB::CanonDSBG(); } LIB::CanonDSBG EvalCanonDSBG::operator()(AST::SetUnaryOp v) const { - Util::ERROR("EvalCanonDSBG: trying to evaluate a SetUnaryOp"); + Util::ERROR("EvalCanonDSBG: trying to evaluate SetUnaryOp ", v, "\n"); return LIB::CanonDSBG(); } LIB::CanonDSBG EvalCanonDSBG::operator()(AST::SetBinOp v) const { - Util::ERROR("EvalCanonDSBG: trying to evaluate a SetBinOp"); + Util::ERROR("EvalCanonDSBG: trying to evaluate SetBinOp ", v, "\n"); return LIB::CanonDSBG(); } LIB::CanonDSBG EvalCanonDSBG::operator()(AST::LinearExp v) const { - Util::ERROR("EvalCanonDSBG: trying to evaluate a LinearExp"); + Util::ERROR("EvalCanonDSBG: trying to evaluate LinearExp ", v, "\n"); return LIB::CanonDSBG(); } LIB::CanonDSBG EvalCanonDSBG::operator()(AST::LExpBinOp v) const { - Util::ERROR("EvalCanonDSBG: trying to evaluate a LExpBinOp"); + Util::ERROR("EvalCanonDSBG: trying to evaluate LExpBinOp ", v, "\n"); return LIB::CanonDSBG(); } LIB::CanonDSBG EvalCanonDSBG::operator()(AST::MDLExp v) const { - Util::ERROR("EvalCanonDSBG: trying to evaluate a MDLExp"); + Util::ERROR("EvalCanonDSBG: trying to evaluate MDLExp ", v, "\n"); return LIB::CanonDSBG(); } LIB::CanonDSBG EvalCanonDSBG::operator()(AST::MDLExpBinOp v) const { - Util::ERROR("EvalCanonDSBG: trying to evaluate a MDLExpBinOp"); + Util::ERROR("EvalCanonDSBG: trying to evaluate MDLExpBinOp ", v, "\n"); return LIB::CanonDSBG(); } LIB::CanonDSBG EvalCanonDSBG::operator()(AST::LinearMap v) const { - Util::ERROR("EvalCanonDSBG: trying to evaluate a LinearMap"); + Util::ERROR("EvalCanonDSBG: trying to evaluate LinearMap ", v, "\n"); return LIB::CanonDSBG(); } LIB::CanonDSBG EvalCanonDSBG::operator()(AST::PWLMap v) const { - Util::ERROR("EvalCanonDSBG: trying to evaluate a PWLMap"); + Util::ERROR("EvalCanonDSBG: trying to evaluate PWLMap ", v, "\n"); return LIB::CanonDSBG(); } LIB::CanonDSBG EvalCanonDSBG::operator()(AST::SBG v) const { - Util::ERROR("EvalCanonDSBG: trying to evaluate a SBG"); + Util::ERROR("EvalCanonDSBG: trying to evaluate SBG ", v, "\n"); return LIB::CanonDSBG(); } diff --git a/eval/visitors/eval_canon_map.cpp b/eval/visitors/eval_canon_map.cpp index bc3a198..eb2e192 100755 --- a/eval/visitors/eval_canon_map.cpp +++ b/eval/visitors/eval_canon_map.cpp @@ -28,25 +28,25 @@ EvalCanonMap::EvalCanonMap(VarEnv env) : env_(env) {} LIB::CanonMap EvalCanonMap::operator()(AST::Natural v) const { - Util::ERROR("EvalCanonMap: trying to evaluate a Natural"); + Util::ERROR("EvalCanonMap: trying to evaluate Natural ", v, "\n"); return LIB::CanonMap(); } LIB::CanonMap EvalCanonMap::operator()(AST::MDNatural v) const { - Util::ERROR("EvalCanonMap: trying to evaluate a MDNatural"); + Util::ERROR("EvalCanonMap: trying to evaluate MDNatural ", v, "\n"); return LIB::CanonMap(); } LIB::CanonMap EvalCanonMap::operator()(AST::Rational v) const { - Util::ERROR("EvalCanonMap: trying to evaluate a Rational"); + Util::ERROR("EvalCanonMap: trying to evaluate Rational ", v, "\n"); return LIB::CanonMap(); } LIB::CanonMap EvalCanonMap::operator()(AST::Boolean v) const { - Util::ERROR("EvalCanonMap: trying to evaluate a Boolean"); + Util::ERROR("EvalCanonMap: trying to evaluate Boolean ", v, "\n"); return LIB::CanonMap(); } @@ -62,108 +62,108 @@ LIB::CanonMap EvalCanonMap::operator()(Util::VariableName v) const } else { - Util::ERROR("EvalCanonMap: variable %s is not a linear expression", v.c_str()); + Util::ERROR("EvalCanonMap: variable ", v, " is not a linear expression\n"); return LIB::CanonMap(); } } - Util::ERROR("EvalCanonMap: variable %s not defined", v.c_str()); + Util::ERROR("EvalCanonMap: variable ", v, " undefined\n"); return LIB::CanonMap(); } LIB::CanonMap EvalCanonMap::operator()(AST::UnaryOp v) const { - Util::ERROR("EvalCanonMap: trying to evaluate an arithmetic UnaryOp"); + Util::ERROR("EvalCanonMap: trying to evaluate arithmetic UnaryOp ", v, "\n"); return LIB::CanonMap(); } LIB::CanonMap EvalCanonMap::operator()(AST::BinOp v) const { - Util::ERROR("EvalCanonMap: trying to evaluate an arithmetic BinOp"); + Util::ERROR("EvalCanonMap: trying to evaluate arithmetic BinOp ", v, "\n"); return LIB::CanonMap(); } LIB::CanonMap EvalCanonMap::operator()(AST::Call v) const { - Util::ERROR("EvalCanonMap: trying to evaluate a Call"); + Util::ERROR("EvalCanonMap: trying to evaluate Call ", v, "\n"); return LIB::CanonMap(); } LIB::CanonMap EvalCanonMap::operator()(AST::Interval v) const { - Util::ERROR("EvalCanonMap: trying to evaluate an Interval"); + Util::ERROR("EvalCanonMap: trying to evaluate Interval ", v, "\n"); return LIB::CanonMap(); } LIB::CanonMap EvalCanonMap::operator()(AST::InterUnaryOp v) const { - Util::ERROR("EvalCanonMap: trying to evaluate an InterUnaryOp"); + Util::ERROR("EvalCanonMap: trying to evaluate InterUnaryOp ", v, "\n"); return LIB::CanonMap(); } LIB::CanonMap EvalCanonMap::operator()(AST::InterBinOp v) const { - Util::ERROR("EvalCanonMap: trying to evaluate an InterBinOp"); + Util::ERROR("EvalCanonMap: trying to evaluate InterBinOp ", v, "\n"); return LIB::CanonMap(); } LIB::CanonMap EvalCanonMap::operator()(AST::MultiDimInter v) const { - Util::ERROR("EvalCanonMap: trying to evaluate an MultiDimInter"); + Util::ERROR("EvalCanonMap: trying to evaluate MultiDimInter ", v, "\n"); return LIB::CanonMap(); } LIB::CanonMap EvalCanonMap::operator()(AST::MDInterUnaryOp v) const { - Util::ERROR("EvalCanonMap: trying to evaluate an MDInterUnaryOp"); + Util::ERROR("EvalCanonMap: trying to evaluate MDInterUnaryOp ", v, "\n"); return LIB::CanonMap(); } LIB::CanonMap EvalCanonMap::operator()(AST::MDInterBinOp v) const { - Util::ERROR("EvalCanonMap: trying to evaluate an MDInterBinOp"); + Util::ERROR("EvalCanonMap: trying to evaluate MDInterBinOp ", v, "\n"); return LIB::CanonMap(); } LIB::CanonMap EvalCanonMap::operator()(AST::Set v) const { - Util::ERROR("EvalCanonMap: trying to evaluate a Set"); + Util::ERROR("EvalCanonMap: trying to evaluate Set ", v, "\n"); return LIB::CanonMap(); } LIB::CanonMap EvalCanonMap::operator()(AST::SetUnaryOp v) const { - Util::ERROR("EvalCanonMap: trying to evaluate a SetUnaryOp"); + Util::ERROR("EvalCanonMap: trying to evaluate SetUnaryOp ", v, "\n"); return LIB::CanonMap(); } LIB::CanonMap EvalCanonMap::operator()(AST::SetBinOp v) const { - Util::ERROR("EvalCanonMap: trying to evaluate a SetBinOp"); + Util::ERROR("EvalCanonMap: trying to evaluate SetBinOp ", v, "\n"); return LIB::CanonMap(); } LIB::CanonMap EvalCanonMap::operator()(AST::LinearExp v) const { - Util::ERROR("EvalCanonMap: trying to evaluate a LinearExp"); + Util::ERROR("EvalCanonMap: trying to evaluate LinearExp ", v, "\n"); return LIB::CanonMap(); } LIB::CanonMap EvalCanonMap::operator()(AST::LExpBinOp v) const { - Util::ERROR("EvalCanonMap: trying to evaluate a LExpBinOp"); + Util::ERROR("EvalCanonMap: trying to evaluate LExpBinOp ", v, "\n"); return LIB::CanonMap(); } LIB::CanonMap EvalCanonMap::operator()(AST::MDLExp v) const { - Util::ERROR("EvalCanonMap: trying to evaluate a MDLExp"); + Util::ERROR("EvalCanonMap: trying to evaluate MDLExp ", v, "\n"); return LIB::CanonMap(); } LIB::CanonMap EvalCanonMap::operator()(AST::MDLExpBinOp v) const { - Util::ERROR("EvalCanonMap: trying to evaluate a MDLExpBinOp"); + Util::ERROR("EvalCanonMap: trying to evaluate MDLExpBinOp ", v, "\n"); return LIB::CanonMap(); } @@ -178,19 +178,19 @@ LIB::CanonMap EvalCanonMap::operator()(AST::LinearMap v) const LIB::CanonMap EvalCanonMap::operator()(AST::PWLMap v) const { - Util::ERROR("EvalCanonMap: trying to evaluate a PWLMap"); + Util::ERROR("EvalCanonMap: trying to evaluate PWLMap ", v, "\n"); return LIB::CanonMap(); } LIB::CanonMap EvalCanonMap::operator()(AST::SBG v) const { - Util::ERROR("EvalCanonMap: trying to evaluate a SBG"); + Util::ERROR("EvalCanonMap: trying to evaluate SBG ", v, "\n"); return LIB::CanonMap(); } LIB::CanonMap EvalCanonMap::operator()(AST::DSBG v) const { - Util::ERROR("EvalCanonMap: trying to evaluate a DSBG"); + Util::ERROR("EvalCanonMap: trying to evaluate DSBG ", v, "\n"); return LIB::CanonMap(); } diff --git a/eval/visitors/eval_canon_pwmap.cpp b/eval/visitors/eval_canon_pwmap.cpp index 9402af3..a4ef668 100755 --- a/eval/visitors/eval_canon_pwmap.cpp +++ b/eval/visitors/eval_canon_pwmap.cpp @@ -28,25 +28,25 @@ EvalCanonPWMap::EvalCanonPWMap(VarEnv env) : env_(env) {} LIB::CanonPWMap EvalCanonPWMap::operator()(AST::Natural v) const { - Util::ERROR("EvalCanonPWMap: trying to evaluate a Natural"); + Util::ERROR("EvalCanonPWMap: trying to evaluate Natural ", v, "\n"); return LIB::CanonPWMap(); } LIB::CanonPWMap EvalCanonPWMap::operator()(AST::MDNatural v) const { - Util::ERROR("EvalCanonPWMap: trying to evaluate a MDNatural"); + Util::ERROR("EvalCanonPWMap: trying to evaluate MDNatural ", v, "\n"); return LIB::CanonPWMap(); } LIB::CanonPWMap EvalCanonPWMap::operator()(AST::Rational v) const { - Util::ERROR("EvalCanonPWMap: trying to evaluate a Rational"); + Util::ERROR("EvalCanonPWMap: trying to evaluate Rational ", v, "\n"); return LIB::CanonPWMap(); } LIB::CanonPWMap EvalCanonPWMap::operator()(AST::Boolean v) const { - Util::ERROR("EvalCanonPWMap: trying to evaluate a Boolean"); + Util::ERROR("EvalCanonPWMap: trying to evaluate Boolean ", v, "\n"); return LIB::CanonPWMap(); } @@ -62,114 +62,114 @@ LIB::CanonPWMap EvalCanonPWMap::operator()(Util::VariableName v) const } else { - Util::ERROR("EvalCanonPWMap: variable %s is not a PWMap", v.c_str()); + Util::ERROR("EvalCanonPWMap: variable ", v, " is not a PWMap\n"); return LIB::CanonPWMap(); } } - Util::ERROR("EvalCanonPWMap: variable %s not defined", v.c_str()); + Util::ERROR("EvalCanonPWMap: variable ", v, " undefined\n"); return LIB::CanonPWMap(); } LIB::CanonPWMap EvalCanonPWMap::operator()(AST::UnaryOp v) const { - Util::ERROR("EvalCanonPWMap: trying to evaluate an arithmetic UnaryOp"); + Util::ERROR("EvalCanonPWMap: trying to evaluate arithmetic UnaryOp ", v, "\n"); return LIB::CanonPWMap(); } LIB::CanonPWMap EvalCanonPWMap::operator()(AST::BinOp v) const { - Util::ERROR("EvalCanonPWMap: trying to evaluate an arithmetic BinOp"); + Util::ERROR("EvalCanonPWMap: trying to evaluate arithmetic BinOp ", v, "\n"); return LIB::CanonPWMap(); } LIB::CanonPWMap EvalCanonPWMap::operator()(AST::Call v) const { - Util::ERROR("EvalCanonPWMap: trying to evaluate a Call"); + Util::ERROR("EvalCanonPWMap: trying to evaluate Call ", v, "\n"); return LIB::CanonPWMap(); } LIB::CanonPWMap EvalCanonPWMap::operator()(AST::Interval v) const { - Util::ERROR("EvalCanonPWMap: trying to evaluate an Interval"); + Util::ERROR("EvalCanonPWMap: trying to evaluate Interval ", v, "\n"); return LIB::CanonPWMap(); } LIB::CanonPWMap EvalCanonPWMap::operator()(AST::InterUnaryOp v) const { - Util::ERROR("EvalCanonPWMap: trying to evaluate an InterUnaryOp"); + Util::ERROR("EvalCanonPWMap: trying to evaluate InterUnaryOp ", v, "\n"); return LIB::CanonPWMap(); } LIB::CanonPWMap EvalCanonPWMap::operator()(AST::InterBinOp v) const { - Util::ERROR("EvalCanonPWMap: trying to evaluate an InterBinOp"); + Util::ERROR("EvalCanonPWMap: trying to evaluate InterBinOp ", v, "\n"); return LIB::CanonPWMap(); } LIB::CanonPWMap EvalCanonPWMap::operator()(AST::MultiDimInter v) const { - Util::ERROR("EvalCanonPWMap: trying to evaluate a MultiDimInter"); + Util::ERROR("EvalCanonPWMap: trying to evaluate MultiDimInter ", v, "\n"); return LIB::CanonPWMap(); } LIB::CanonPWMap EvalCanonPWMap::operator()(AST::MDInterUnaryOp v) const { - Util::ERROR("EvalCanonPWMap: trying to evaluate a MDInterUnaryOp"); + Util::ERROR("EvalCanonPWMap: trying to evaluate MDInterUnaryOp ", v, "\n"); return LIB::CanonPWMap(); } LIB::CanonPWMap EvalCanonPWMap::operator()(AST::MDInterBinOp v) const { - Util::ERROR("EvalCanonPWMap: trying to evaluate a MDInterBinOp"); + Util::ERROR("EvalCanonPWMap: trying to evaluate MDInterBinOp ", v, "\n"); return LIB::CanonPWMap(); } LIB::CanonPWMap EvalCanonPWMap::operator()(AST::Set v) const { - Util::ERROR("EvalCanonPWMap: trying to evaluate a Set"); + Util::ERROR("EvalCanonPWMap: trying to evaluate Set ", v, "\n"); return LIB::CanonPWMap(); } LIB::CanonPWMap EvalCanonPWMap::operator()(AST::SetUnaryOp v) const { - Util::ERROR("EvalCanonPWMap: trying to evaluate a SetUnaryOp"); + Util::ERROR("EvalCanonPWMap: trying to evaluate SetUnaryOp ", v, "\n"); return LIB::CanonPWMap(); } LIB::CanonPWMap EvalCanonPWMap::operator()(AST::SetBinOp v) const { - Util::ERROR("EvalCanonPWMap: trying to evaluate a SetBinOp"); + Util::ERROR("EvalCanonPWMap: trying to evaluate SetBinOp ", v, "\n"); return LIB::CanonPWMap(); } LIB::CanonPWMap EvalCanonPWMap::operator()(AST::LinearExp v) const { - Util::ERROR("EvalCanonPWMap: trying to evaluate a LinearExp"); + Util::ERROR("EvalCanonPWMap: trying to evaluate LinearExp ", v, "\n"); return LIB::CanonPWMap(); } LIB::CanonPWMap EvalCanonPWMap::operator()(AST::LExpBinOp v) const { - Util::ERROR("EvalCanonPWMap: trying to evaluate a LExpBinOp"); + Util::ERROR("EvalCanonPWMap: trying to evaluate LExpBinOp ", v, "\n"); return LIB::CanonPWMap(); } LIB::CanonPWMap EvalCanonPWMap::operator()(AST::MDLExp v) const { - Util::ERROR("EvalCanonPWMap: trying to evaluate a MDLExp"); + Util::ERROR("EvalCanonPWMap: trying to evaluate MDLExp ", v, "\n"); return LIB::CanonPWMap(); } LIB::CanonPWMap EvalCanonPWMap::operator()(AST::MDLExpBinOp v) const { - Util::ERROR("EvalCanonPWMap: trying to evaluate a MDLExpBinOp"); + Util::ERROR("EvalCanonPWMap: trying to evaluate MDLExpBinOp ", v, "\n"); return LIB::CanonPWMap(); } LIB::CanonPWMap EvalCanonPWMap::operator()(AST::LinearMap v) const { - Util::ERROR("EvalCanonPWMap: trying to evaluate a LinearMap"); + Util::ERROR("EvalCanonPWMap: trying to evaluate LinearMap ", v, "\n"); return LIB::CanonPWMap(); } @@ -186,13 +186,13 @@ LIB::CanonPWMap EvalCanonPWMap::operator()(AST::PWLMap v) const LIB::CanonPWMap EvalCanonPWMap::operator()(AST::SBG v) const { - Util::ERROR("EvalCanonPWMap: trying to evaluate a SBG"); + Util::ERROR("EvalCanonPWMap: trying to evaluate SBG ", v, "\n"); return LIB::CanonPWMap(); } LIB::CanonPWMap EvalCanonPWMap::operator()(AST::DSBG v) const { - Util::ERROR("EvalCanonPWMap: trying to evaluate a DSBG"); + Util::ERROR("EvalCanonPWMap: trying to evaluate DSBG ", v, "\n"); return LIB::CanonPWMap(); } diff --git a/eval/visitors/eval_canon_sbg.cpp b/eval/visitors/eval_canon_sbg.cpp index ade1c2d..298f839 100755 --- a/eval/visitors/eval_canon_sbg.cpp +++ b/eval/visitors/eval_canon_sbg.cpp @@ -28,25 +28,25 @@ EvalCanonSBG::EvalCanonSBG(VarEnv env) : env_(env) {} LIB::CanonSBG EvalCanonSBG::operator()(AST::Natural v) const { - Util::ERROR("EvalCanonSBG: trying to evaluate a Natural"); + Util::ERROR("EvalCanonSBG: trying to evaluate Natural ", v, "\n"); return LIB::CanonSBG(); } LIB::CanonSBG EvalCanonSBG::operator()(AST::MDNatural v) const { - Util::ERROR("EvalCanonSBG: trying to evaluate a MDNatural"); + Util::ERROR("EvalCanonSBG: trying to evaluate MDNatural ", v, "\n"); return LIB::CanonSBG(); } LIB::CanonSBG EvalCanonSBG::operator()(AST::Rational v) const { - Util::ERROR("EvalCanonSBG: trying to evaluate a Rational"); + Util::ERROR("EvalCanonSBG: trying to evaluate Rational ", v, "\n"); return LIB::CanonSBG(); } LIB::CanonSBG EvalCanonSBG::operator()(AST::Boolean v) const { - Util::ERROR("EvalCanonSBG: trying to evaluate a Boolean"); + Util::ERROR("EvalCanonSBG: trying to evaluate Boolean ", v, "\n"); return LIB::CanonSBG(); } @@ -62,120 +62,120 @@ LIB::CanonSBG EvalCanonSBG::operator()(Util::VariableName v) const } else { - Util::ERROR("EvalCanonSBG: variable %s is not a PWMap", v.c_str()); + Util::ERROR("EvalCanonSBG: variable ", v, " is not a PWMap\n"); return LIB::CanonSBG(); } } - Util::ERROR("EvalCanonSBG: variable %s not defined", v.c_str()); + Util::ERROR("EvalCanonSBG: variable ", v, " undefined\n"); return LIB::CanonSBG(); } LIB::CanonSBG EvalCanonSBG::operator()(AST::UnaryOp v) const { - Util::ERROR("EvalCanonSBG: trying to evaluate an arithmetic BinOp"); + Util::ERROR("EvalCanonSBG: trying to evaluate arithmetic UnaryOp ", v, "\n"); return LIB::CanonSBG(); } LIB::CanonSBG EvalCanonSBG::operator()(AST::BinOp v) const { - Util::ERROR("EvalCanonSBG: trying to evaluate an arithmetic BinOp"); + Util::ERROR("EvalCanonSBG: trying to evaluate arithmetic BinOp ", v, "\n"); return LIB::CanonSBG(); } LIB::CanonSBG EvalCanonSBG::operator()(AST::Call v) const { - Util::ERROR("EvalCanonSBG: trying to evaluate a Call"); + Util::ERROR("EvalCanonSBG: trying to evaluate Call ", v, "\n"); return LIB::CanonSBG(); } LIB::CanonSBG EvalCanonSBG::operator()(AST::Interval v) const { - Util::ERROR("EvalCanonSBG: trying to evaluate an Interval"); + Util::ERROR("EvalCanonSBG: trying to evaluate Interval ", v, "\n"); return LIB::CanonSBG(); } LIB::CanonSBG EvalCanonSBG::operator()(AST::InterUnaryOp v) const { - Util::ERROR("EvalCanonSBG: trying to evaluate an InterUnaryOp"); + Util::ERROR("EvalCanonSBG: trying to evaluate InterUnaryOp ", v, "\n"); return LIB::CanonSBG(); } LIB::CanonSBG EvalCanonSBG::operator()(AST::InterBinOp v) const { - Util::ERROR("EvalCanonSBG: trying to evaluate an InterBinOp"); + Util::ERROR("EvalCanonSBG: trying to evaluate InterBinOp ", v, "\n"); return LIB::CanonSBG(); } LIB::CanonSBG EvalCanonSBG::operator()(AST::MultiDimInter v) const { - Util::ERROR("EvalCanonSBG: trying to evaluate an MultiDimInter"); + Util::ERROR("EvalCanonSBG: trying to evaluate MultiDimInter ", v, "\n"); return LIB::CanonSBG(); } LIB::CanonSBG EvalCanonSBG::operator()(AST::MDInterUnaryOp v) const { - Util::ERROR("EvalCanonSBG: trying to evaluate an MDInterUnaryOp"); + Util::ERROR("EvalCanonSBG: trying to evaluate MDInterUnaryOp ", v, "\n"); return LIB::CanonSBG(); } LIB::CanonSBG EvalCanonSBG::operator()(AST::MDInterBinOp v) const { - Util::ERROR("EvalCanonSBG: trying to evaluate an MDInterBinOp"); + Util::ERROR("EvalCanonSBG: trying to evaluate MDInterBinOp ", v, "\n"); return LIB::CanonSBG(); } LIB::CanonSBG EvalCanonSBG::operator()(AST::Set v) const { - Util::ERROR("EvalCanonSBG: trying to evaluate a Set"); + Util::ERROR("EvalCanonSBG: trying to evaluate Set ", v, "\n"); return LIB::CanonSBG(); } LIB::CanonSBG EvalCanonSBG::operator()(AST::SetUnaryOp v) const { - Util::ERROR("EvalCanonSBG: trying to evaluate a SetUnaryOp"); + Util::ERROR("EvalCanonSBG: trying to evaluate SetUnaryOp ", v, "\n"); return LIB::CanonSBG(); } LIB::CanonSBG EvalCanonSBG::operator()(AST::SetBinOp v) const { - Util::ERROR("EvalCanonSBG: trying to evaluate a SetBinOp"); + Util::ERROR("EvalCanonSBG: trying to evaluate SetBinOp ", v, "\n"); return LIB::CanonSBG(); } LIB::CanonSBG EvalCanonSBG::operator()(AST::LinearExp v) const { - Util::ERROR("EvalCanonSBG: trying to evaluate a LinearExp"); + Util::ERROR("EvalCanonSBG: trying to evaluate LinearExp ", v, "\n"); return LIB::CanonSBG(); } LIB::CanonSBG EvalCanonSBG::operator()(AST::LExpBinOp v) const { - Util::ERROR("EvalCanonSBG: trying to evaluate a LExpBinOp"); + Util::ERROR("EvalCanonSBG: trying to evaluate LExpBinOp ", v, "\n"); return LIB::CanonSBG(); } LIB::CanonSBG EvalCanonSBG::operator()(AST::MDLExp v) const { - Util::ERROR("EvalCanonSBG: trying to evaluate a MDLExp"); + Util::ERROR("EvalCanonSBG: trying to evaluate MDLExp ", v, "\n"); return LIB::CanonSBG(); } LIB::CanonSBG EvalCanonSBG::operator()(AST::MDLExpBinOp v) const { - Util::ERROR("EvalCanonSBG: trying to evaluate a MDLExpBinOp"); + Util::ERROR("EvalCanonSBG: trying to evaluate MDLExpBinOp ", v, "\n"); return LIB::CanonSBG(); } LIB::CanonSBG EvalCanonSBG::operator()(AST::LinearMap v) const { - Util::ERROR("EvalCanonSBG: trying to evaluate a LinearMap"); + Util::ERROR("EvalCanonSBG: trying to evaluate LinearMap ", v, "\n"); return LIB::CanonSBG(); } LIB::CanonSBG EvalCanonSBG::operator()(AST::PWLMap v) const { - Util::ERROR("EvalCanonSBG: trying to evaluate a PWLMap"); + Util::ERROR("EvalCanonSBG: trying to evaluate PWLMap ", v, "\n"); return LIB::CanonSBG(); } @@ -195,7 +195,7 @@ LIB::CanonSBG EvalCanonSBG::operator()(AST::SBG v) const LIB::CanonSBG EvalCanonSBG::operator()(AST::DSBG v) const { - Util::ERROR("EvalCanonSBG: trying to evaluate a DSBG"); + Util::ERROR("EvalCanonSBG: trying to evaluate DSBG ", v, "\n"); return LIB::CanonSBG(); } diff --git a/eval/visitors/eval_container.cpp b/eval/visitors/eval_container.cpp index 3ab2898..d81054f 100755 --- a/eval/visitors/eval_container.cpp +++ b/eval/visitors/eval_container.cpp @@ -25,13 +25,13 @@ namespace Eval { ContainerBaseType EvalContainer::operator()(Util::MD_NAT v) const { - Util::ERROR("EvalContainer: trying to evaluate a MD_NAT"); + Util::ERROR("EvalContainer: trying to evaluate MD_NAT ", v, "\n"); return ContainerBaseType(); } ContainerBaseType EvalContainer::operator()(Util::RATIONAL v) const { - Util::ERROR("EvalContainer: trying to evaluate a RATIONAL"); + Util::ERROR("EvalContainer: trying to evaluate RATIONAL ", v, "\n"); return ContainerBaseType(); } @@ -42,25 +42,33 @@ ContainerBaseType EvalContainer::operator()(ContainerBaseType v) const ContainerBaseType EvalContainer::operator()(LinearBaseType v) const { - Util::ERROR("EvalContainer: trying to evaluate a LinearBaseType"); + std::visit([](auto &&arg) { + Util::ERROR("EvalContainer: trying to evaluate LinearBaseType ", arg, "\n"); + }, v); return ContainerBaseType(); } ContainerBaseType EvalContainer::operator()(MapBaseType v) const { - Util::ERROR("EvalContainer: trying to evaluate a MapBaseType"); + std::visit([](auto &&arg) { + Util::ERROR("EvalContainer: trying to evaluate MapBaseType ", arg, "\n"); + }, v); return ContainerBaseType(); } ContainerBaseType EvalContainer::operator()(SBGBaseType v) const { - Util::ERROR("EvalContainer: trying to evaluate a SBGBaseType"); + std::visit([](auto &&arg) { + Util::ERROR("EvalContainer: trying to evaluate SBGBaseType ", arg, "\n"); + }, v); return ContainerBaseType(); } ContainerBaseType EvalContainer::operator()(InfoBaseType v) const { - Util::ERROR("EvalContainer: trying to evaluate an InfoBaseType"); + std::visit([](auto &&arg) { + Util::ERROR("EvalContainer: trying to evaluate InfoBaseType ", arg, "\n"); + }, v); return ContainerBaseType(); } diff --git a/eval/visitors/eval_expr.cpp b/eval/visitors/eval_expr.cpp index 0256910..20503c9 100755 --- a/eval/visitors/eval_expr.cpp +++ b/eval/visitors/eval_expr.cpp @@ -27,23 +27,13 @@ namespace Eval { // Function visitors ----------------------------------------------------------- // ----------------------------------------------------------------------------- -auto member_visitor_ = Util::Overload { - [](Util::NAT a, LIB::Interval b) { return b.isMember(a); }, - [](Util::NAT a, LIB::MultiDimInter b) { return b.isMember(Util::MD_NAT(a)); }, - [](Util::MD_NAT a, LIB::MultiDimInter b) { return b.isMember(a); }, - [](auto a, auto b) { - Util::ERROR("Wrong arguments for isMember"); - return false; - } -}; - auto min_visitor_ = Util::Overload { [](LIB::Interval a) { return Util::MD_NAT(a.begin()); }, [](LIB::MultiDimInter a) { return a.minElem(); }, [](LIB::UnordSet a) { return a.minElem(); }, [](LIB::OrdSet a) { return a.minElem(); }, [](auto a) { - Util::ERROR("Wrong arguments for minElem"); + Util::ERROR("min_visitor_: wrong argument ", a, " for minElem\n"); return Util::MD_NAT(); } }; @@ -54,7 +44,7 @@ auto max_visitor_ = Util::Overload { [](LIB::UnordSet a) { return a.maxElem(); }, [](LIB::OrdSet a) { return a.maxElem(); }, [](auto a) { - Util::ERROR("Wrong arguments for maxElem"); + Util::ERROR("max_visitor_: wrong argument ", a, " for maxElem\n"); return Util::MD_NAT(); } }; @@ -63,7 +53,8 @@ auto compose_linear_visitor_ = Util::Overload { [](LIB::LExp a, LIB::LExp b) { return LinearBaseType(a.composition(b)); }, [](LIB::Exp a, LIB::Exp b) { return LinearBaseType(a.composition(b)); }, [](auto a, auto b) { - Util::ERROR("Wrong arguments for composition"); + Util::ERROR("compose_linear_visitor_: wrong arguments ", a, ", ", b + , " for compose\n"); return LinearBaseType(); } }; @@ -80,12 +71,13 @@ auto compose_map_visitor_ = Util::Overload { return MapBaseType(a.composition(b)); }, [](auto a, auto b) { - Util::ERROR("Wrong arguments for composition"); + Util::ERROR("compose_map_visitor_: wrong arguments ", a, ", ", b + , " for compose\n"); return MapBaseType(); } }; -auto image_visitor2_ = Util::Overload { +auto image_visitor_ = Util::Overload { [](LIB::UnordSet a, LIB::BaseMap b) { return ContainerBaseType(b.image(a)); }, [](LIB::OrdSet a, LIB::CanonMap b) { return ContainerBaseType(b.image(a)); }, [](LIB::UnordSet a, LIB::BasePWMap b) { @@ -95,12 +87,12 @@ auto image_visitor2_ = Util::Overload { return ContainerBaseType(b.image(a)); }, [](auto a, auto b) { - Util::ERROR("Wrong arguments for image 2"); + Util::ERROR("image_visitor_: wrong arguments ", a, ", ", b, " for image\n"); return ContainerBaseType(); } }; -auto pre_image_visitor2_ = Util::Overload { +auto pre_image_visitor_ = Util::Overload { [](LIB::UnordSet a, LIB::BaseMap b) { return ContainerBaseType(b.preImage(a)); }, @@ -114,7 +106,8 @@ auto pre_image_visitor2_ = Util::Overload { return ContainerBaseType(b.preImage(a)); }, [](auto a, auto b) { - Util::ERROR("Wrong arguments for pre image 2"); + Util::ERROR("pre_image_visitor_: wrong arguments ", a, ", ", b + , " for pre-image\n"); return ContainerBaseType(); } }; @@ -125,7 +118,8 @@ auto combine_visitor_ = Util::Overload { return MapBaseType(a.combine(b)); }, [](auto a, auto b) { - Util::ERROR("Wrong arguments for combine"); + Util::ERROR("combine_visitor_: wrong arguments ", a, ", ", b + , " for combine\n"); return MapBaseType(); } }; @@ -138,16 +132,17 @@ auto first_inv_visitor_ = Util::Overload { return MapBaseType(a.firstInv()); }, [](auto a) { - Util::ERROR("Wrong arguments for firstInv"); + Util::ERROR("first_inv_visitor_: wrong argument ", a, " for firstInv\n"); return MapBaseType(); } }; -auto min_map_visitor2_ = Util::Overload { +auto min_map_visitor_ = Util::Overload { [](LIB::BasePWMap a, LIB::BasePWMap b) { return MapBaseType(a.minMap(b)); }, [](LIB::CanonPWMap a, LIB::CanonPWMap b) { return MapBaseType(a.minMap(b)); }, [](auto a, auto b) { - Util::ERROR("Wrong arguments for minMap2"); + Util::ERROR("min_map_visitor_: wrong arguments ", a, ", ", b + , " for minMap\n"); return MapBaseType(); } }; @@ -156,18 +151,19 @@ auto reduce_visitor_ = Util::Overload { [](LIB::BasePWMap a) { return MapBaseType(a.reduce()); }, [](LIB::CanonPWMap a) { return MapBaseType(a.reduce()); }, [](auto a) { - Util::ERROR("Wrong arguments for reduce"); + Util::ERROR("reduce_visitor_: wrong argument ", a, " for reduce\n"); return MapBaseType(); } }; -auto min_adj_visitor2_ = Util::Overload { +auto min_adj_visitor_ = Util::Overload { [](LIB::BasePWMap a, LIB::BasePWMap b) { return MapBaseType(a.minAdjMap(b)); }, [](LIB::CanonPWMap a, LIB::CanonPWMap b) { return MapBaseType(a.minAdjMap(b)); }, [](auto a, auto b) { - Util::ERROR("Wrong arguments for minAdjMap"); + Util::ERROR("min_adj_visitor_: wrong arguments ", a, ", ", b + , " for minAdj\n"); return MapBaseType(); } }; @@ -176,7 +172,7 @@ auto inf_visitor_ = Util::Overload { [](LIB::BasePWMap a) { return MapBaseType(a.mapInf()); }, [](LIB::CanonPWMap a) { return MapBaseType(a.mapInf()); }, [](auto a, auto b) { - Util::ERROR("Wrong arguments for mapInf"); + Util::ERROR("inf_visitor_: wrong argument ", a, " for mapInf\n"); return MapBaseType(); } }; @@ -185,7 +181,7 @@ auto connected_visitor_ = Util::Overload { [](LIB::BaseSBG a) { return MapBaseType(connectedComponents(a)); }, [](LIB::CanonSBG a) { return MapBaseType(connectedComponents(a)); }, [](auto a) { - Util::ERROR("Wrong arguments for connectedComponents"); + Util::ERROR("connected_visitor_: wrong argument ", a, " for CC\n"); return MapBaseType(); } }; @@ -200,7 +196,8 @@ auto matching_visitor_ = Util::Overload { return InfoBaseType(match.calculate()); }, [](auto a, auto b, auto c) { - Util::ERROR("Wrong arguments for matching"); + Util::ERROR("matching_visitor_: wrong arguments ", a, ", ", b + , " for matching\n"); return InfoBaseType(); } }; @@ -215,7 +212,7 @@ auto scc_visitor_ = Util::Overload { return MapBaseType(scc.calculate()); }, [](auto a, auto b) { - Util::ERROR("Wrong arguments for scc"); + Util::ERROR("scc_visitor_: wrong argument ", a, " for scc\n"); return MapBaseType(); } }; @@ -230,7 +227,7 @@ auto ts_visitor_ = Util::Overload { return MapBaseType(ts.calculate()); }, [](auto a, auto b) { - Util::ERROR("Wrong arguments for ts"); + Util::ERROR("ts_visitor_: wrong argument ", a, " for sort\n"); return MapBaseType(); } }; @@ -249,7 +246,8 @@ auto match_scc_visitor_ = Util::Overload { return MapBaseType(scc.calculate()); }, [](auto a, auto b, auto c) { - Util::ERROR("Wrong arguments for matching+scc"); + Util::ERROR("match_scc_visitor_: wrong arguments ", a, ", ", b + , " for matchSCC\n"); return MapBaseType(); } }; @@ -276,7 +274,8 @@ auto match_scc_ts_visitor_ = Util::Overload { return MapBaseType(ts_res); }, [](auto a, auto b, auto c) { - Util::ERROR("Wrong arguments for matching+scc+ts"); + Util::ERROR("match_scc_ts_visitor_: wrong arguments ", a, ", ", b + , " for matchSCCTS\n"); return MapBaseType(); } }; @@ -291,7 +290,7 @@ auto cut_visitor_ = Util::Overload { return ContainerBaseType(cut_set.calculate()); }, [](auto a, auto b) { - Util::ERROR("Wrong arguments for cut vertices set"); + Util::ERROR("cut_visitor_: wrong argument ", a, " for cut\n"); return ContainerBaseType(); } }; @@ -310,10 +309,19 @@ EvalExpression::EvalExpression(unsigned int nmbr_dims, bool opt_conds ExprBaseType EvalExpression::operator()(AST::Natural v) const { + Util::ERROR_UNLESS(nmbr_dims_ == 1 + ,"EvalExpr: nmbr_dims_: ", nmbr_dims_, " not 1\n"); + return Util::MD_NAT(v); } -ExprBaseType EvalExpression::operator()(AST::MDNatural v) const { return v; } +ExprBaseType EvalExpression::operator()(AST::MDNatural v) const +{ + Util::ERROR_UNLESS(nmbr_dims_ == v.arity() || 0 == v.arity() + ,"EvalExpr: nmbr_dims_: ", nmbr_dims_, " != arity(", v, ")\n"); + + return v; +} ExprBaseType EvalExpression::operator()(AST::Rational v) const { @@ -331,7 +339,7 @@ ExprBaseType EvalExpression::operator()(Util::VariableName v) const if (v_opt) return *v_opt; - Util::ERROR("EvalExpression: variable %s not defined", v.c_str()); + Util::ERROR("EvalExpression: variable ", v, " undefined\n"); return Util::MD_NAT(0); } @@ -341,8 +349,11 @@ ExprBaseType EvalExpression::operator()(AST::UnaryOp v) const if (std::holds_alternative(x)) { auto x_value = std::get(x); - if (x_value.arity() == 1) - return Util::MD_NAT(boost::apply_visitor(EvalNat(env_), AST::Expr(v))); + + Util::ERROR_UNLESS(nmbr_dims_ == x_value.arity() || 0 == x_value.arity() + ,"EvalExpr: nmbr_dims_: ", nmbr_dims_, " != arity(", x_value, ")\n"); + + return Util::MD_NAT(boost::apply_visitor(EvalNat(env_), AST::Expr(v))); } return boost::apply_visitor(EvalRat(env_), AST::Expr(v)); @@ -387,18 +398,6 @@ ExprBaseType EvalExpression::operator()(AST::Call v) const } break; - case Eval::Func::member: - if (eval_args.size() == 2) { - arity_ok = true; - - ContainerBaseType container - = std::visit(EvalContainer{}, eval_args[1]); - NatBaseType x = std::visit(EvalNatBT{}, eval_args[0]); - bool result = std::visit(member_visitor_, x, container); - return Util::MD_NAT(result); - } - break; - case Eval::Func::min: if (eval_args.size() == 1) { arity_ok = true; @@ -476,7 +475,7 @@ ExprBaseType EvalExpression::operator()(AST::Call v) const ContainerBaseType subdom = std::visit(EvalContainer{}, eval_args[0]); MapBaseType sbgmap = std::visit(EvalMap(), eval_args[1]); - ExprBaseType result = std::visit(image_visitor2_, subdom, sbgmap); + ExprBaseType result = std::visit(image_visitor_, subdom, sbgmap); return result; } @@ -499,7 +498,7 @@ ExprBaseType EvalExpression::operator()(AST::Call v) const ContainerBaseType subdom = std::visit(EvalContainer{}, eval_args[0]); MapBaseType map = std::visit(EvalMap(), eval_args[1]); - ExprBaseType result = std::visit(pre_image_visitor2_, subdom, map); + ExprBaseType result = std::visit(pre_image_visitor_, subdom, map); return result; } @@ -545,7 +544,7 @@ ExprBaseType EvalExpression::operator()(AST::Call v) const EvalMap visit_map; MapBaseType pw1 = std::visit(visit_map, eval_args[0]); MapBaseType pw2 = std::visit(visit_map, eval_args[1]); - MapBaseType result = std::visit(min_map_visitor2_, pw1, pw2); + MapBaseType result = std::visit(min_map_visitor_, pw1, pw2); return result; } @@ -565,7 +564,7 @@ ExprBaseType EvalExpression::operator()(AST::Call v) const MapBaseType map1 = std::visit(EvalMap{}, eval_args[0]); MapBaseType map2 = std::visit(EvalMap{}, eval_args[1]); - MapBaseType result = std::visit(min_adj_visitor2_, map1, map2); + MapBaseType result = std::visit(min_adj_visitor_, map1, map2); return result; } break; @@ -667,17 +666,18 @@ ExprBaseType EvalExpression::operator()(AST::Call v) const break; default: - Util::ERROR("EvalExpression: function %s not implemented", vname.c_str()); + Util::ERROR("EvalExpression: function ", vname, " not implemented\n"); return Util::MD_NAT(0); } if (!arity_ok) { - Util::ERROR("EvalExpression: wrong number of arguments for Call"); + Util::ERROR("EvalExpression: wrong number of arguments for Call " + , vname, "\n"); return Util::MD_NAT(0); } } - Util::ERROR("EvalExpression: function %s does not exist", vname.c_str()); + Util::ERROR("EvalExpression: function ", vname, " doesn't exist\n"); return Util::MD_NAT(0); } @@ -697,7 +697,7 @@ ExprBaseType EvalExpression::operator()(AST::InterUnaryOp v) const default: std::stringstream ss; ss << v.op(); - Util::ERROR("EvalExpression: InterUnaryOp %s not supported.", ss.str().c_str()); + Util::ERROR("EvalExpression: InterUnaryOp ", v.op(), " unsupported\n"); return Util::MD_NAT(0); } } @@ -718,30 +718,35 @@ ExprBaseType EvalExpression::operator()(AST::InterBinOp v) const return Util::MD_NAT(l == r); default: - std::stringstream ss; - ss << v.op(); - Util::ERROR("EvalExpression: InterBinOp %s not supported.", ss.str().c_str()); + Util::ERROR("EvalExpression: InterBinOp ", v.op(), " unsupported\n"); return Util::MD_NAT(0); } } ExprBaseType EvalExpression::operator()(AST::MultiDimInter v) const { - return boost::apply_visitor(EvalMDI(env_), AST::Expr(v)); + SBG::LIB::SetPiece mdi = boost::apply_visitor(EvalMDI(env_), AST::Expr(v)); + + Util::ERROR_UNLESS(mdi.arity() == nmbr_dims_ || mdi.arity() == 0 + , "EvalExpr: nmbr_dims_: ", nmbr_dims_, " != arity(", mdi, ")\n"); + + return mdi; } ExprBaseType EvalExpression::operator()(AST::MDInterUnaryOp v) const { EvalMDI visit_mdi(env_); LIB::MultiDimInter mdi = boost::apply_visitor(visit_mdi, v.e()); + + Util::ERROR_UNLESS(mdi.arity() == nmbr_dims_ || mdi.arity() == 0 + , "EvalExpr: nmbr_dims_: ", nmbr_dims_, " != arity(", mdi, ")\n"); + switch (v.op()) { case AST::ContainerUOp::card: return Util::MD_NAT(mdi.cardinal()); default: - std::stringstream ss; - ss << v.op(); - Util::ERROR("EvalExpression: MDInterUnaryOp %s not supported.", ss.str().c_str()); + Util::ERROR("EvalExpression: MDInterUnaryOp ", v.op(), " unsupported\n"); return Util::MD_NAT(0); } @@ -753,6 +758,12 @@ ExprBaseType EvalExpression::operator()(AST::MDInterBinOp v) const EvalMDI visit_mdi(env_); LIB::MultiDimInter l = boost::apply_visitor(visit_mdi, v.left()); LIB::MultiDimInter r = boost::apply_visitor(visit_mdi, v.right()); + + Util::ERROR_UNLESS((l.arity() == nmbr_dims_ && r.arity() == nmbr_dims_) + || l.arity() == 0 || r.arity() == 0 + ,"EvalExpr: nmbr_dims_: ", nmbr_dims_, " != arity(", l, ") or arity(", r + , ")\n"); + switch (v.op()) { case AST::ContainerOp::cap: return l.intersection(r); @@ -764,22 +775,32 @@ ExprBaseType EvalExpression::operator()(AST::MDInterBinOp v) const return Util::MD_NAT(l == r); default: - std::stringstream ss; - ss << v.op(); - Util::ERROR("EvalExpression: MDInterBinOp %s not supported.", ss.str().c_str()); + Util::ERROR("EvalExpression: MDInterBinOp ", v.op(), " unsupported\n"); return Util::MD_NAT(0); } + return Util::MD_NAT(0); } + ExprBaseType EvalExpression::operator()(AST::Set v) const { ContainerBaseType c; - if (nmbr_dims_ == 1 && opt_conds_) - c = boost::apply_visitor(EvalOrdSet(env_), AST::Expr(v)); - else - c = boost::apply_visitor(EvalUnordSet(env_), AST::Expr(v)); + if (nmbr_dims_ == 1 && opt_conds_) { + LIB::OrdSet s = boost::apply_visitor(EvalOrdSet(env_), AST::Expr(v)); + c = s; + + Util::ERROR_UNLESS(s.arity() == 1 || s.arity() == 0 + , "EvalExpr: nmbr_dims_: ", nmbr_dims_, " != arity(", s, ")\n"); + } + else { + LIB::UnordSet s = boost::apply_visitor(EvalUnordSet(env_), AST::Expr(v)); + c = s; + + Util::ERROR_UNLESS(s.arity() == nmbr_dims_ || s.arity() == 0 + , "EvalExpr: nmbr_dims_: ", nmbr_dims_, " != arity(", s, ")\n"); + } return c; } @@ -793,9 +814,7 @@ ExprBaseType VisitSetUnOp(AST::SetUnaryOp v, LIB::OrdSet s) return Util::MD_NAT(s.cardinal()); default: - std::stringstream ss; - ss << v.op(); - Util::ERROR("EvalExpression: SetUnaryOp %s not supported.", ss.str().c_str()); + Util::ERROR("EvalExpression: SetUnaryOp ", v.op(), " unsupported\n"); return Util::MD_NAT(0); } @@ -809,9 +828,7 @@ ExprBaseType VisitSetUnOp(AST::SetUnaryOp v, LIB::UnordSet s) return Util::MD_NAT(s.cardinal()); default: - std::stringstream ss; - ss << v.op(); - Util::ERROR("EvalExpression: SetUnaryOp %s not supported.", ss.str().c_str()); + Util::ERROR("EvalExpression: SetUnaryOp ", v.op(), " unsupported\n"); return Util::MD_NAT(0); } @@ -824,12 +841,20 @@ ExprBaseType EvalExpression::operator()(AST::SetUnaryOp v) const if (nmbr_dims_ == 1 && opt_conds_) { EvalOrdSet visit_ord_set(env_); LIB::OrdSet s = boost::apply_visitor(visit_ord_set, exp); + + Util::ERROR_UNLESS(s.arity() == 1 || s.arity() == 0 + , "EvalExpr: nmbr_dims_: ", nmbr_dims_, " != arity(", s, ")\n"); + return VisitSetUnOp(v, s); } else { EvalUnordSet visit_unord_set(env_); LIB::UnordSet s = boost::apply_visitor(visit_unord_set, exp); + + Util::ERROR_UNLESS(s.arity() == nmbr_dims_ || s.arity() == 0 + , "EvalExpr: nmbr_dims_: ", nmbr_dims_, " != arity(", s, ")\n"); + return VisitSetUnOp(v, s); } @@ -854,9 +879,7 @@ ExprBaseType VisitSetBinOp(AST::SetBinOp v, LIB::OrdSet sl, LIB::OrdSet sr) return ContainerBaseType(sl.cup(sr)); default: - std::stringstream ss; - ss << v.op(); - Util::ERROR("EvalExpression: SetBinOp %s not supported.", ss.str().c_str()); + Util::ERROR("EvalExpression: SetBinOp ", v.op(), " unsupported\n"); return Util::MD_NAT(0); } @@ -879,9 +902,7 @@ ExprBaseType VisitSetBinOp(AST::SetBinOp v, LIB::UnordSet sl, LIB::UnordSet sr) return ContainerBaseType(sl.cup(sr)); default: - std::stringstream ss; - ss << v.op(); - Util::ERROR("EvalExpression: SetBinOp %s not supported.", ss.str().c_str()); + Util::ERROR("EvalExpression: SetBinOp ", v.op(), " unsupported\n"); return Util::MD_NAT(0); } @@ -895,6 +916,12 @@ ExprBaseType EvalExpression::operator()(AST::SetBinOp v) const EvalOrdSet visit_ord_set(env_); LIB::OrdSet sl = boost::apply_visitor(visit_ord_set, l); LIB::OrdSet sr = boost::apply_visitor(visit_ord_set, r); + + Util::ERROR_UNLESS((sl.arity() == 1 && sr.arity() == 1) + || sl.arity() == 0 || sr.arity() == 0 + ,"EvalExpr: nmbr_dims_: ", nmbr_dims_ + , " != arity(", sl, ") or arity(", sr, ")\n"); + return VisitSetBinOp(v, sl, sr); } @@ -902,6 +929,12 @@ ExprBaseType EvalExpression::operator()(AST::SetBinOp v) const EvalUnordSet visit_unord_set(env_); LIB::UnordSet sl = boost::apply_visitor(visit_unord_set, l); LIB::UnordSet sr = boost::apply_visitor(visit_unord_set, r); + + Util::ERROR_UNLESS((sl.arity() == nmbr_dims_ && sr.arity() == nmbr_dims_) + || sl.arity() == 0 || sr.arity() == 0 + ,"EvalExpr: nmbr_dims_: ", nmbr_dims_ + , " != arity(", sl, ") or arity(", sr, ")\n"); + return VisitSetBinOp(v, sl, sr); } @@ -932,9 +965,7 @@ ExprBaseType EvalExpression::operator()(AST::LExpBinOp v) const return lexp - rexp; default: - std::stringstream ss; - ss << v.op(); - Util::ERROR("EvalExpression: LExpBinOp %s not supported.", ss.str().c_str()); + Util::ERROR("EvalExpression: LExpBinOp ", v.op(), " unsupported\n"); return Util::MD_NAT(0); } } @@ -943,14 +974,25 @@ ExprBaseType EvalExpression::operator()(AST::LExpBinOp v) const ExprBaseType EvalExpression::operator()(AST::MDLExp v) const { - return boost::apply_visitor(EvalMDLE(env_), AST::Expr(v)); + LIB::Exp mdle = boost::apply_visitor(EvalMDLE(env_), AST::Expr(v)); + + Util::ERROR_UNLESS(mdle.arity() == nmbr_dims_ + , "EvalExpr: nmbr_dims_: ", nmbr_dims_, " != arity(", mdle, ")\n"); + + return mdle; } ExprBaseType EvalExpression::operator()(AST::MDLExpBinOp v) const { AST::Expr l = v.left(), r = v.right(); EvalMDLE visit_le(env_); - LIB::Exp lexp = boost::apply_visitor(visit_le, l), rexp = boost::apply_visitor(visit_le, r); + LIB::Exp lexp = boost::apply_visitor(visit_le, l); + LIB::Exp rexp = boost::apply_visitor(visit_le, r); + + Util::ERROR_UNLESS(lexp.arity() == nmbr_dims_ && rexp.arity() == nmbr_dims_ + ,"EvalExpr: nmbr_dims_: ", nmbr_dims_ + , " != arity(", lexp, ") or arity(", rexp, ")\n"); + switch (v.op()) { case AST::ExpOp::eq: return Util::MD_NAT(lexp == rexp); @@ -962,9 +1004,7 @@ ExprBaseType EvalExpression::operator()(AST::MDLExpBinOp v) const return lexp - rexp; default: - std::stringstream ss; - ss << v.op(); - Util::ERROR("EvalExpression: MDLExpBinOp %s not supported.", ss.str().c_str()); + Util::ERROR("EvalExpression: MDLExpBinOp ", v.op(), " unsupported\n"); return Util::MD_NAT(0); } @@ -975,20 +1015,42 @@ ExprBaseType EvalExpression::operator()(AST::MDLExpBinOp v) const ExprBaseType EvalExpression::operator()(AST::LinearMap v) const { - if (nmbr_dims_ == 1 && opt_conds_) - return boost::apply_visitor(EvalCanonMap(env_), AST::Expr(v)); + if (nmbr_dims_ == 1 && opt_conds_) { + LIB::CanonMap m = boost::apply_visitor(EvalCanonMap(env_), AST::Expr(v)); + + Util::ERROR_UNLESS(m.arity() == 1 || m.arity() == 0 + , "EvalExpr: nmbr_dims_: ", nmbr_dims_, " != arity(", m, ")\n"); + + return m; + } + + LIB::BaseMap m = boost::apply_visitor(EvalBaseMap(env_), AST::Expr(v)); + + Util::ERROR_UNLESS(m.arity() == nmbr_dims_ || m.arity() == 0 + , "EvalExpr: nmbr_dims_: ", nmbr_dims_, " != arity(", m, ")\n"); - return boost::apply_visitor(EvalBaseMap(env_), AST::Expr(v)); + return m; } // ----- // ExprBaseType EvalExpression::operator()(AST::PWLMap v) const { - if (nmbr_dims_ == 1 && opt_conds_) - return boost::apply_visitor(EvalCanonPWMap(env_), AST::Expr(v)); + if (nmbr_dims_ == 1 && opt_conds_) { + LIB::CanonPWMap pw = boost::apply_visitor(EvalCanonPWMap(env_), AST::Expr(v)); + + Util::ERROR_UNLESS(pw.arity() == 1 || pw.arity() == 0 + , "EvalExpr: nmbr_dims_: ", nmbr_dims_, " != arity(", pw, ")\n"); + + return pw; + } + + LIB::BasePWMap pw = boost::apply_visitor(EvalBasePWMap(env_), AST::Expr(v)); + + Util::ERROR_UNLESS(pw.arity() == nmbr_dims_ || pw.arity() == 0 + , "EvalExpr: nmbr_dims_: ", nmbr_dims_, " != arity(", pw, ")\n"); - return boost::apply_visitor(EvalBasePWMap(env_), AST::Expr(v)); + return pw; } ExprBaseType EvalExpression::operator()(AST::SBG v) const diff --git a/eval/visitors/eval_graph.cpp b/eval/visitors/eval_graph.cpp index 9c634ea..4cf9772 100755 --- a/eval/visitors/eval_graph.cpp +++ b/eval/visitors/eval_graph.cpp @@ -25,31 +25,37 @@ namespace Eval { SBGBaseType EvalGraph::operator()(Util::MD_NAT v) const { - Util::ERROR("EvalGraph: trying to evaluate a MD_NAT"); + Util::ERROR("EvalGraph: trying to evaluate MD_NAT ", v, "\n"); return SBGBaseType(); } SBGBaseType EvalGraph::operator()(Util::RATIONAL v) const { - Util::ERROR("EvalGraph: trying to evaluate a RATIONAL"); + Util::ERROR("EvalGraph: trying to evaluate RATIONAL ", v, "\n"); return SBGBaseType(); } SBGBaseType EvalGraph::operator()(ContainerBaseType v) const { - Util::ERROR("EvalGraph: trying to evaluate a ContainerBaseType"); + std::visit([](auto &&arg) { + Util::ERROR("EvalGraph: trying to evaluate ContainerBaseType ", arg, "\n"); + }, v); return SBGBaseType(); } SBGBaseType EvalGraph::operator()(LinearBaseType v) const { - Util::ERROR("EvalGraph: trying to evaluate a LinearBaseType"); + std::visit([](auto &&arg) { + Util::ERROR("EvalGraph: trying to evaluate LinearBaseType ", arg, "\n"); + }, v); return SBGBaseType(); } SBGBaseType EvalGraph::operator()(MapBaseType v) const { - Util::ERROR("EvalGraph: trying to evaluate a MapBaseType"); + std::visit([](auto &&arg) { + Util::ERROR("EvalGraph: trying to evaluate MapBaseType ", arg, "\n"); + }, v); return SBGBaseType(); } @@ -60,7 +66,9 @@ SBGBaseType EvalGraph::operator()(SBGBaseType v) const SBGBaseType EvalGraph::operator()(InfoBaseType v) const { - Util::ERROR("EvalGraph: trying to evaluate an InfoBaseType"); + std::visit([](auto &&arg) { + Util::ERROR("EvalGraph: trying to evaluate InfoBaseType ", arg, "\n"); + }, v); return SBGBaseType(); } diff --git a/eval/visitors/eval_interval.cpp b/eval/visitors/eval_interval.cpp index 0e984b7..9eb7ccb 100755 --- a/eval/visitors/eval_interval.cpp +++ b/eval/visitors/eval_interval.cpp @@ -28,25 +28,25 @@ EvalInterval::EvalInterval(VarEnv env) : env_(env) {} LIB::Interval EvalInterval::operator()(AST::Natural v) const { - Util::ERROR("EvalInterval: trying to evaluate an Natural"); + Util::ERROR("EvalInterval: trying to evaluate Natural ", v, "\n"); return LIB::Interval(); } LIB::Interval EvalInterval::operator()(AST::MDNatural v) const { - Util::ERROR("EvalInterval: trying to evaluate an MDNatural"); + Util::ERROR("EvalInterval: trying to evaluate MDNatural ", v, "\n"); return LIB::Interval(); } LIB::Interval EvalInterval::operator()(AST::Rational v) const { - Util::ERROR("EvalInterval: trying to evaluate a Rational"); + Util::ERROR("EvalInterval: trying to evaluate Rational ", v, "\n"); return LIB::Interval(); } LIB::Interval EvalInterval::operator()(AST::Boolean v) const { - Util::ERROR("EvalInterval: trying to evaluate a Boolean"); + Util::ERROR("EvalInterval: trying to evaluate Boolean ", v, "\n"); return LIB::Interval(); } @@ -62,30 +62,30 @@ LIB::Interval EvalInterval::operator()(Util::VariableName v) const } else { - Util::ERROR("EvalInterval: variable %s is not an interval", v.c_str()); + Util::ERROR("EvalInterval: variable ", v, " is not an interval\n"); return LIB::Interval(); } } - Util::ERROR("EvalInterval: variable %s not defined", v.c_str()); + Util::ERROR("EvalInterval: variable ", v, " undefined\n"); return LIB::Interval(); } LIB::Interval EvalInterval::operator()(AST::UnaryOp v) const { - Util::ERROR("EvalInterval: trying to evaluate an arithmetic UnaryOp"); + Util::ERROR("EvalInterval: trying to evaluate arithmetic UnaryOp ", v, "\n"); return LIB::Interval(); } LIB::Interval EvalInterval::operator()(AST::BinOp v) const { - Util::ERROR("EvalInterval: trying to evaluate an arithmetic BinOp"); + Util::ERROR("EvalInterval: trying to evaluate arithmetic BinOp ", v, "\n"); return LIB::Interval(); } LIB::Interval EvalInterval::operator()(AST::Call v) const { - Util::ERROR("EvalInterval: trying to evaluate a Call"); + Util::ERROR("EvalInterval: trying to evaluate Call ", v, "\n"); return LIB::Interval(); } @@ -104,9 +104,7 @@ LIB::Interval EvalInterval::operator()(AST::InterUnaryOp v) const AST::Expr exp = v.e(); switch (v.op()) { default: - std::stringstream ss; - ss << v.op(); - Util::ERROR("EvalInterval: InterUnaryOp %s not supported.", ss.str().c_str()); + Util::ERROR("EvalInterval: InterUnaryOp ", v.op(), " unsupported\n"); return LIB::Interval(); } } @@ -120,96 +118,92 @@ LIB::Interval EvalInterval::operator()(AST::InterBinOp v) const return l.intersection(r); default: - std::stringstream ss; - ss << v.op(); - Util::ERROR("EvalInterval: InterBinOp %s not supported.", ss.str().c_str()); + Util::ERROR("EvalInterval: InterBinOp ", v.op(), " unsupported\n"); return LIB::Interval(); } } LIB::Interval EvalInterval::operator()(AST::MultiDimInter v) const { - Util::ERROR("EvalInterval: trying to evaluate a MultiDimInter"); + Util::ERROR("EvalInterval: trying to evaluate MultiDimInter ", v, "\n"); return LIB::Interval(); } LIB::Interval EvalInterval::operator()(AST::MDInterUnaryOp v) const { - Util::ERROR("EvalInterval: trying to evaluate a MDInterUnaryOp"); + Util::ERROR("EvalInterval: trying to evaluate MDInterUnaryOp ", v, "\n"); return LIB::Interval(); } LIB::Interval EvalInterval::operator()(AST::MDInterBinOp v) const { - Util::ERROR("EvalInterval: trying to evaluate a MDInterBinOp"); + Util::ERROR("EvalInterval: trying to evaluate MDInterBinOp ", v, "\n"); return LIB::Interval(); } LIB::Interval EvalInterval::operator()(AST::Set v) const { - std::stringstream ss; - ss << v; - Util::ERROR("EvalInterval: trying to evaluate the Set %s", ss.str().c_str()); + Util::ERROR("EvalInterval: trying to evaluate Set ", v, "\n"); return LIB::Interval(); } LIB::Interval EvalInterval::operator()(AST::SetUnaryOp v) const { - Util::ERROR("EvalInterval: trying to evaluate a SetUnaryOp"); + Util::ERROR("EvalInterval: trying to evaluate SetUnaryOp ", v, "\n"); return LIB::Interval(); } LIB::Interval EvalInterval::operator()(AST::SetBinOp v) const { - Util::ERROR("EvalInterval: trying to evaluate a SetBinOp"); + Util::ERROR("EvalInterval: trying to evaluate SetBinOp ", v, "\n"); return LIB::Interval(); } LIB::Interval EvalInterval::operator()(AST::LinearExp v) const { - Util::ERROR("EvalInterval: trying to evaluate a LinearExp"); + Util::ERROR("EvalInterval: trying to evaluate LinearExp ", v, "\n"); return LIB::Interval(); } LIB::Interval EvalInterval::operator()(AST::LExpBinOp v) const { - Util::ERROR("EvalInterval: trying to evaluate a LExpBinOp"); + Util::ERROR("EvalInterval: trying to evaluate LExpBinOp ", v, "\n"); return LIB::Interval(); } LIB::Interval EvalInterval::operator()(AST::MDLExp v) const { - Util::ERROR("EvalInterval: trying to evaluate a LinearExp"); + Util::ERROR("EvalInterval: trying to evaluate MDLExp ", v, "\n"); return LIB::Interval(); } LIB::Interval EvalInterval::operator()(AST::MDLExpBinOp v) const { - Util::ERROR("EvalInterval: trying to evaluate a LExpBinOp"); + Util::ERROR("EvalInterval: trying to evaluate MDLExpBinOp ", v, "\n"); return LIB::Interval(); } LIB::Interval EvalInterval::operator()(AST::LinearMap v) const { - Util::ERROR("EvalInterval: trying to evaluate a LinearMap"); + Util::ERROR("EvalInterval: trying to evaluate LinearMap ", v, "\n"); return LIB::Interval(); } LIB::Interval EvalInterval::operator()(AST::PWLMap v) const { - Util::ERROR("EvalInterval: trying to evaluate a PWLMap"); + Util::ERROR("EvalInterval: trying to evaluate PWLMap ", v, "\n"); return LIB::Interval(); } LIB::Interval EvalInterval::operator()(AST::SBG v) const { - Util::ERROR("EvalInterval: trying to evaluate a SBG"); + Util::ERROR("EvalInterval: trying to evaluate SBG ", v, "\n"); return LIB::Interval(); } LIB::Interval EvalInterval::operator()(AST::DSBG v) const { - Util::ERROR("EvalInterval: trying to evaluate a DSBG"); + Util::ERROR("EvalInterval: trying to evaluate DSBG ", v, "\n"); return LIB::Interval(); } diff --git a/eval/visitors/eval_le.cpp b/eval/visitors/eval_le.cpp index 7365f86..6938a59 100755 --- a/eval/visitors/eval_le.cpp +++ b/eval/visitors/eval_le.cpp @@ -28,25 +28,25 @@ EvalLE::EvalLE(VarEnv env) : env_(env) {} LIB::LExp EvalLE::operator()(AST::Natural v) const { - Util::ERROR("EvalLE: trying to evaluate a Natural"); + Util::ERROR("EvalLE: trying to evaluate Natural ", v, "\n"); return LIB::LExp(); } LIB::LExp EvalLE::operator()(AST::MDNatural v) const { - Util::ERROR("EvalLE: trying to evaluate a MDNatural"); + Util::ERROR("EvalLE: trying to evaluate MDNatural ", v, "\n"); return LIB::LExp(); } LIB::LExp EvalLE::operator()(AST::Rational v) const { - Util::ERROR("EvalLE: trying to evaluate a Rational"); + Util::ERROR("EvalLE: trying to evaluate Rational ", v, "\n"); return LIB::LExp(); } LIB::LExp EvalLE::operator()(AST::Boolean v) const { - Util::ERROR("EvalLE: trying to evaluate a Boolean"); + Util::ERROR("EvalLE: trying to evaluate Boolean ", v, "\n"); return LIB::LExp(); } @@ -62,84 +62,84 @@ LIB::LExp EvalLE::operator()(Util::VariableName v) const } else { - Util::ERROR("EvalLE: variable %s is not a linear expression", v.c_str()); + Util::ERROR("EvalLE: variable ", v, " is not a linear expression\n"); return LIB::LExp(); } } - Util::ERROR("EvalLE: variable %s not defined", v.c_str()); + Util::ERROR("EvalLE: variable ", v, " undefined\n"); return LIB::LExp(); } LIB::LExp EvalLE::operator()(AST::UnaryOp v) const { - Util::ERROR("EvalLE: trying to evaluate an arithmetic UnaryOp"); + Util::ERROR("EvalLE: trying to evaluate arithmetic UnaryOp ", v, "\n"); return LIB::LExp(); } LIB::LExp EvalLE::operator()(AST::BinOp v) const { - Util::ERROR("EvalLE: trying to evaluate an arithmetic BinOp"); + Util::ERROR("EvalLE: trying to evaluate arithmetic BinOp ", v, "\n"); return LIB::LExp(); } LIB::LExp EvalLE::operator()(AST::Call v) const { - Util::ERROR("EvalLE: trying to evaluate a Call"); + Util::ERROR("EvalLE: trying to evaluate Call ", v, "\n"); return LIB::LExp(); } LIB::LExp EvalLE::operator()(AST::Interval v) const { - Util::ERROR("EvalLE: trying to evaluate an Interval"); + Util::ERROR("EvalLE: trying to evaluate Interval ", v, "\n"); return LIB::LExp(); } LIB::LExp EvalLE::operator()(AST::InterUnaryOp v) const { - Util::ERROR("EvalLE: trying to evaluate an InterUnaryOp"); + Util::ERROR("EvalLE: trying to evaluate InterUnaryOp ", v, "\n"); return LIB::LExp(); } LIB::LExp EvalLE::operator()(AST::InterBinOp v) const { - Util::ERROR("EvalLE: trying to evaluate an InterBinOp"); + Util::ERROR("EvalLE: trying to evaluate InterBinOp ", v, "\n"); return LIB::LExp(); } LIB::LExp EvalLE::operator()(AST::MultiDimInter v) const { - Util::ERROR("EvalLE: trying to evaluate an MultiDimInter"); + Util::ERROR("EvalLE: trying to evaluate MultiDimInter ", v, "\n"); return LIB::LExp(); } LIB::LExp EvalLE::operator()(AST::MDInterUnaryOp v) const { - Util::ERROR("EvalLE: trying to evaluate an MDInterUnaryOp"); + Util::ERROR("EvalLE: trying to evaluate MDInterUnaryOp ", v, "\n"); return LIB::LExp(); } LIB::LExp EvalLE::operator()(AST::MDInterBinOp v) const { - Util::ERROR("EvalLE: trying to evaluate an MDInterBinOp"); + Util::ERROR("EvalLE: trying to evaluate MDInterBinOp ", v, "\n"); return LIB::LExp(); } LIB::LExp EvalLE::operator()(AST::Set v) const { - Util::ERROR("EvalLE: trying to evaluate a Set"); + Util::ERROR("EvalLE: trying to evaluate Set ", v, "\n"); return LIB::LExp(); } LIB::LExp EvalLE::operator()(AST::SetUnaryOp v) const { - Util::ERROR("EvalLE: trying to evaluate a SetUnaryOp"); + Util::ERROR("EvalLE: trying to evaluate SetUnaryOp ", v, "\n"); return LIB::LExp(); } LIB::LExp EvalLE::operator()(AST::SetBinOp v) const { - Util::ERROR("EvalLE: trying to evaluate a SetBinOp"); + Util::ERROR("EvalLE: trying to evaluate SetBinOp ", v, "\n"); return LIB::LExp(); } @@ -165,46 +165,44 @@ LIB::LExp EvalLE::operator()(AST::LExpBinOp v) const return l - r; default: - std::stringstream ss; - ss << v.op(); - Util::ERROR("EvalLE: LExpBinOp %s not supported.", ss.str().c_str()); + Util::ERROR("EvalLE: LExpBinOp ", v.op(), " unsupported\n"); return LIB::LExp(); } } LIB::LExp EvalLE::operator()(AST::MDLExp v) const { - Util::ERROR("EvalLE: trying to evaluate an MDLExp"); + Util::ERROR("EvalLE: trying to evaluate MDLExp ", v, "\n"); return LIB::LExp(); } LIB::LExp EvalLE::operator()(AST::MDLExpBinOp v) const { - Util::ERROR("EvalLE: trying to evaluate an MDLExpBinOp"); + Util::ERROR("EvalLE: trying to evaluate MDLExpBinOp ", v, "\n"); return LIB::LExp(); } LIB::LExp EvalLE::operator()(AST::LinearMap v) const { - Util::ERROR("EvalLE: trying to evaluate a LinearMap"); + Util::ERROR("EvalLE: trying to evaluate LinearMap ", v, "\n"); return LIB::LExp(); } LIB::LExp EvalLE::operator()(AST::PWLMap v) const { - Util::ERROR("EvalLE: trying to evaluate a PWLMap"); + Util::ERROR("EvalLE: trying to evaluate PWLMap ", v, "\n"); return LIB::LExp(); } LIB::LExp EvalLE::operator()(AST::SBG v) const { - Util::ERROR("EvalLE: trying to evaluate a SBG"); + Util::ERROR("EvalLE: trying to evaluate SBG ", v, "\n"); return LIB::LExp(); } LIB::LExp EvalLE::operator()(AST::DSBG v) const { - Util::ERROR("EvalLE: trying to evaluate a DSBG"); + Util::ERROR("EvalLE: trying to evaluate DSBG ", v, "\n"); return LIB::LExp(); } diff --git a/eval/visitors/eval_linear.cpp b/eval/visitors/eval_linear.cpp index eebb614..398f198 100755 --- a/eval/visitors/eval_linear.cpp +++ b/eval/visitors/eval_linear.cpp @@ -25,19 +25,21 @@ namespace Eval { LinearBaseType EvalLinear::operator()(Util::MD_NAT v) const { - Util::ERROR("EvalLinear: trying to evaluate a MD_NAT"); + Util::ERROR("EvalLinear: trying to evaluate MD_NAT ", v, "\n"); return LinearBaseType(); } LinearBaseType EvalLinear::operator()(Util::RATIONAL v) const { - Util::ERROR("EvalLinear: trying to evaluate a RATIONAL"); + Util::ERROR("EvalLinear: trying to evaluate RATIONAL ", v, "\n"); return LinearBaseType(); } LinearBaseType EvalLinear::operator()(ContainerBaseType v) const { - Util::ERROR("EvalLinear: trying to evaluate a ContainerBaseType"); + std::visit([](auto &&arg) { + Util::ERROR("EvalLinear: trying to evaluate ContainerBaseType ", arg, "\n"); + }, v); return LinearBaseType(); } @@ -48,19 +50,25 @@ LinearBaseType EvalLinear::operator()(LinearBaseType v) const LinearBaseType EvalLinear::operator()(MapBaseType v) const { - Util::ERROR("EvalLinear: trying to evaluate a BaseType"); + std::visit([](auto &&arg) { + Util::ERROR("EvalLinear: trying to evaluate MapBaseType ", arg, "\n"); + }, v); return LinearBaseType(); } LinearBaseType EvalLinear::operator()(SBGBaseType v) const { - Util::ERROR("EvalLinear: trying to evaluate a BaseType"); + std::visit([](auto &&arg) { + Util::ERROR("EvalLinear: trying to evaluate SBGBaseType ", arg, "\n"); + }, v); return LinearBaseType(); } LinearBaseType EvalLinear::operator()(InfoBaseType v) const { - Util::ERROR("EvalLinear: trying to evaluate a BaseType"); + std::visit([](auto &&arg) { + Util::ERROR("EvalLinear: trying to evaluate InfoBaseType ", arg, "\n"); + }, v); return LinearBaseType(); } } // namespace Eval diff --git a/eval/visitors/eval_map.cpp b/eval/visitors/eval_map.cpp index 71906cf..5bd64c0 100755 --- a/eval/visitors/eval_map.cpp +++ b/eval/visitors/eval_map.cpp @@ -25,25 +25,29 @@ namespace Eval { MapBaseType EvalMap::operator()(Util::MD_NAT v) const { - Util::ERROR("EvalMap: trying to evaluate a MD_NAT"); + Util::ERROR("EvalMap: trying to evaluate MD_NAT ", v, "\n"); return MapBaseType(); } MapBaseType EvalMap::operator()(Util::RATIONAL v) const { - Util::ERROR("EvalMap: trying to evaluate a RATIONAL"); + Util::ERROR("EvalMap: trying to evaluate RATIONAL ", v, "\n"); return MapBaseType(); } MapBaseType EvalMap::operator()(ContainerBaseType v) const { - Util::ERROR("EvalMap: trying to evaluate a ContainerBaseType"); + std::visit([](auto &&arg) { + Util::ERROR("EvalMap: trying to evaluate ContainerBaseType ", arg, "\n"); + }, v); return MapBaseType(); } MapBaseType EvalMap::operator()(LinearBaseType v) const { - Util::ERROR("EvalMap: trying to evaluate a LinearBaseType"); + std::visit([](auto &&arg) { + Util::ERROR("EvalMap: trying to evaluate LinearBaseType ", arg, "\n"); + }, v); return MapBaseType(); } @@ -54,13 +58,17 @@ MapBaseType EvalMap::operator()(MapBaseType v) const MapBaseType EvalMap::operator()(SBGBaseType v) const { - Util::ERROR("EvalMap: trying to evaluate a SBGBaseType"); + std::visit([](auto &&arg) { + Util::ERROR("EvalMap: trying to evaluate SBGBaseType ", arg, "\n"); + }, v); return MapBaseType(); } MapBaseType EvalMap::operator()(InfoBaseType v) const { - Util::ERROR("EvalMap: trying to evaluate an InfoBaseType"); + std::visit([](auto &&arg) { + Util::ERROR("EvalMap: trying to evaluate InfoBaseType ", arg, "\n"); + }, v); return MapBaseType(); } diff --git a/eval/visitors/eval_mdi.cpp b/eval/visitors/eval_mdi.cpp index 99c82d4..bd5eec1 100755 --- a/eval/visitors/eval_mdi.cpp +++ b/eval/visitors/eval_mdi.cpp @@ -28,25 +28,25 @@ EvalMDI::EvalMDI(VarEnv env) : env_(env) {} LIB::MultiDimInter EvalMDI::operator()(AST::Natural v) const { - Util::ERROR("EvalMDI: trying to evaluate an Natural"); + Util::ERROR("EvalMDI: trying to evaluate Natural ", v, "\n"); return LIB::MultiDimInter(); } LIB::MultiDimInter EvalMDI::operator()(AST::MDNatural v) const { - Util::ERROR("EvalMDI: trying to evaluate an MDNatural"); + Util::ERROR("EvalMDI: trying to evaluate MDNatural ", v, "\n"); return LIB::MultiDimInter(); } LIB::MultiDimInter EvalMDI::operator()(AST::Rational v) const { - Util::ERROR("EvalMDI: trying to evaluate a Rational"); + Util::ERROR("EvalMDI: trying to evaluate Rational ", v, "\n"); return LIB::MultiDimInter(); } LIB::MultiDimInter EvalMDI::operator()(AST::Boolean v) const { - Util::ERROR("EvalMDI: trying to evaluate a Boolean"); + Util::ERROR("EvalMDI: trying to evaluate Boolean ", v, "\n"); return LIB::MultiDimInter(); } @@ -62,48 +62,48 @@ LIB::MultiDimInter EvalMDI::operator()(Util::VariableName v) const } else { - Util::ERROR("EvalMDI: variable %s is not an interval", v.c_str()); + Util::ERROR("EvalMDI: variable ", v, " is not an interval\n"); return LIB::MultiDimInter(); } } - Util::ERROR("EvalMDI: variable %s not defined", v.c_str()); + Util::ERROR("EvalMDI: variable ", v, " undefined\n"); return LIB::MultiDimInter(); } LIB::MultiDimInter EvalMDI::operator()(AST::UnaryOp v) const { - Util::ERROR("EvalMDI: trying to evaluate an arithmetic UnaryOp"); + Util::ERROR("EvalMDI: trying to evaluate arithmetic UnaryOp ", v, "\n"); return LIB::MultiDimInter(); } LIB::MultiDimInter EvalMDI::operator()(AST::BinOp v) const { - Util::ERROR("EvalMDI: trying to evaluate an arithmetic BinOp"); + Util::ERROR("EvalMDI: trying to evaluate arithmetic BinOp ", v, "\n"); return LIB::MultiDimInter(); } LIB::MultiDimInter EvalMDI::operator()(AST::Call v) const { - Util::ERROR("EvalMDI: trying to evaluate a Call"); + Util::ERROR("EvalMDI: trying to evaluate Call ", v, "\n"); return LIB::MultiDimInter(); } LIB::MultiDimInter EvalMDI::operator()(AST::Interval v) const { - Util::ERROR("EvalMDI: trying to evaluate an Interval"); + Util::ERROR("EvalMDI: trying to evaluate Interval ", v, "\n"); return LIB::MultiDimInter(); } LIB::MultiDimInter EvalMDI::operator()(AST::InterUnaryOp v) const { - Util::ERROR("EvalMDI: trying to evaluate an InterUnaryOp"); + Util::ERROR("EvalMDI: trying to evaluate InterUnaryOp ", v, "\n"); return LIB::MultiDimInter(); } LIB::MultiDimInter EvalMDI::operator()(AST::InterBinOp v) const { - Util::ERROR("EvalMDI: trying to evaluate an InterBinOp"); + Util::ERROR("EvalMDI: trying to evaluate InterBinOp ", v, "\n"); return LIB::MultiDimInter(); } @@ -123,9 +123,7 @@ LIB::MultiDimInter EvalMDI::operator()(AST::MDInterUnaryOp v) const AST::Expr exp = v.e(); switch (v.op()) { default: - std::stringstream ss; - ss << v.op(); - Util::ERROR("EvalMDI: MDInterUnaryOp %s not supported.", ss.str().c_str()); + Util::ERROR("EvalMDI: MDInterUnaryOp ", v.op(), " unsupported\n"); return LIB::MultiDimInter(); } } @@ -139,78 +137,74 @@ LIB::MultiDimInter EvalMDI::operator()(AST::MDInterBinOp v) const return l.intersection(r); default: - std::stringstream ss; - ss << v.op(); - Util::ERROR("EvalMD: MDInterBinOp %s not supported.", ss.str().c_str()); + Util::ERROR("EvalMD: MDInterBinOp ", v.op(), " unsupported\n"); return LIB::MultiDimInter(); } } LIB::MultiDimInter EvalMDI::operator()(AST::Set v) const { - std::stringstream ss; - ss << v; - Util::ERROR("EvalMDI: trying to evaluate the Set %s", ss.str().c_str()); + Util::ERROR("EvalMDI: trying to evaluate Set ", v, "\n"); return LIB::MultiDimInter(); } LIB::MultiDimInter EvalMDI::operator()(AST::SetUnaryOp v) const { - Util::ERROR("EvalMDI: trying to evaluate a SetUnaryOp"); + Util::ERROR("EvalMDI: trying to evaluate SetUnaryOp ", v, "\n"); return LIB::MultiDimInter(); } LIB::MultiDimInter EvalMDI::operator()(AST::SetBinOp v) const { - Util::ERROR("EvalMDI: trying to evaluate a SetBinOp"); + Util::ERROR("EvalMDI: trying to evaluate SetBinOp ", v, "\n"); return LIB::MultiDimInter(); } LIB::MultiDimInter EvalMDI::operator()(AST::LinearExp v) const { - Util::ERROR("EvalMDI: trying to evaluate a LinearExp"); + Util::ERROR("EvalMDI: trying to evaluate LinearExp ", v, "\n"); return LIB::MultiDimInter(); } LIB::MultiDimInter EvalMDI::operator()(AST::LExpBinOp v) const { - Util::ERROR("EvalMDI: trying to evaluate a LExpBinOp"); + Util::ERROR("EvalMDI: trying to evaluate LExpBinOp ", v, "\n"); return LIB::MultiDimInter(); } LIB::MultiDimInter EvalMDI::operator()(AST::MDLExp v) const { - Util::ERROR("EvalMDI: trying to evaluate a LinearExp"); + Util::ERROR("EvalMDI: trying to evaluate MDLExp ", v, "\n"); return LIB::MultiDimInter(); } LIB::MultiDimInter EvalMDI::operator()(AST::MDLExpBinOp v) const { - Util::ERROR("EvalMDI: trying to evaluate a LExpBinOp"); + Util::ERROR("EvalMDI: trying to evaluate MDLExpBinOp ", v, "\n"); return LIB::MultiDimInter(); } LIB::MultiDimInter EvalMDI::operator()(AST::LinearMap v) const { - Util::ERROR("EvalMDI: trying to evaluate a LinearMap"); + Util::ERROR("EvalMDI: trying to evaluate LinearMap ", v, "\n"); return LIB::MultiDimInter(); } LIB::MultiDimInter EvalMDI::operator()(AST::PWLMap v) const { - Util::ERROR("EvalMDI: trying to evaluate a PWLMap"); + Util::ERROR("EvalMDI: trying to evaluate PWLMap ", v, "\n"); return LIB::MultiDimInter(); } LIB::MultiDimInter EvalMDI::operator()(AST::SBG v) const { - Util::ERROR("EvalMDI: trying to evaluate a SBG"); + Util::ERROR("EvalMDI: trying to evaluate SBG ", v, "\n"); return LIB::MultiDimInter(); } LIB::MultiDimInter EvalMDI::operator()(AST::DSBG v) const { - Util::ERROR("EvalMDI: trying to evaluate a DSBG"); + Util::ERROR("EvalMDI: trying to evaluate DSBG ", v, "\n"); return LIB::MultiDimInter(); } diff --git a/eval/visitors/eval_mdle.cpp b/eval/visitors/eval_mdle.cpp index 65634a2..885f2f3 100755 --- a/eval/visitors/eval_mdle.cpp +++ b/eval/visitors/eval_mdle.cpp @@ -28,25 +28,25 @@ EvalMDLE::EvalMDLE(VarEnv env) : env_(env) {} LIB::Exp EvalMDLE::operator()(AST::Natural v) const { - Util::ERROR("EvalMDLE: trying to evaluate a Natural"); + Util::ERROR("EvalMDLE: trying to evaluate Natural ", v, "\n"); return LIB::Exp(); } LIB::Exp EvalMDLE::operator()(AST::MDNatural v) const { - Util::ERROR("EvalMDLE: trying to evaluate a MDNatural"); + Util::ERROR("EvalMDLE: trying to evaluate MDNatural ", v, "\n"); return LIB::Exp(); } LIB::Exp EvalMDLE::operator()(AST::Rational v) const { - Util::ERROR("EvalMDLE: trying to evaluate a Rational"); + Util::ERROR("EvalMDLE: trying to evaluate Rational ", v, "\n"); return LIB::Exp(); } LIB::Exp EvalMDLE::operator()(AST::Boolean v) const { - Util::ERROR("EvalMDLE: trying to evaluate a Boolean"); + Util::ERROR("EvalMDLE: trying to evaluate Boolean ", v, "\n"); return LIB::Exp(); } @@ -62,96 +62,96 @@ LIB::Exp EvalMDLE::operator()(Util::VariableName v) const } else { - Util::ERROR("EvalMDLE: variable %s is not a linear expression", v.c_str()); + Util::ERROR("EvalMDLE: variable ", v, " is not a mdle\n"); return LIB::Exp(); } } - Util::ERROR("EvalMDLE: variable %s not defined", v.c_str()); + Util::ERROR("EvalMDLE: variable ", v, " undefined\n"); return LIB::Exp(); } LIB::Exp EvalMDLE::operator()(AST::UnaryOp v) const { - Util::ERROR("EvalMDLE: trying to evaluate an arithmetic UnaryOp"); + Util::ERROR("EvalMDLE: trying to evaluate arithmetic UnaryOp ", v , "\n"); return LIB::Exp(); } LIB::Exp EvalMDLE::operator()(AST::BinOp v) const { - Util::ERROR("EvalMDLE: trying to evaluate an arithmetic BinOp"); + Util::ERROR("EvalMDLE: trying to evaluate arithmetic BinOp ", v, "\n"); return LIB::Exp(); } LIB::Exp EvalMDLE::operator()(AST::Call v) const { - Util::ERROR("EvalMDLE: trying to evaluate a Call"); + Util::ERROR("EvalMDLE: trying to evaluate Call ", v, "\n"); return LIB::Exp(); } LIB::Exp EvalMDLE::operator()(AST::Interval v) const { - Util::ERROR("EvalMDLE: trying to evaluate an Interval"); + Util::ERROR("EvalMDLE: trying to evaluate Interval ", v, "\n"); return LIB::Exp(); } LIB::Exp EvalMDLE::operator()(AST::InterUnaryOp v) const { - Util::ERROR("EvalMDLE: trying to evaluate an InterUnaryOp"); + Util::ERROR("EvalMDLE: trying to evaluate InterUnaryOp ", v, "\n"); return LIB::Exp(); } LIB::Exp EvalMDLE::operator()(AST::InterBinOp v) const { - Util::ERROR("EvalMDLE: trying to evaluate an InterBinOp"); + Util::ERROR("EvalMDLE: trying to evaluate InterBinOp ", v, "\n"); return LIB::Exp(); } LIB::Exp EvalMDLE::operator()(AST::MultiDimInter v) const { - Util::ERROR("EvalMDLE: trying to evaluate an MultiDimInter"); + Util::ERROR("EvalMDLE: trying to evaluate MultiDimInter ", v, "\n"); return LIB::Exp(); } LIB::Exp EvalMDLE::operator()(AST::MDInterUnaryOp v) const { - Util::ERROR("EvalMDLE: trying to evaluate an MDInterUnaryOp"); + Util::ERROR("EvalMDLE: trying to evaluate MDInterUnaryOp ", v, "\n"); return LIB::Exp(); } LIB::Exp EvalMDLE::operator()(AST::MDInterBinOp v) const { - Util::ERROR("EvalMDLE: trying to evaluate an MDInterBinOp"); + Util::ERROR("EvalMDLE: trying to evaluate MDInterBinOp ", v, "\n"); return LIB::Exp(); } LIB::Exp EvalMDLE::operator()(AST::Set v) const { - Util::ERROR("EvalMDLE: trying to evaluate a Set"); + Util::ERROR("EvalMDLE: trying to evaluate Set ", v, "\n"); return LIB::Exp(); } LIB::Exp EvalMDLE::operator()(AST::SetUnaryOp v) const { - Util::ERROR("EvalMDLE: trying to evaluate a SetUnaryOp"); + Util::ERROR("EvalMDLE: trying to evaluate SetUnaryOp ", v, "\n"); return LIB::Exp(); } LIB::Exp EvalMDLE::operator()(AST::SetBinOp v) const { - Util::ERROR("EvalMDLE: trying to evaluate a SetBinOp"); + Util::ERROR("EvalMDLE: trying to evaluate SetBinOp ", v, "\n"); return LIB::Exp(); } LIB::Exp EvalMDLE::operator()(AST::LinearExp v) const { - Util::ERROR("EvalMDLE: trying to evaluate a LinearExp"); + Util::ERROR("EvalMDLE: trying to evaluate LinearExp ", v, "\n"); return LIB::Exp(); } LIB::Exp EvalMDLE::operator()(AST::LExpBinOp v) const { - Util::ERROR("EvalMDLE: trying to evaluate a LExpBinOp"); + Util::ERROR("EvalMDLE: trying to evaluate LExpBinOp ", v, "\n"); return LIB::Exp(); } @@ -178,34 +178,32 @@ LIB::Exp EvalMDLE::operator()(AST::MDLExpBinOp v) const return l - r; default: - std::stringstream ss; - ss << v.op(); - Util::ERROR("EvalMDLE: LExpBinOp %s not supported.", ss.str().c_str()); + Util::ERROR("EvalMDLE: LExpBinOp ", v.op(), " unsupported\n"); return LIB::Exp(); } } LIB::Exp EvalMDLE::operator()(AST::LinearMap v) const { - Util::ERROR("EvalMDLE: trying to evaluate a LinearMap"); + Util::ERROR("EvalMDLE: trying to evaluate LinearMap ", v, "\n"); return LIB::Exp(); } LIB::Exp EvalMDLE::operator()(AST::PWLMap v) const { - Util::ERROR("EvalMDLE: trying to evaluate a PWLMap"); + Util::ERROR("EvalMDLE: trying to evaluate PWLMap ", v, "\n"); return LIB::Exp(); } LIB::Exp EvalMDLE::operator()(AST::SBG v) const { - Util::ERROR("EvalMDLE: trying to evaluate a SBG"); + Util::ERROR("EvalMDLE: trying to evaluate SBG ", v, "\n"); return LIB::Exp(); } LIB::Exp EvalMDLE::operator()(AST::DSBG v) const { - Util::ERROR("EvalMDLE: trying to evaluate a DSBG"); + Util::ERROR("EvalMDLE: trying to evaluate DSBG ", v, "\n"); return LIB::Exp(); } diff --git a/eval/visitors/eval_mdnat.cpp b/eval/visitors/eval_mdnat.cpp index d3e04c6..6b0d49d 100755 --- a/eval/visitors/eval_mdnat.cpp +++ b/eval/visitors/eval_mdnat.cpp @@ -28,7 +28,7 @@ EvalMDNat::EvalMDNat(VarEnv env) : env_(env) {} Util::MD_NAT EvalMDNat::operator()(AST::Natural v) const { - Util::ERROR("EvalMDNat: trying to evaluate a Natural"); + Util::ERROR("EvalMDNat: trying to evaluate Natural ", v, "\n"); return 0; } @@ -39,7 +39,7 @@ Util::MD_NAT EvalMDNat::operator()(AST::Rational v) const if (v.denominator() == 1) return v.numerator(); - Util::ERROR("EvalMDNat: trying to evaluate a Rational"); + Util::ERROR("EvalMDNat: trying to evaluate Rational ", v, "\n"); return 0; } @@ -60,13 +60,13 @@ Util::MD_NAT EvalMDNat::operator()(Util::VariableName v) const return std::get(value); } - Util::ERROR("EvalMDNat: variable %s not defined", v.c_str()); + Util::ERROR("EvalMDNat: variable ", v, " undefined"\n); return 0; } Util::MD_NAT EvalMDNat::operator()(AST::UnaryOp v) const { - Util::ERROR("EvalMDNat: trying to evaluate an arithmetic UnaryOp"); + Util::ERROR("EvalMDNat: trying to evaluate arithmetic UnaryOp ", v, "\n"); return 0; } @@ -87,118 +87,116 @@ Util::MD_NAT EvalMDNat::operator()(AST::BinOp v) const return pow(ApplyThis(l), ApplyThis(r)); default: - std::stringstream ss; - ss << v.op(); - Util::ERROR("EvalMDNat: BinOp %s not supported.", ss.str().c_str()); + Util::ERROR("EvalMDNat: BinOp ", v.op(), " unsupported\n"); return 0; } } Util::MD_NAT EvalMDNat::operator()(AST::Call v) const { - Util::ERROR("EvalMDNat: trying to evaluate a Call"); + Util::ERROR("EvalMDNat: trying to evaluate Call ", v, "\n"); return 0; } Util::MD_NAT EvalMDNat::operator()(AST::Interval v) const { - Util::ERROR("EvalMDNat: trying to evaluate an Interval"); + Util::ERROR("EvalMDNat: trying to evaluate Interval ", v, "\n"); return 0; } Util::MD_NAT EvalMDNat::operator()(AST::InterUnaryOp v) const { - Util::ERROR("EvalMDNat: trying to evaluate an InterUnaryOp"); + Util::ERROR("EvalMDNat: trying to evaluate InterUnaryOp ", v, "\n"); return 0; } Util::MD_NAT EvalMDNat::operator()(AST::InterBinOp v) const { - Util::ERROR("EvalMDNat: trying to evaluate an InterBinOp"); + Util::ERROR("EvalMDNat: trying to evaluate InterBinOp ", v, "\n"); return 0; } Util::MD_NAT EvalMDNat::operator()(AST::MultiDimInter v) const { - Util::ERROR("EvalMDNat: trying to evaluate an MultiDimInter"); + Util::ERROR("EvalMDNat: trying to evaluate MultiDimInter ", v, "\n"); return 0; } Util::MD_NAT EvalMDNat::operator()(AST::MDInterUnaryOp v) const { - Util::ERROR("EvalMDNat: trying to evaluate an MDInterUnaryOp"); + Util::ERROR("EvalMDNat: trying to evaluate MDInterUnaryOp ", v, "\n"); return 0; } Util::MD_NAT EvalMDNat::operator()(AST::MDInterBinOp v) const { - Util::ERROR("EvalMDNat: trying to evaluate an MDInterBinOp"); + Util::ERROR("EvalMDNat: trying to evaluate MDInterBinOp ", v, "\n"); return 0; } Util::MD_NAT EvalMDNat::operator()(AST::Set v) const { - Util::ERROR("EvalMDNat: trying to evaluate an Set"); + Util::ERROR("EvalMDNat: trying to evaluate Set ", v, "\n"); return 0; } Util::MD_NAT EvalMDNat::operator()(AST::SetUnaryOp v) const { - Util::ERROR("EvalMDNat: trying to evaluate an SetUnaryOp"); + Util::ERROR("EvalMDNat: trying to evaluate SetUnaryOp ", v, "\n"); return 0; } Util::MD_NAT EvalMDNat::operator()(AST::SetBinOp v) const { - Util::ERROR("EvalMDNat: trying to evaluate an SetBinOp"); + Util::ERROR("EvalMDNat: trying to evaluate SetBinOp ", v, "\n"); return 0; } Util::MD_NAT EvalMDNat::operator()(AST::LinearExp v) const { - Util::ERROR("EvalMDNat: trying to evaluate a LinearExp"); + Util::ERROR("EvalMDNat: trying to evaluate LinearExp ", v, "\n"); return 0; } Util::MD_NAT EvalMDNat::operator()(AST::LExpBinOp v) const { - Util::ERROR("EvalMDNat: trying to evaluate a LExpBinOp"); + Util::ERROR("EvalMDNat: trying to evaluate LExpBinOp ", v, "\n"); return 0; } Util::MD_NAT EvalMDNat::operator()(AST::MDLExp v) const { - Util::ERROR("EvalMDNat: trying to evaluate a MDLExp"); + Util::ERROR("EvalMDNat: trying to evaluate MDLExp ", v, "\n"); return 0; } Util::MD_NAT EvalMDNat::operator()(AST::MDLExpBinOp v) const { - Util::ERROR("EvalMDNat: trying to evaluate a MDLExpBinOp"); + Util::ERROR("EvalMDNat: trying to evaluate MDLExpBinOp ", v, "\n"); return 0; } Util::MD_NAT EvalMDNat::operator()(AST::LinearMap v) const { - Util::ERROR("EvalMDNat: trying to evaluate a LinearMap"); + Util::ERROR("EvalMDNat: trying to evaluate LinearMap ", v, "\n"); return 0; } Util::MD_NAT EvalMDNat::operator()(AST::PWLMap v) const { - Util::ERROR("EvalMDNat: trying to evaluate a PWLMap"); + Util::ERROR("EvalMDNat: trying to evaluate PWLMap ", v, "\n"); return 0; } Util::MD_NAT EvalMDNat::operator()(AST::SBG v) const { - Util::ERROR("EvalMDNat: trying to evaluate a SBG"); + Util::ERROR("EvalMDNat: trying to evaluate a SBG ", v, "\n"); return 0; } Util::MD_NAT EvalMDNat::operator()(AST::DSBG v) const { - Util::ERROR("EvalMDNat: trying to evaluate a DSBG"); + Util::ERROR("EvalMDNat: trying to evaluate a DSBG ", v, "\n"); return 0; } diff --git a/eval/visitors/eval_nat.cpp b/eval/visitors/eval_nat.cpp index 02f73dc..4d4f307 100755 --- a/eval/visitors/eval_nat.cpp +++ b/eval/visitors/eval_nat.cpp @@ -30,7 +30,7 @@ Util::NAT EvalNat::operator()(AST::Natural v) const { return v; } Util::NAT EvalNat::operator()(AST::MDNatural v) const { - Util::ERROR("EvalNat: trying to evaluate a MDNatural"); + Util::ERROR("EvalNat: trying to evaluate MDNatural ", v, "\n"); return 0; } @@ -39,7 +39,7 @@ Util::NAT EvalNat::operator()(AST::Rational v) const if (boost::apply_visitor(*this, v.den()) == 1) return boost::apply_visitor(*this, v.num()); - Util::ERROR("EvalNat: trying to evaluate a Rational"); + Util::ERROR("EvalNat: trying to evaluate Rational ", v, "\n"); return 0; } @@ -67,13 +67,13 @@ Util::NAT EvalNat::operator()(Util::VariableName v) const return std::get(value).toNat(); } - Util::ERROR("EvalNat: variable %s not defined", v.c_str()); + Util::ERROR("EvalNat: variable ", v, " undefined\n"); return 0; } Util::NAT EvalNat::operator()(AST::UnaryOp v) const { - Util::ERROR("EvalNat: trying to evaluate an arithmetic UnaryOp"); + Util::ERROR("EvalNat: trying to evaluate arithmetic UnaryOp ", v, "\n"); return 0; } @@ -95,118 +95,116 @@ Util::NAT EvalNat::operator()(AST::BinOp v) const return pow(l, r); default: - std::stringstream ss; - ss << v.op(); - Util::ERROR("EvalNat: BinOp %s not supported.", ss.str().c_str()); + Util::ERROR("EvalNat: BinOp ", v.op(), " unsupported\n"); return 0; } } Util::NAT EvalNat::operator()(AST::Call v) const { - Util::ERROR("EvalNat: trying to evaluate a Call"); + Util::ERROR("EvalNat: trying to evaluate Call ", v, "\n"); return 0; } Util::NAT EvalNat::operator()(AST::Interval v) const { - Util::ERROR("EvalNat: trying to evaluate an Interval"); + Util::ERROR("EvalNat: trying to evaluate Interval ", v, "\n"); return 0; } Util::NAT EvalNat::operator()(AST::InterUnaryOp v) const { - Util::ERROR("EvalNat: trying to evaluate an InterUnaryOp"); + Util::ERROR("EvalNat: trying to evaluate InterUnaryOp ", v, "\n"); return 0; } Util::NAT EvalNat::operator()(AST::InterBinOp v) const { - Util::ERROR("EvalNat: trying to evaluate an InterBinOp"); + Util::ERROR("EvalNat: trying to evaluate InterBinOp ", v, "\n"); return 0; } Util::NAT EvalNat::operator()(AST::MultiDimInter v) const { - Util::ERROR("EvalNat: trying to evaluate an MultiDimInter"); + Util::ERROR("EvalNat: trying to evaluate MultiDimInter ", v, "\n"); return 0; } Util::NAT EvalNat::operator()(AST::MDInterUnaryOp v) const { - Util::ERROR("EvalNat: trying to evaluate an MDInterUnaryOp"); + Util::ERROR("EvalNat: trying to evaluate MDInterUnaryOp ", v, "\n"); return 0; } Util::NAT EvalNat::operator()(AST::MDInterBinOp v) const { - Util::ERROR("EvalNat: trying to evaluate an MDInterBinOp"); + Util::ERROR("EvalNat: trying to evaluate MDInterBinOp ", v, "\n"); return 0; } Util::NAT EvalNat::operator()(AST::Set v) const { - Util::ERROR("EvalNat: trying to evaluate an Set"); + Util::ERROR("EvalNat: trying to evaluate Set ", v, "\n"); return 0; } Util::NAT EvalNat::operator()(AST::SetUnaryOp v) const { - Util::ERROR("EvalNat: trying to evaluate an SetUnaryOp"); + Util::ERROR("EvalNat: trying to evaluate SetUnaryOp ", v, "\n"); return 0; } Util::NAT EvalNat::operator()(AST::SetBinOp v) const { - Util::ERROR("EvalNat: trying to evaluate an SetBinOp"); + Util::ERROR("EvalNat: trying to evaluate SetBinOp ", v, "\n"); return 0; } Util::NAT EvalNat::operator()(AST::LinearExp v) const { - Util::ERROR("EvalNat: trying to evaluate a LinearExp"); + Util::ERROR("EvalNat: trying to evaluate LinearExp ", v, "\n"); return 0; } Util::NAT EvalNat::operator()(AST::LExpBinOp v) const { - Util::ERROR("EvalNat: trying to evaluate a LExpBinOp"); + Util::ERROR("EvalNat: trying to evaluate LExpBinOp ", v, "\n"); return 0; } Util::NAT EvalNat::operator()(AST::MDLExp v) const { - Util::ERROR("EvalNat: trying to evaluate a MDLExp"); + Util::ERROR("EvalNat: trying to evaluate MDLExp ", v, "\n"); return 0; } Util::NAT EvalNat::operator()(AST::MDLExpBinOp v) const { - Util::ERROR("EvalNat: trying to evaluate a MDLExpBinOp"); + Util::ERROR("EvalNat: trying to evaluate MDLExpBinOp ", v, "\n"); return 0; } Util::NAT EvalNat::operator()(AST::LinearMap v) const { - Util::ERROR("EvalNat: trying to evaluate a LinearMap"); + Util::ERROR("EvalNat: trying to evaluate LinearMap ", v, "\n"); return 0; } Util::NAT EvalNat::operator()(AST::PWLMap v) const { - Util::ERROR("EvalNat: trying to evaluate a PWLMap"); + Util::ERROR("EvalNat: trying to evaluate PWLMap ", v, "\n"); return 0; } Util::NAT EvalNat::operator()(AST::SBG v) const { - Util::ERROR("EvalNat: trying to evaluate a SBG"); + Util::ERROR("EvalNat: trying to evaluate SBG ", v, "\n"); return 0; } Util::NAT EvalNat::operator()(AST::DSBG v) const { - Util::ERROR("EvalNat: trying to evaluate a DSBG"); + Util::ERROR("EvalNat: trying to evaluate DSBG ", v, "\n"); return 0; } diff --git a/eval/visitors/eval_natbt.cpp b/eval/visitors/eval_natbt.cpp index a76310a..5b7ec88 100755 --- a/eval/visitors/eval_natbt.cpp +++ b/eval/visitors/eval_natbt.cpp @@ -27,37 +27,47 @@ NatBaseType EvalNatBT::operator()(Util::MD_NAT v) const { return v; } NatBaseType EvalNatBT::operator()(Util::RATIONAL v) const { - Util::ERROR("EvalNatBT: trying to evaluate a RATIONAL"); + Util::ERROR("EvalNatBT: trying to evaluate RATIONAL ", v, "\n"); return NatBaseType(); } NatBaseType EvalNatBT::operator()(ContainerBaseType v) const { - Util::ERROR("EvalNatBT: trying to evaluate a ContainerBaseType"); + std::visit([](auto &&arg) { + Util::ERROR("EvalNatBT: trying to evaluate ContainerBaseType ", arg, "\n"); + }, v); return NatBaseType(); } NatBaseType EvalNatBT::operator()(LinearBaseType v) const { - Util::ERROR("EvalNatBT: trying to evaluate a LinearBaseType"); + std::visit([](auto &&arg) { + Util::ERROR("EvalNatBT: trying to evaluate LinearBaseType ", arg, "\n"); + }, v); return NatBaseType(); } NatBaseType EvalNatBT::operator()(MapBaseType v) const { - Util::ERROR("EvalNatBT: trying to evaluate a MapBaseType"); + std::visit([](auto &&arg) { + Util::ERROR("EvalNatBT: trying to evaluate MapBaseType ", arg, "\n"); + }, v); return NatBaseType(); } NatBaseType EvalNatBT::operator()(SBGBaseType v) const { - Util::ERROR("EvalNatBT: trying to evaluate a SBGBaseType"); + std::visit([](auto &&arg) { + Util::ERROR("EvalNatBT: trying to evaluate SBGBaseType ", arg, "\n"); + }, v); return NatBaseType(); } NatBaseType EvalNatBT::operator()(InfoBaseType v) const { - Util::ERROR("EvalNatBT: trying to evaluate an InfoBaseType"); + std::visit([](auto &&arg) { + Util::ERROR("EvalNatBT: trying to evaluate InfoBaseType ", arg, "\n"); + }, v); return NatBaseType(); } diff --git a/eval/visitors/eval_ord_set.cpp b/eval/visitors/eval_ord_set.cpp index 5003fe3..9186ed9 100755 --- a/eval/visitors/eval_ord_set.cpp +++ b/eval/visitors/eval_ord_set.cpp @@ -28,25 +28,25 @@ EvalOrdSet::EvalOrdSet(VarEnv env) : env_(env) {} LIB::OrdSet EvalOrdSet::operator()(AST::Natural v) const { - Util::ERROR("EvalOrdSet: trying to evaluate a Natural"); + Util::ERROR("EvalOrdSet: trying to evaluate Natural ", v, "\n"); return LIB::OrdSet(); } LIB::OrdSet EvalOrdSet::operator()(AST::MDNatural v) const { - Util::ERROR("EvalOrdSet: trying to evaluate a MDNatural"); + Util::ERROR("EvalOrdSet: trying to evaluate MDNatural ", v, "\n"); return LIB::OrdSet(); } LIB::OrdSet EvalOrdSet::operator()(AST::Rational v) const { - Util::ERROR("EvalOrdSet: trying to evaluate a Rational"); + Util::ERROR("EvalOrdSet: trying to evaluate Rational ", v, "\n"); return LIB::OrdSet(); } LIB::OrdSet EvalOrdSet::operator()(AST::Boolean v) const { - Util::ERROR("EvalOrdSet: trying to evaluate a Boolean"); + Util::ERROR("EvalOrdSet: trying to evaluate Boolean ", v, "\n"); return LIB::OrdSet(); } @@ -62,66 +62,66 @@ LIB::OrdSet EvalOrdSet::operator()(Util::VariableName v) const } else { - Util::ERROR("EvalOrdSet: variable %s is not a set", v.c_str()); + Util::ERROR("EvalOrdSet: variable ", v, " is not a set\n"); return LIB::OrdSet(); } } - Util::ERROR("EvalOrdSet: variable %s not defined", v.c_str()); + Util::ERROR("EvalOrdSet: variable ", v, " undefined\n"); return LIB::OrdSet(); } LIB::OrdSet EvalOrdSet::operator()(AST::UnaryOp v) const { - Util::ERROR("EvalOrdSet: trying to evaluate an arithmetic UnaryOp"); + Util::ERROR("EvalOrdSet: trying to evaluate arithmetic UnaryOp ", v, "\n"); return LIB::OrdSet(); } LIB::OrdSet EvalOrdSet::operator()(AST::BinOp v) const { - Util::ERROR("EvalOrdSet: trying to evaluate an arithmetic BinOp"); + Util::ERROR("EvalOrdSet: trying to evaluate arithmetic BinOp ", v, "\n"); return LIB::OrdSet(); } LIB::OrdSet EvalOrdSet::operator()(AST::Call v) const { - Util::ERROR("EvalOrdSet: trying to evaluate a Call"); + Util::ERROR("EvalOrdSet: trying to evaluate Call ", v, "\n"); return LIB::OrdSet(); } LIB::OrdSet EvalOrdSet::operator()(AST::Interval v) const { - Util::ERROR("EvalOrdSet: trying to evaluate an Interval"); + Util::ERROR("EvalOrdSet: trying to evaluate Interval ", v, "\n"); return LIB::OrdSet(); } LIB::OrdSet EvalOrdSet::operator()(AST::InterUnaryOp v) const { - Util::ERROR("EvalOrdSet: trying to evaluate an InterUnaryOp"); + Util::ERROR("EvalOrdSet: trying to evaluate InterUnaryOp ", v, "\n"); return LIB::OrdSet(); } LIB::OrdSet EvalOrdSet::operator()(AST::InterBinOp v) const { - Util::ERROR("EvalOrdSet: trying to evaluate an InterBinOp"); + Util::ERROR("EvalOrdSet: trying to evaluate InterBinOp ", v, "\n"); return LIB::OrdSet(); } LIB::OrdSet EvalOrdSet::operator()(AST::MultiDimInter v) const { - Util::ERROR("EvalOrdSet: trying to evaluate an MultiDimInter"); + Util::ERROR("EvalOrdSet: trying to evaluate MultiDimInter ", v, "\n"); return LIB::OrdSet(); } LIB::OrdSet EvalOrdSet::operator()(AST::MDInterUnaryOp v) const { - Util::ERROR("EvalOrdSet: trying to evaluate an MDInterUnaryOp"); + Util::ERROR("EvalOrdSet: trying to evaluate MDInterUnaryOp ", v, "\n"); return LIB::OrdSet(); } LIB::OrdSet EvalOrdSet::operator()(AST::MDInterBinOp v) const { - Util::ERROR("EvalOrdSet: trying to evaluate an MDInterBinOp"); + Util::ERROR("EvalOrdSet: trying to evaluate MDInterBinOp ", v, "\n"); return LIB::OrdSet(); } @@ -141,9 +141,7 @@ LIB::OrdSet EvalOrdSet::operator()(AST::SetUnaryOp v) const AST::Expr e = v.e(); switch (v.op()) { default: - std::stringstream ss; - ss << v.op(); - Util::ERROR("EvalOrdSet: SetUnaryOp %s not supported.", ss.str().c_str()); + Util::ERROR("EvalOrdSet: SetUnaryOp ", v.op(), " unsupported\n"); return LIB::OrdSet(); } } @@ -160,58 +158,56 @@ LIB::OrdSet EvalOrdSet::operator()(AST::SetBinOp v) const return l.difference(r); default: - std::stringstream ss; - ss << v.op(); - Util::ERROR("EvalOrdSet: SetBinOp %s not supported.", ss.str().c_str()); + Util::ERROR("EvalOrdSet: SetBinOp ", v.op(), " unsupported\n"); return LIB::OrdSet(); } } LIB::OrdSet EvalOrdSet::operator()(AST::LinearExp v) const { - Util::ERROR("EvalOrdSet: trying to evaluate a LinearExp"); + Util::ERROR("EvalOrdSet: trying to evaluate LinearExp ", v, "\n"); return LIB::OrdSet(); } LIB::OrdSet EvalOrdSet::operator()(AST::LExpBinOp v) const { - Util::ERROR("EvalOrdSet: trying to evaluate a LExpBinOp"); + Util::ERROR("EvalOrdSet: trying to evaluate LExpBinOp ", v, "\n"); return LIB::OrdSet(); } LIB::OrdSet EvalOrdSet::operator()(AST::MDLExp v) const { - Util::ERROR("EvalOrdSet: trying to evaluate a MDLExp"); + Util::ERROR("EvalOrdSet: trying to evaluate MDLExp ", v, "\n"); return LIB::OrdSet(); } LIB::OrdSet EvalOrdSet::operator()(AST::MDLExpBinOp v) const { - Util::ERROR("EvalOrdSet: trying to evaluate a MDLExpBinOp"); + Util::ERROR("EvalOrdSet: trying to evaluate MDLExpBinOp ", v, "\n"); return LIB::OrdSet(); } LIB::OrdSet EvalOrdSet::operator()(AST::LinearMap v) const { - Util::ERROR("EvalOrdSet: trying to evaluate a LinearMap"); + Util::ERROR("EvalOrdSet: trying to evaluate LinearMap ", v, "\n"); return LIB::OrdSet(); } LIB::OrdSet EvalOrdSet::operator()(AST::PWLMap v) const { - Util::ERROR("EvalOrdSet: trying to evaluate a PWLMap"); + Util::ERROR("EvalOrdSet: trying to evaluate PWLMap ", v, "\n"); return LIB::OrdSet(); } LIB::OrdSet EvalOrdSet::operator()(AST::SBG v) const { - Util::ERROR("EvalOrdSet: trying to evaluate a SBG"); + Util::ERROR("EvalOrdSet: trying to evaluate SBG ", v, "\n"); return LIB::OrdSet(); } LIB::OrdSet EvalOrdSet::operator()(AST::DSBG v) const { - Util::ERROR("EvalOrdSet: trying to evaluate a DSBG"); + Util::ERROR("EvalOrdSet: trying to evaluate DSBG ", v, "\n"); return LIB::OrdSet(); } diff --git a/eval/visitors/eval_rat.cpp b/eval/visitors/eval_rat.cpp index e23c710..8b4c456 100755 --- a/eval/visitors/eval_rat.cpp +++ b/eval/visitors/eval_rat.cpp @@ -26,11 +26,14 @@ namespace Eval { EvalRat::EvalRat() : env_() {} EvalRat::EvalRat(VarEnv env) : env_(env) {} -Util::RATIONAL EvalRat::operator()(AST::Natural v) const { return Util::RATIONAL(v, 1); } +Util::RATIONAL EvalRat::operator()(AST::Natural v) const +{ + return Util::RATIONAL(v, 1); +} Util::RATIONAL EvalRat::operator()(AST::MDNatural v) const { - Util::ERROR("EvalRat: trying to evaluate a MDNatural"); + Util::ERROR("EvalRat: trying to evaluate MDNatural ", v, "\n"); return Util::RATIONAL(0, 1); } @@ -64,12 +67,12 @@ Util::RATIONAL EvalRat::operator()(Util::VariableName v) const } else { - Util::ERROR("EvalRat: variable %s is not rational", v.c_str()); + Util::ERROR("EvalRat: variable ", v, " is not rational\n"); return Util::RATIONAL(0, 1); } } - Util::ERROR("EvalRat: variable %s not defined", v.c_str()); + Util::ERROR("EvalRat: variable ", v, " undefined\n"); return Util::RATIONAL(0, 1); } @@ -85,19 +88,16 @@ Util::RATIONAL EvalRat::operator()(AST::UnaryOp v) const return -result; default: - Util::ERROR("EvalExpression: UnaryOp %s not supported.", ss.str().c_str()); + Util::ERROR("EvalExpression: UnaryOp ", v.op(), " unsupported\n"); return 0; } - Util::ERROR("EvalExpression: UnaryOp %s not supported.", ss.str().c_str()); + Util::ERROR("EvalExpression: UnaryOp ", v.op(), " unsupported\n"); return 0; } Util::RATIONAL EvalRat::operator()(AST::BinOp v) const { - std::stringstream ss; - ss << v.op(); - Util::RATIONAL l = boost::apply_visitor(*this, v.left()); Util::RATIONAL r = boost::apply_visitor(*this, v.right()); switch (v.op()) { @@ -111,119 +111,119 @@ Util::RATIONAL EvalRat::operator()(AST::BinOp v) const return l * r; default: - Util::ERROR("EvalRat: BinOp %s not supported.", ss.str().c_str()); + Util::ERROR("EvalRat: BinOp ", v.op(), " unsupported\n"); return Util::RATIONAL(0, 1); } - Util::ERROR("EvalExpression: BinOp %s not supported.", ss.str().c_str()); + Util::ERROR("EvalExpression: BinOp ", v.op(), " unsupported\n"); return 0; } Util::RATIONAL EvalRat::operator()(AST::Call v) const { - Util::ERROR("EvalRat: trying to evaluate a Call"); + Util::ERROR("EvalRat: trying to evaluate Call ", v, "\n"); return Util::RATIONAL(0, 1); } Util::RATIONAL EvalRat::operator()(AST::Interval v) const { - Util::ERROR("EvalRat: trying to evaluate an Interval"); + Util::ERROR("EvalRat: trying to evaluate Interval ", v, "\n"); return Util::RATIONAL(0, 1); } Util::RATIONAL EvalRat::operator()(AST::InterUnaryOp v) const { - Util::ERROR("EvalRat: trying to evaluate an InterUnaryOp"); + Util::ERROR("EvalRat: trying to evaluate InterUnaryOp ", v, "\n"); return Util::RATIONAL(0, 1); } Util::RATIONAL EvalRat::operator()(AST::InterBinOp v) const { - Util::ERROR("EvalRat: trying to evaluate an InterBinOp"); + Util::ERROR("EvalRat: trying to evaluate InterBinOp ", v, "\n"); return Util::RATIONAL(0, 1); } Util::RATIONAL EvalRat::operator()(AST::MultiDimInter v) const { - Util::ERROR("EvalRat: trying to evaluate a MultiDimInter"); + Util::ERROR("EvalRat: trying to evaluate MultiDimInter ", v, "\n"); return Util::RATIONAL(0, 1); } Util::RATIONAL EvalRat::operator()(AST::MDInterUnaryOp v) const { - Util::ERROR("EvalRat: trying to evaluate a MDInterUnaryOp"); + Util::ERROR("EvalRat: trying to evaluate MDInterUnaryOp ", v, "\n"); return Util::RATIONAL(0, 1); } Util::RATIONAL EvalRat::operator()(AST::MDInterBinOp v) const { - Util::ERROR("EvalRat: trying to evaluate a MDInterBinOp"); + Util::ERROR("EvalRat: trying to evaluate MDInterBinOp ", v, "\n"); return Util::RATIONAL(0, 1); } Util::RATIONAL EvalRat::operator()(AST::Set v) const { - Util::ERROR("EvalRat: trying to evaluate a Set"); + Util::ERROR("EvalRat: trying to evaluate Set ", v, "\n"); return Util::RATIONAL(0, 1); } Util::RATIONAL EvalRat::operator()(AST::SetUnaryOp v) const { - Util::ERROR("EvalRat: trying to evaluate a SetUnaryOp"); + Util::ERROR("EvalRat: trying to evaluate SetUnaryOp ", v, "\n"); return Util::RATIONAL(0, 1); } Util::RATIONAL EvalRat::operator()(AST::SetBinOp v) const { - Util::ERROR("EvalRat: trying to evaluate a SetBinOp"); + Util::ERROR("EvalRat: trying to evaluate SetBinOp ", v, "\n"); return Util::RATIONAL(0, 1); } Util::RATIONAL EvalRat::operator()(AST::LinearExp v) const { - Util::ERROR("EvalRat: trying to evaluate a LinearExp"); + Util::ERROR("EvalRat: trying to evaluate LinearExp ", v, "\n"); return Util::RATIONAL(0, 1); } Util::RATIONAL EvalRat::operator()(AST::LExpBinOp v) const { - Util::ERROR("EvalRat: trying to evaluate a LExpBinOp"); + Util::ERROR("EvalRat: trying to evaluate LExpBinOp ", v, "\n"); return Util::RATIONAL(0, 1); } Util::RATIONAL EvalRat::operator()(AST::MDLExp v) const { - Util::ERROR("EvalRat: trying to evaluate a MDLExp"); + Util::ERROR("EvalRat: trying to evaluate MDLExp ", v, "\n"); return Util::RATIONAL(0, 1); } Util::RATIONAL EvalRat::operator()(AST::MDLExpBinOp v) const { - Util::ERROR("EvalRat: trying to evaluate a MDLExpBinOp"); + Util::ERROR("EvalRat: trying to evaluate MDLExpBinOp ", v, "\n"); return Util::RATIONAL(0, 1); } Util::RATIONAL EvalRat::operator()(AST::LinearMap v) const { - Util::ERROR("EvalRat: trying to evaluate a LinearMap"); + Util::ERROR("EvalRat: trying to evaluate LinearMap ", v, "\n"); return Util::RATIONAL(0, 1); } Util::RATIONAL EvalRat::operator()(AST::PWLMap v) const { - Util::ERROR("EvalRat: trying to evaluate a PWLMap"); + Util::ERROR("EvalRat: trying to evaluate PWLMap ", v, "\n"); return Util::RATIONAL(0, 1); } Util::RATIONAL EvalRat::operator()(AST::SBG v) const { - Util::ERROR("EvalRat: trying to evaluate a SBG"); + Util::ERROR("EvalRat: trying to evaluate SBG ", v, "\n"); return Util::RATIONAL(0, 1); } Util::RATIONAL EvalRat::operator()(AST::DSBG v) const { - Util::ERROR("EvalRat: trying to evaluate a DSBG"); + Util::ERROR("EvalRat: trying to evaluate DSBG ", v, "\n"); return Util::RATIONAL(0, 1); } diff --git a/eval/visitors/eval_unord_set.cpp b/eval/visitors/eval_unord_set.cpp index 8e34071..e664916 100755 --- a/eval/visitors/eval_unord_set.cpp +++ b/eval/visitors/eval_unord_set.cpp @@ -28,25 +28,25 @@ EvalUnordSet::EvalUnordSet(VarEnv env) : env_(env) {} LIB::UnordSet EvalUnordSet::operator()(AST::Natural v) const { - Util::ERROR("EvalUnordSet: trying to evaluate a Natural"); + Util::ERROR("EvalUnordSet: trying to evaluate Natural"); return LIB::UnordSet(); } LIB::UnordSet EvalUnordSet::operator()(AST::MDNatural v) const { - Util::ERROR("EvalUnordSet: trying to evaluate a MDNatural"); + Util::ERROR("EvalUnordSet: trying to evaluate MDNatural"); return LIB::UnordSet(); } LIB::UnordSet EvalUnordSet::operator()(AST::Rational v) const { - Util::ERROR("EvalUnordSet: trying to evaluate a Rational"); + Util::ERROR("EvalUnordSet: trying to evaluate Rational"); return LIB::UnordSet(); } LIB::UnordSet EvalUnordSet::operator()(AST::Boolean v) const { - Util::ERROR("EvalUnordSet: trying to evaluate a Boolean"); + Util::ERROR("EvalUnordSet: trying to evaluate Boolean"); return LIB::UnordSet(); } @@ -62,66 +62,66 @@ LIB::UnordSet EvalUnordSet::operator()(Util::VariableName v) const } else { - Util::ERROR("EvalUnordSet: variable %s is not a set", v.c_str()); + Util::ERROR("EvalUnordSet: variable", v, " is not a set\n"); return LIB::UnordSet(); } } - Util::ERROR("EvalUnordSet: variable %s not defined", v.c_str()); + Util::ERROR("EvalUnordSet: variable", v, " undefined\n"); return LIB::UnordSet(); } LIB::UnordSet EvalUnordSet::operator()(AST::UnaryOp v) const { - Util::ERROR("EvalUnordSet: trying to evaluate an arithmetic UnaryOp"); + Util::ERROR("EvalUnordSet: trying to evaluate arithmetic UnaryOp"); return LIB::UnordSet(); } LIB::UnordSet EvalUnordSet::operator()(AST::BinOp v) const { - Util::ERROR("EvalUnordSet: trying to evaluate an arithmetic BinOp"); + Util::ERROR("EvalUnordSet: trying to evaluate arithmetic BinOp"); return LIB::UnordSet(); } LIB::UnordSet EvalUnordSet::operator()(AST::Call v) const { - Util::ERROR("EvalUnordSet: trying to evaluate a Call"); + Util::ERROR("EvalUnordSet: trying to evaluate Call"); return LIB::UnordSet(); } LIB::UnordSet EvalUnordSet::operator()(AST::Interval v) const { - Util::ERROR("EvalUnordSet: trying to evaluate an Interval"); + Util::ERROR("EvalUnordSet: trying to evaluate Interval"); return LIB::UnordSet(); } LIB::UnordSet EvalUnordSet::operator()(AST::InterUnaryOp v) const { - Util::ERROR("EvalUnordSet: trying to evaluate an InterUnaryOp"); + Util::ERROR("EvalUnordSet: trying to evaluate InterUnaryOp"); return LIB::UnordSet(); } LIB::UnordSet EvalUnordSet::operator()(AST::InterBinOp v) const { - Util::ERROR("EvalUnordSet: trying to evaluate an InterBinOp"); + Util::ERROR("EvalUnordSet: trying to evaluate InterBinOp"); return LIB::UnordSet(); } LIB::UnordSet EvalUnordSet::operator()(AST::MultiDimInter v) const { - Util::ERROR("EvalUnordSet: trying to evaluate an MultiDimInter"); + Util::ERROR("EvalUnordSet: trying to evaluate MultiDimInter"); return LIB::UnordSet(); } LIB::UnordSet EvalUnordSet::operator()(AST::MDInterUnaryOp v) const { - Util::ERROR("EvalUnordSet: trying to evaluate an MDInterUnaryOp"); + Util::ERROR("EvalUnordSet: trying to evaluate MDInterUnaryOp"); return LIB::UnordSet(); } LIB::UnordSet EvalUnordSet::operator()(AST::MDInterBinOp v) const { - Util::ERROR("EvalUnordSet: trying to evaluate an MDInterBinOp"); + Util::ERROR("EvalUnordSet: trying to evaluate MDInterBinOp"); return LIB::UnordSet(); } @@ -141,9 +141,7 @@ LIB::UnordSet EvalUnordSet::operator()(AST::SetUnaryOp v) const AST::Expr e = v.e(); switch (v.op()) { default: - std::stringstream ss; - ss << v.op(); - Util::ERROR("EvalUnordSet: SetUnaryOp %s not supported.", ss.str().c_str()); + Util::ERROR("EvalUnordSet: SetUnaryOp ", v.op(), " unsupported\n"); return LIB::UnordSet(); } } @@ -160,58 +158,56 @@ LIB::UnordSet EvalUnordSet::operator()(AST::SetBinOp v) const return l.difference(r); default: - std::stringstream ss; - ss << v.op(); - Util::ERROR("EvalUnordSet: SetBinOp %s not supported.", ss.str().c_str()); + Util::ERROR("EvalUnordSet: SetBinOp ", v.op(), " unsupported\n"); return LIB::UnordSet(); } } LIB::UnordSet EvalUnordSet::operator()(AST::LinearExp v) const { - Util::ERROR("EvalUnordSet: trying to evaluate a LinearExp"); + Util::ERROR("EvalUnordSet: trying to evaluate LinearExp ", v, "\n"); return LIB::UnordSet(); } LIB::UnordSet EvalUnordSet::operator()(AST::LExpBinOp v) const { - Util::ERROR("EvalUnordSet: trying to evaluate a LExpBinOp"); + Util::ERROR("EvalUnordSet: trying to evaluate LExpBinOp ", v, "\n"); return LIB::UnordSet(); } LIB::UnordSet EvalUnordSet::operator()(AST::MDLExp v) const { - Util::ERROR("EvalUnordSet: trying to evaluate a MDLExp"); + Util::ERROR("EvalUnordSet: trying to evaluate MDLExp ", v, "\n"); return LIB::UnordSet(); } LIB::UnordSet EvalUnordSet::operator()(AST::MDLExpBinOp v) const { - Util::ERROR("EvalUnordSet: trying to evaluate a MDLExpBinOp"); + Util::ERROR("EvalUnordSet: trying to evaluate MDLExpBinOp ", v, "\n"); return LIB::UnordSet(); } LIB::UnordSet EvalUnordSet::operator()(AST::LinearMap v) const { - Util::ERROR("EvalUnordSet: trying to evaluate a LinearMap"); + Util::ERROR("EvalUnordSet: trying to evaluate LinearMap ", v, "\n"); return LIB::UnordSet(); } LIB::UnordSet EvalUnordSet::operator()(AST::PWLMap v) const { - Util::ERROR("EvalUnordSet: trying to evaluate a PWLMap"); + Util::ERROR("EvalUnordSet: trying to evaluate PWLMap ", v, "\n"); return LIB::UnordSet(); } LIB::UnordSet EvalUnordSet::operator()(AST::SBG v) const { - Util::ERROR("EvalUnordSet: trying to evaluate a SBG"); + Util::ERROR("EvalUnordSet: trying to evaluate SBG ", v, "\n"); return LIB::UnordSet(); } LIB::UnordSet EvalUnordSet::operator()(AST::DSBG v) const { - Util::ERROR("EvalUnordSet: trying to evaluate a DSBG"); + Util::ERROR("EvalUnordSet: trying to evaluate DSBG ", v, "\n"); return LIB::UnordSet(); } diff --git a/parser/Makefile.include b/parser/Makefile.include index 2fa5fd1..0474ebb 100755 --- a/parser/Makefile.include +++ b/parser/Makefile.include @@ -7,7 +7,6 @@ PARSER := bin/sbg-parser all: $(PARSER) PARSER_SRC := \ - $(UTIL_DIR)/debug.cpp \ $(UTIL_DIR)/defs.cpp \ $(PARSER_DIR)/main.cpp \ $(AST_DIR)/expr.cpp \ diff --git a/parser/expr.cpp b/parser/expr.cpp index 2035195..cf53424 100755 --- a/parser/expr.cpp +++ b/parser/expr.cpp @@ -444,8 +444,8 @@ ExprRule::ExprRule(Iterator &it) : | lexp_expr | arithmetic_expr | set_expr - | interval_expr - | mdi_expr; + | mdi_expr + | interval_expr; expr_list = expr[phx::push_back(qi::_val, qi::_1)] >> *(COMA >> expr)[phx::push_back(qi::_val, qi::_1)]; diff --git a/parser/main.cpp b/parser/main.cpp index 0783cdb..6f35eae 100755 --- a/parser/main.cpp +++ b/parser/main.cpp @@ -26,7 +26,7 @@ void parseProgramFromFile(std::string fname) { std::ifstream in(fname.c_str()); if (in.fail()) - SBG::Util::ERROR("Unable to open file"); + SBG::Util::ERROR("Unable to open file ", fname, "\n"); in.unsetf(std::ios::skipws); std::string str( @@ -74,7 +74,7 @@ void usage() void version() { - std::cout << "SBG library v3.0\n"; + std::cout << "SBG library v3.0.0" << std::endl; std::cout << "License GPLv3+: GNU GPL version 3 or later" << " \n"; std::cout << "This is free software: you are free to change and redistribute" @@ -118,7 +118,7 @@ int main(int argc, char** argv) if (!filename.empty()) parseProgramFromFile(filename); else - SBG::Util::ERROR("A filename should be provided"); + SBG::Util::ERROR("A filename should be provided\n"); return 0; } diff --git a/sbg/SBG.doxyfile b/sbg/SBG.doxyfile index 05d5609..e7ed08a 100755 --- a/sbg/SBG.doxyfile +++ b/sbg/SBG.doxyfile @@ -38,7 +38,7 @@ PROJECT_NAME = Set-Based Graph Library # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.0.0 +PROJECT_NUMBER = 3.0.0 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/sbg/interval.cpp b/sbg/interval.cpp index 676136c..a98451f 100755 --- a/sbg/interval.cpp +++ b/sbg/interval.cpp @@ -24,8 +24,8 @@ namespace SBG { namespace LIB { Interval::Interval() : begin_(1), step_(1), end_(0) {} -Interval::Interval(NAT x) : begin_(x), step_(1), end_(x) {} -Interval::Interval(NAT begin, NAT step, NAT end) +Interval::Interval(const NAT &x) : begin_(x), step_(1), end_(x) {} +Interval::Interval(const NAT &begin, const NAT &step, const NAT &end) : begin_(begin), step_(step), end_(end) { if (end >= begin) { @@ -43,9 +43,12 @@ Interval::Interval(NAT begin, NAT step, NAT end) } } -member_imp(Interval, NAT, begin); -member_imp(Interval, NAT, step); -member_imp(Interval, NAT, end); +NAT Interval::begin() const { return begin_; } +NAT &Interval::begin_ref() { return begin_; } +NAT Interval::step() const { return step_; } +NAT &Interval::step_ref() { return step_; } +NAT Interval::end() const { return end_; } +NAT &Interval::end_ref() { return end_; } // Operators ------------------------------------------------------------------- @@ -69,7 +72,7 @@ bool Interval::operator<(const Interval &other) const std::ostream &operator<<(std::ostream &out, const Interval &i) { out << "[" << Util::toStr(i.begin()); - if (i.step_ != 1) + if (i.step() != 1) out << ":" << Util::toStr(i.step()); out << ":" << Util::toStr(i.end()) << "]"; @@ -85,7 +88,7 @@ unsigned int Interval::cardinal() const bool Interval::isEmpty() const { return end_ < begin_; } -bool Interval::isMember(NAT x) const +bool Interval::isMember(const NAT &x) const { if (x < begin_ || x > end_) return false; @@ -128,7 +131,7 @@ Interval Interval::intersection(const Interval &other)const // Extra operations ------------------------------------------------------------ -Interval Interval::offset(Util::NAT off) const +Interval Interval::offset(const Util::NAT &off) const { Util::NAT new_b = begin_ + off, new_e = end_ + off; diff --git a/sbg/interval.hpp b/sbg/interval.hpp index 35da6ec..1b30c44 100755 --- a/sbg/interval.hpp +++ b/sbg/interval.hpp @@ -47,13 +47,16 @@ using MD_NAT = Util::MD_NAT; struct Interval { using MaybeInterval = std::optional; - member_class(NAT, begin); - member_class(NAT, step); - member_class(NAT, end); + NAT begin() const; + NAT &begin_ref(); + NAT step() const; + NAT &step_ref(); + NAT end() const; + NAT &end_ref(); Interval(); - Interval(NAT x); - Interval(NAT begin, NAT step, NAT end); + Interval(const NAT &x); + Interval(const NAT &begin, const NAT &step, const NAT &end); bool operator==(const Interval &i) const; bool operator!=(const Interval &i) const; @@ -64,15 +67,20 @@ struct Interval { */ unsigned int cardinal() const; bool isEmpty() const; - bool isMember(NAT x) const; + bool isMember(const NAT &x) const; Interval intersection(const Interval &i2) const; /** * @brief Extra operations. */ - Interval offset(Util::NAT off) const; + Interval offset(const Util::NAT &off) const; Interval least(const Interval &i2) const; MaybeInterval compact(const Interval &i2) const; + + private: + NAT begin_; + NAT step_; + NAT end_; }; std::ostream &operator<<(std::ostream &out, const Interval &i); diff --git a/sbg/map.cpp b/sbg/map.cpp index 88a3681..a759b3e 100755 --- a/sbg/map.cpp +++ b/sbg/map.cpp @@ -43,7 +43,7 @@ void compatible(Interval i, LExp le) , im_begin = min_rat * m + h; if (im_step.denominator() != 1 || im_begin.denominator() != 1) if (im_step.numerator() != 0 || im_begin.numerator() != 0) { - Util::ERROR("LIB::SBGMap::compatible: incompatible i/le"); + Util::ERROR("compatible: incompatible ", i, " with ", le, "\n"); return; } @@ -53,7 +53,7 @@ void compatible(Interval i, LExp le) void compatible(SetPiece mdi, Exp mdle) { Util::ERROR_UNLESS(mdi.arity() == mdle.arity() - , "LIB::SBGMap::compatible: dimensions don't match"); + , "compatible: dimensions of ", mdi, " and ", mdle, " don't match\n"); for (unsigned int j = 0; j < mdi.arity(); ++j) compatible(mdi[j], mdle[j]); @@ -104,9 +104,6 @@ SetPiece image(SetPiece mdi, Exp mdle) if (mdi.isEmpty()) return mdi; - Util::ERROR_UNLESS(mdi.arity() == mdle.arity() - , "LIB::SBGMap::image: dimensions don't match"); - SetPiece res; for (unsigned int j = 0; j < mdi.arity(); ++j) res.emplaceBack(image(mdi[j], mdle[j])); @@ -121,27 +118,22 @@ SBGMap::SBGMap() : dom_(Set()), exp_(Exp()) {} template SBGMap::SBGMap(Util::MD_NAT x, Exp exp) : dom_(), exp_() { SetPiece mdi(x); - compatible(mdi, exp); dom_ = Set(mdi); exp_ = exp; } template SBGMap::SBGMap(Interval i, LExp le) : dom_(), exp_() { - compatible(i, le); dom_ = Set(SetPiece(i)); exp_ = Exp(le); } template SBGMap::SBGMap(SetPiece mdi, Exp exp) : dom_(), exp_() { - compatible(mdi, exp); dom_ = Set(mdi); exp_ = exp; } template SBGMap::SBGMap(Set dom, Exp exp) : dom_(), exp_() { if (!dom.isEmpty()) { - for (const SetPiece &mdi : dom) - compatible(mdi, exp); dom_ = dom; exp_ = exp; } @@ -189,9 +181,17 @@ std::ostream &operator<<(std::ostream &out, const SBGMap &sbgmap) // SBGMap functions ------------------------------------------------------------ -// Function should be called on a non-empty sbgmap template -std::size_t SBGMap::arity() const { return dom_.begin()->arity(); } +std::size_t SBGMap::arity() const +{ + if (dom_.isEmpty()) + return 0; + + return dom_.begin()->arity(); +} + +template +bool SBGMap::isEmpty() const { return dom_.isEmpty(); } template SBGMap SBGMap::restrict(const Set &subdom) const diff --git a/sbg/map.hpp b/sbg/map.hpp index ebf845b..6b56b28 100755 --- a/sbg/map.hpp +++ b/sbg/map.hpp @@ -61,6 +61,7 @@ struct SBGMap { * @brief Traditional map operations. */ std::size_t arity() const; + bool isEmpty() const; SBGMap restrict(const Set &subdom) const; Set image() const; Set image(const Set &subdom) const; diff --git a/sbg/multidim_inter.cpp b/sbg/multidim_inter.cpp index d5c7696..7ba784e 100755 --- a/sbg/multidim_inter.cpp +++ b/sbg/multidim_inter.cpp @@ -24,23 +24,20 @@ namespace SBG { namespace LIB { MultiDimInter::MultiDimInter() : intervals_() {} -MultiDimInter::MultiDimInter(MD_NAT x) : intervals_() { - Util::ERROR_UNLESS(x.arity() > 0, "LIB::MDI1: empty not allowed"); +MultiDimInter::MultiDimInter(const MD_NAT &x) : intervals_() { for (NAT xi : x) intervals_.emplace_back(Interval(xi, 1, xi)); } -MultiDimInter::MultiDimInter(Interval i) : intervals_() +MultiDimInter::MultiDimInter(const Interval &i) : intervals_() { - Util::ERROR_UNLESS(!i.isEmpty(), "LIB::MDI2: empty not allowed"); intervals_.emplace_back(i); } -MultiDimInter::MultiDimInter(unsigned int nmbr_copies - , Interval i) : intervals_() { - Util::ERROR_UNLESS(!i.isEmpty(), "LIB::MDI3: empty not allowed"); +MultiDimInter::MultiDimInter(const unsigned int &nmbr_copies + , const Interval &i) : intervals_() { for (unsigned int j = 0; j < nmbr_copies; ++j) intervals_.emplace_back(i); } -MultiDimInter::MultiDimInter(InterVector iv) : intervals_(iv) {} +MultiDimInter::MultiDimInter(const InterVector &iv) : intervals_(iv) {} member_imp(MultiDimInter, InterVector, intervals); @@ -66,37 +63,26 @@ void MultiDimInter::emplaceBack(Interval i) Interval &MultiDimInter::operator[](std::size_t n) { - Util::ERROR_UNLESS(n < intervals_.size() && intervals_.size() > 0 - , "LIB::MDI::operator[]: invalid n"); return intervals_[n]; } const Interval &MultiDimInter::operator[](std::size_t n) const { - Util::ERROR_UNLESS(n < intervals_.size() && intervals_.size() > 0 - , "LIB::MDI::operator[]: invalid n"); return intervals_[n]; } bool MultiDimInter::operator==(const MultiDimInter &other) const { - Util::ERROR_UNLESS(arity() == other.arity() - , "LIB::MDI::operator==: dimensions don't match"); return intervals_ == other.intervals_; } bool MultiDimInter::operator!=(const MultiDimInter &other) const { - Util::ERROR_UNLESS(arity() == other.arity() - , "LIB::MDI::operator!=: dimensions don't match"); return !(*this == other); } bool MultiDimInter::operator<(const MultiDimInter &other) const { - Util::ERROR_UNLESS(arity() == other.arity() - , "LIB::MDI::operator<: dimensions don't match"); - if (other.isEmpty()) return false; @@ -135,24 +121,8 @@ unsigned int MultiDimInter::cardinal() const bool MultiDimInter::isEmpty() const { return intervals_.empty(); } -bool MultiDimInter::isMember(const MD_NAT &x) const -{ - Util::ERROR_UNLESS(x.arity() == arity() - , "LIB::MDI::isMember: dimensions don't match"); - - if (isEmpty()) - return false; - - for (unsigned int j = 0; j < arity(); ++j) - if (!operator[](j).isMember(x[j])) - return false; - - return true; -} Util::MD_NAT MultiDimInter::minElem() const { - Util::ERROR_UNLESS(!isEmpty(), "LIB::MDI::minElem: shouldn't be empty"); - MD_NAT res; for (const Interval &i : intervals_) @@ -163,8 +133,6 @@ Util::MD_NAT MultiDimInter::minElem() const Util::MD_NAT MultiDimInter::maxElem() const { - Util::ERROR_UNLESS(!isEmpty(), "LIB::MDI::maxElem: shouldn't be empty"); - MD_NAT res; for (const Interval &i : intervals_) @@ -175,9 +143,6 @@ Util::MD_NAT MultiDimInter::maxElem() const MultiDimInter MultiDimInter::intersection(const MultiDimInter &other) const { - Util::ERROR_UNLESS(arity() == other.arity() - , "LIB::MDI::intersection: dimensions don't match"); - if (isEmpty() || other.isEmpty()) return MultiDimInter(); @@ -199,9 +164,6 @@ MultiDimInter MultiDimInter::intersection(const MultiDimInter &other) const MultiDimInter MultiDimInter::offset(const MD_NAT &off) const { - Util::ERROR_UNLESS(off.arity() == arity() - , "LIB::MDI::offset: dimensions don't match"); - MultiDimInter res; for (unsigned int j = 0; j < arity(); ++j) diff --git a/sbg/multidim_inter.hpp b/sbg/multidim_inter.hpp index 45cc3d2..35e5561 100755 --- a/sbg/multidim_inter.hpp +++ b/sbg/multidim_inter.hpp @@ -42,10 +42,10 @@ struct MultiDimInter { member_class(InterVector, intervals); MultiDimInter(); - MultiDimInter(MD_NAT x); - MultiDimInter(Interval i); - MultiDimInter(unsigned int nmbr_copies, Interval i); - MultiDimInter(InterVector iv); + MultiDimInter(const MD_NAT &x); + MultiDimInter(const Interval &i); + MultiDimInter(const unsigned int &nmbr_copies, const Interval &i); + MultiDimInter(const InterVector &iv); typedef InterVectorIt iterator; typedef InterVectorConstIt const_iterator; @@ -67,7 +67,6 @@ struct MultiDimInter { std::size_t arity() const; unsigned int cardinal() const; bool isEmpty() const; - bool isMember(const MD_NAT &x) const; // Useful? Util::MD_NAT minElem() const; Util::MD_NAT maxElem() const; MultiDimInter intersection(const MultiDimInter &other) const; diff --git a/sbg/multidim_lexp.cpp b/sbg/multidim_lexp.cpp index b45d536..12dd899 100755 --- a/sbg/multidim_lexp.cpp +++ b/sbg/multidim_lexp.cpp @@ -26,16 +26,12 @@ namespace LIB { MDLExp::MDLExp() : exps_() {} MDLExp::MDLExp(Util::MD_NAT x) { - Util::ERROR_UNLESS(x.arity() > 0, "LIB::MDLE1: empty not allowed"); - for (Util::NAT xi : x) exps_.emplace_back(LExp(0, Util::RATIONAL(xi))); } MDLExp::MDLExp(LExp le) : exps_() { exps_.emplace_back(le); } MDLExp::MDLExp(unsigned int nmbr_copies, LExp le) : exps_() { - Util::ERROR_UNLESS(nmbr_copies > 0, "LIB::MDLE2: empty not allowed"); - for (unsigned int j = 0; j < nmbr_copies; ++j) exps_.emplace_back(le); } @@ -100,9 +96,6 @@ std::size_t MDLExp::arity() const { return exps_.size(); } MDLExp MDLExp::composition(const MDLExp &other) const { - Util::ERROR_UNLESS(arity() == other.arity() - , "LIB::MDLE::composition: dimensions don't match"); - MDLExp res; for (unsigned int j = 0; j < arity(); ++j) diff --git a/sbg/ord_pw_mdinter.cpp b/sbg/ord_pw_mdinter.cpp index 36e49ca..9fe0a57 100755 --- a/sbg/ord_pw_mdinter.cpp +++ b/sbg/ord_pw_mdinter.cpp @@ -57,14 +57,11 @@ OrdPWMDInter::OrdPWMDInter(Interval i) : pieces_() { pieces_.insert(SetPiece(i)); } OrdPWMDInter::OrdPWMDInter(SetPiece mdi) : pieces_() { - Util::ERROR_UNLESS(mdi.isUnidim(), "LIB::Ord2: should be uni-dimensional"); - if (!mdi.isEmpty()) pieces_.insert(mdi); } OrdPWMDInter::OrdPWMDInter(MDInterOrdSet container) : pieces_() { for (const SetPiece &mdi : container) { - Util::ERROR_UNLESS(mdi.isUnidim(), "LIB::Ord3:: should be uni-dimensional"); if (!mdi.isEmpty()) pieces_.insert(mdi); } @@ -137,15 +134,11 @@ bool OrdPWMDInter::isEmpty() const { return pieces_.empty(); } Util::MD_NAT OrdPWMDInter::minElem() const { - Util::ERROR_UNLESS(!isEmpty(), "LIB::Ord::minElem: shouldn't be empty"); - return begin()->minElem(); } Util::MD_NAT OrdPWMDInter::maxElem() const { - Util::ERROR_UNLESS(!isEmpty(), "LIB::Ord::maxElem: shouldn't be empty"); - auto it = end(); --it; return it->maxElem(); @@ -299,7 +292,8 @@ OrdPWMDInter OrdPWMDInter::difference(const OrdPWMDInter &other) const std::size_t OrdPWMDInter::arity() const { - Util::ERROR_UNLESS(!isEmpty(), "LIB::Ord::arity: set is empty"); + if (isEmpty()) + return 0; return begin()->arity(); } @@ -350,7 +344,7 @@ OrdPWMDInter OrdPWMDInter::compact() const if (next_compacted.isEmpty()) { auto ith = new_ith.compact(*next_it); if (ith) { - new_ith = ith.value(); + new_ith = std::move(ith.value()); compacted.emplaceBack(*next_it); } } diff --git a/sbg/pw_map.cpp b/sbg/pw_map.cpp index e3d0bd5..d70d626 100644 --- a/sbg/pw_map.cpp +++ b/sbg/pw_map.cpp @@ -55,13 +55,13 @@ template PWMap::PWMap(Set s) : maps_() { if (!s.isEmpty()) { SBGMap map(s, Exp(s.begin()->arity(), LExp())); - maps_.emplace_back(std::move(map)); + maps_.emplace_back(map); } } template PWMap::PWMap(Map map) : maps_() { if (!map.dom().isEmpty()) - maps_.emplace_back(std::move(map)); + maps_.emplace_back(map); } template PWMap::PWMap(MS maps) : maps_(maps) {} @@ -89,13 +89,13 @@ std::size_t PWMap::size() const { return maps_.size(); } template void PWMap::emplace(Map map) { if (!map.dom().isEmpty()) - maps_.emplace_back(std::move(map)); + maps_.emplace_back(map); } template void PWMap::emplaceBack(Map map) { if (!map.dom().isEmpty()) - maps_.emplace_back(std::move(map)); + maps_.emplace_back(map); } template @@ -253,11 +253,11 @@ std::ostream &operator<<(std::ostream &out, const PWMap &pw) // PWMap functions ------------------------------------------------------------- -// Function should be called on a non-empty pw template std::size_t PWMap::arity() const { - Util::ERROR_UNLESS(!isEmpty(), "LIB::PWMap::arity: empty not allowed"); + if (isEmpty()) + return 0; return begin()->dom().begin()->arity(); } @@ -691,7 +691,7 @@ PWMap PWMap::compact() const if (next_compacted.isEmpty()) { auto ith = new_ith.compact(*next_it); if (ith) { - new_ith = ith.value(); + new_ith = std::move(ith.value()); compacted = compacted.cup(next_it->dom()); } } diff --git a/sbg/sbg.cpp b/sbg/sbg.cpp index 2e369af..15f3731 100755 --- a/sbg/sbg.cpp +++ b/sbg/sbg.cpp @@ -32,7 +32,7 @@ template SBGraph::SBGraph(Set V, PW Vmap, PW map1, PW map2, PW Emap) : V_(V), Vmap_(Vmap), E_(map1.dom().intersection(map2.dom())) , map1_(map1), map2_(map2), Emap_(Emap), subE_map_() { - unsigned int j = 0; + unsigned int j = 1; for (const SBGMap &sbgmap : Emap) { Set dom = sbgmap.dom(); for (const SetPiece &mdi : dom) { @@ -56,11 +56,11 @@ std::ostream &operator<<(std::ostream &out, const SBGraph &g) { out << "V = " << g.V() << ";\n"; out << "Vmap = " << g.Vmap() << ";\n\n"; - out << "E = " << g.E() << "\n"; - out << "map1 = " << g.map1() << "\n"; - out << "map2 = " << g.map2() << "\n"; - out << "Emap = " << g.Emap() << "\n"; - out << "sub_Emap = " << g.subE_map() << "\n"; + out << "E = " << g.E() << ";\n"; + out << "map1 = " << g.map1() << ";\n"; + out << "map2 = " << g.map2() << ";\n"; + out << "Emap = " << g.Emap() << ";\n"; + out << "sub_Emap = " << g.subE_map() << ";\n"; return out; } @@ -84,15 +84,9 @@ SBGraph SBGraph::addSV(const Set &vertices) const return res; } - else - Util::ERROR("LIB::SBG::addSV: vertices should be non-empty and disjoint from current vertices"); - return SBGraph(); } -template -unsigned int SBGraph::nmbrSV() const { return Vmap_.image().size(); } - template SBGraph SBGraph::addSE(const PW &pw1, const PW &pw2) const { @@ -117,12 +111,8 @@ SBGraph SBGraph::addSE(const PW &pw1, const PW &pw2) const return res; } - - else Util::ERROR("LIB::SBG::addSE: edges should be non-empty and disjoint from current vertices"); } - else Util::ERROR("LIB::SBG::addSE: maps domains should coincide"); - return SBGraph(); } @@ -180,7 +170,7 @@ template DSBGraph::DSBGraph(Set V, PW Vmap, PW mapB, PW mapD, PW Emap) : V_(V), Vmap_(Vmap), E_(mapB.dom().intersection(mapD.dom())) , mapB_(mapB), mapD_(mapD), Emap_(Emap), subE_map_() { - unsigned int j = 0; + unsigned int j = 1; for (const SBGMap &sbgmap : Emap) { Set dom = sbgmap.dom(); for (const SetPiece &mdi : dom) { @@ -204,11 +194,11 @@ std::ostream &operator<<(std::ostream &out, const DSBGraph &g) { out << "V = " << g.V() << ";\n"; out << "Vmap = " << g.Vmap() << ";\n\n"; - out << "E = " << g.E() << "\n"; - out << "mapB = " << g.mapB() << "\n"; - out << "mapD = " << g.mapD() << "\n"; - out << "Emap = " << g.Emap() << "\n"; - out << "subE_map = " << g.subE_map() << "\n"; + out << "E = " << g.E() << ";\n"; + out << "mapB = " << g.mapB() << ";\n"; + out << "mapD = " << g.mapD() << ";\n"; + out << "Emap = " << g.Emap() << ";\n"; + out << "subE_map = " << g.subE_map() << ";\n"; return out; } @@ -232,14 +222,9 @@ DSBGraph DSBGraph::addSV(const Set &vertices) const return res; } - else Util::ERROR("LIB::SBG::addSV: vertices should be non-empty and disjoint from current vertices"); - return DSBGraph(); } -template -unsigned int DSBGraph::nmbrSV() const { return Vmap_.image().size(); } - template DSBGraph DSBGraph::addSE(const PW &pw1, const PW &pw2) const { @@ -264,12 +249,8 @@ DSBGraph DSBGraph::addSE(const PW &pw1, const PW &pw2) const return res; } - - else Util::ERROR("LIB::SBG::addSE: edges should be non-empty and disjoint from current vertices"); } - else Util::ERROR("LIB::SBG::addSE: maps domains should coincide"); - return DSBGraph(); } diff --git a/sbg/sbg.hpp b/sbg/sbg.hpp index bfbcde3..b8377a1 100755 --- a/sbg/sbg.hpp +++ b/sbg/sbg.hpp @@ -51,7 +51,6 @@ struct SBGraph { SBGraph(Set V, PW Vmap, PW map1, PW map2, PW Emap); SBGraph addSV(const Set &vertices) const; - unsigned int nmbrSV() const; SBGraph addSE(const PW &pw1, const PW &pw2) const; SBGraph copy(unsigned int times) const; }; @@ -82,7 +81,6 @@ struct DSBGraph { DSBGraph(Set V, PW Vmap, PW mapB, PW mapD, PW Emap); DSBGraph addSV(const Set &vertices) const; - unsigned int nmbrSV() const; DSBGraph addSE(const PW &pw1, const PW &pw2) const; DSBGraph eraseVertices(Set vs) const; diff --git a/sbg/sbg_algorithms.cpp b/sbg/sbg_algorithms.cpp index 451bd0b..ec6e37c 100644 --- a/sbg/sbg_algorithms.cpp +++ b/sbg/sbg_algorithms.cpp @@ -462,7 +462,7 @@ SBGSCC::SBGSCC() : dsbg_(), V_(), Vmap_(), E_(), Emap_(), Ediff_(), mapB_() template SBGSCC::SBGSCC(DSBGraph dsbg, bool debug) : dsbg_(dsbg), debug_(debug), Ediff_() { - DSBGraph dg = partitionSE(dsbg); + DSBGraph dg = dsbg; dsbg_ = dg; V_ = dg.V(); @@ -496,7 +496,7 @@ template PWMap SBGSCC::sccMinReach(DSBGraph dg) const { if (debug()) - Util::SBG_LOG << "Min reach graph:\n" << dg << "\n\n"; + std::cout << "Min reach graph:\n" << dg << "\n\n"; Set V = dg.V(), E = dg.E(); PW mapB = dg.mapB(), mapD = dg.mapD(), subE_map = dg.subE_map(); @@ -507,6 +507,7 @@ PWMap SBGSCC::sccMinReach(DSBGraph dg) const if (E.isEmpty()) return rmap; + Set Vc; do { old_rmap = rmap; @@ -514,72 +515,86 @@ PWMap SBGSCC::sccMinReach(DSBGraph dg) const PW new_rmap = mapB.minAdjMap(ermapD); rmap = rmap.minMap(new_rmap).combine(rmap); + if (debug()) + Util::SBG_LOG << "rmap before rec: " << rmap << "\n\n"; Set positive(SetPiece(copies, Interval(1, 1, Util::Inf))); PW rec_rmap; - Set Vc = V.difference(old_rmap.equalImage(rmap)); - for (const Map &subv : dg.Vmap()) { - Set vs = subv.dom(); - if (!vs.isEmpty()) { - // Vertices in the set-vertex that share its rep with other vertex - // in the set-vertex - Set VR = rmap.restrict(vs).sharedImage(); - // There is a recursive vertex that changed its rep in the last step - // (to avoid computing again an already found recursion) - if (!VR.intersection(Vc).isEmpty()) { - // Edges with both endings in VR (path to a minimum rep) - Set ERB = mapB.preImage(VR), ERD = mapD.preImage(VR); - Set ER = ERB.intersection(ERD); - - // Distance map - PW dmap; - Set ith = rmap.image(VR), dom_VR; - //Set visited, dom_vs; - Util::NAT dist = 0; - // Calculate distance for vertices in same_rep that reach reps - for (; dg.Vmap().restrict(dom_VR).sharedImage().isEmpty();) { - Exp exp(Util::MD_NAT(copies, dist)); - Set dom = ith.difference(dmap.dom()); - dmap.emplaceBack(Map(ith.difference(dmap.dom()), exp)); - dom_VR = dmap.dom().intersection(VR); - // Update ith to vertices that have outgoing edges entering ith - ith = mapB.image(mapD.preImage(ith)); - ++dist; - } - dmap = dmap.restrict(VR); - PW dmapB = dmap.composition(mapB), dmapD = dmap.composition(mapD); - // Get edges where the end is closer to the rep that the beginning - Set not_cycle_edges = (dmapB - dmapD).preImage(positive); - ER = ER.intersection(not_cycle_edges); - - // Extend to subset-edge - Set ER_plus = subE_map.preImage(subE_map.image(ER)); - PW auxB = mapB.restrict(ER_plus), auxD = mapD.restrict(ER_plus); - // Calculate a succesor - Set same_SV = dg.Vmap().preImage(dg.Vmap().image(VR)); - PW rmap_plus = auxB.minAdjMap(auxD).restrict(same_SV); - - // Update rmap for recursion, and leave the rest unchanged - rec_rmap = rmap_plus.combine(rec_rmap).compact(); - - if (debug()) { - Util::SBG_LOG << "VR: " << VR << "\n"; - Util::SBG_LOG << "ER: " << ER << "\n"; - Util::SBG_LOG << "dmap: " << dmap << "\n"; - Util::SBG_LOG << "not_cycle_edges: " << not_cycle_edges << "\n"; - Util::SBG_LOG << "ER_plus: " << ER_plus << "\n"; - Util::SBG_LOG << "rmap_plus: " << rmap_plus << "\n"; + Vc = V.difference(old_rmap.equalImage(rmap)); + if (!Vc.isEmpty()) { + for (const Map &subv : dg.Vmap()) { + Set vs = subv.dom(); + if (!vs.intersection(Vc).isEmpty()) { + // If the mrv is in the same SV, the algorithm would detect a false + // recursion, i.e. if we have a cycle 1 -> 2 -> ... -> 10 -> 1, + // where SV = [1:10], then it detects a recursion when mrv(10) + // becomes "1" (false recursion). So we take self mrvs out. + auto other_rep = rmap.filterMap([](const SBGMap &sbgmap) { + return notEqId(sbgmap); + }).dom(); + // Vertices in the set-vertex that share its rep with other vertex + // in the set-vertex + Set VR = rmap.restrict(vs.intersection(other_rep)).sharedImage(); + // There is a recursive vertex that changed its rep in the last step + // (to avoid computing again an already found recursion) + if (!VR.intersection(Vc).isEmpty()) { + // Vertices that reach the shared representative + Set repV = rmap.preImage(rmap.image(VR)); + Set end = VR.difference(Vc); + + // Edges with both endings in VR (path to a minimum rep) + Set ERB = mapB.preImage(repV), ERD = mapD.preImage(repV); + Set ER = ERB.intersection(ERD); + if (!end.isEmpty() && !ER.isEmpty()) { + // Distance map + PW dmap; + Set ith = end; + Util::NAT dist = 0; + // Calculate distance for vertices in same_rep that reach reps + for (; dg.Vmap().restrict(dmap.dom()).sharedImage().isEmpty();) { + Set dom = ith.difference(dmap.dom()); + Exp exp(Util::MD_NAT(copies, dist)); + dmap.emplaceBack(Map(dom, exp)); + // Update ith to vertices that have outgoing edges entering ith + ith = mapB.image(mapD.preImage(ith)); + ++dist; + } + PW dmapB = dmap.composition(mapB), dmapD = dmap.composition(mapD); + // Get edges where the end is closer to the rep than the beginning + Set not_cycle_edges = (dmapB - dmapD).preImage(positive); + ER = ER.intersection(not_cycle_edges); + + // Extend to subset-edge + Set ER_plus = subE_map.preImage(subE_map.image(ER)); + // Calculate a succesor + PW auxB = mapB.restrict(ER_plus), auxD = mapD.restrict(ER_plus); + PW smap_plus = rmap.restrict(VR); + smap_plus = smap_plus.combine(auxB.minAdjMap(auxD)); + + // Update rmap for recursion, and leave the rest unchanged + rec_rmap = smap_plus.combine(rec_rmap).compact(); + + if (debug()) { + Util::SBG_LOG << "VR: " << VR << "\n"; + Util::SBG_LOG << "repV: " << repV << "\n"; + Util::SBG_LOG << "ER: " << ER << "\n"; + Util::SBG_LOG << "dmap: " << dmap << "\n"; + Util::SBG_LOG << "not_cycle_edges: " << not_cycle_edges << "\n"; + Util::SBG_LOG << "ER_plus: " << ER_plus << "\n"; + Util::SBG_LOG << "smap_plus: " << smap_plus << "\n"; + Util::SBG_LOG << "rec_rmap: " << rec_rmap << "\n\n"; + } + } } } } - } - rmap = rec_rmap.combine(rmap).compact(); - if (debug()) - Util::SBG_LOG << "rmap rec: " << rmap << "\n\n"; - - if (rmap != old_rmap) + rmap = rec_rmap.combine(rmap).compact(); rmap = rmap.mapInf(); - } while (rmap != old_rmap); + + if (debug()) + Util::SBG_LOG << "rmap after rec: " << rmap << "\n\n"; + } + } while (!Vc.isEmpty()); return rmap; } @@ -594,19 +609,21 @@ PWMap SBGSCC::sccStep() DSBGraph aux_dsbg( V(), Vmap() - , mapB().restrict(E()), mapD().restrict(E()), Emap().restrict(E()) + , mapB().restrict(E()), mapD().restrict(E()), Emap().restrict(E()).compact() ); PW new_rmap = sccMinReach(aux_dsbg); if (debug()) - Util::SBG_LOG << "SCC new_rmap: " << new_rmap << "\n\n"; + Util::SBG_LOG << "SCC new_rmap: " << new_rmap << "\n"; PW rmap_B = new_rmap.composition(mapB()); PW rmap_D = new_rmap.composition(mapD()); Set Esame = rmap_B.equalImage(rmap_D); // Edges in the same SCC // Leave edges in the same SCC - set_E(Esame); set_Ediff(E().difference(Esame)); + set_E(Esame); + if (debug()) + Util::SBG_LOG << "SCC erased edges: " << Ediff() << "\n\n"; // Swap directions PW aux_B = mapB(); @@ -623,12 +640,11 @@ PWMap SBGSCC::calculate() Util::SBG_LOG << "SCC dsbg: \n" << dsbg() << "\n\n"; auto begin = std::chrono::high_resolution_clock::now(); + PW rmap = sccStep(); do { - sccStep(); - sccStep(); + rmap = sccStep(); } while (Ediff() != Set()); - PW rmap = sccStep().compact(); - set_rmap(rmap); + set_rmap(rmap.compact()); auto end = std::chrono::high_resolution_clock::now(); auto total = std::chrono::duration_cast( @@ -637,7 +653,7 @@ PWMap SBGSCC::calculate() Util::SBG_LOG << "Total SCC exec time: " << total.count() << " [μs]\n\n"; if (debug()) - Util::SBG_LOG << "SCC result: " << rmap << "\n\n"; + Util::SBG_LOG << "SCC result: " << rmap.compact() << "\n\n"; return rmap; } @@ -968,33 +984,8 @@ DSBGraph buildSCCFromMatching(const SBGMatching &match) PWMap mapD = matchedU_inv.composition(unmatchedU); mapD = mapD.compact(); - unsigned int j = 1, dims = Vmap.arity(); - PWMap Emap; - for (const SBGMap &map1 : Vmap) { - Set edges1 = mapB.preImage(map1.dom()); - for (const SBGMap &map2 : Vmap) { - Set edges2 = mapD.preImage(map2.dom()); - Set dom = edges1.intersection(edges2); - Exp exp(Util::MD_NAT(dims, j)); - - Emap.emplaceBack(SBGMap(dom.compact(), exp)); - ++j; - } - } - - PWMap subE_map; - j = 1; - for (const SBGMap &mapb : mapB) { - for (const SBGMap &mapd : mapD) { - Set ith = mapb.dom().intersection(mapd.dom()); - Exp exp(Util::MD_NAT(dims, j)); - subE_map.emplaceBack(SBGMap(ith.compact(), exp)); - ++j; - } - } - + PWMap Emap = match.Emap().restrict(unmatched_edges); DSBGraph res(V, Vmap, mapB, mapD, Emap); - res.set_subE_map(subE_map); auto end = std::chrono::high_resolution_clock::now(); auto total = std::chrono::duration_cast( end - start diff --git a/sbg/unord_pw_mdinter.cpp b/sbg/unord_pw_mdinter.cpp index 381bbd6..d058031 100755 --- a/sbg/unord_pw_mdinter.cpp +++ b/sbg/unord_pw_mdinter.cpp @@ -136,9 +136,6 @@ bool UnordPWMDInter::isEmpty() const { return pieces_.empty(); } Util::MD_NAT UnordPWMDInter::minElem() const { - Util::ERROR_UNLESS(!isEmpty() - , "LIB::Unord::minElem: shouldn't be empty"); - MD_NAT res = begin()->minElem(); for (const SetPiece &mdi : pieces_) { Util::MD_NAT ith = mdi.minElem(); @@ -151,9 +148,6 @@ Util::MD_NAT UnordPWMDInter::minElem() const Util::MD_NAT UnordPWMDInter::maxElem() const { - Util::ERROR_UNLESS(!isEmpty() - , "LIB::Unord::maxElem: shouldn't be empty"); - MD_NAT res = begin()->maxElem(); for (const SetPiece &mdi : pieces_) { Util::MD_NAT ith = mdi.maxElem(); @@ -170,9 +164,6 @@ UnordPWMDInter UnordPWMDInter::intersection(const UnordPWMDInter &other) const if (isEmpty() || other.isEmpty()) return UnordPWMDInter(); - Util::ERROR_UNLESS(arity() == other.arity() - , "LIB::Unord::intersection: dimensions don't match"); - if (pieces_ == other.pieces_) return *this; @@ -199,9 +190,6 @@ UnordPWMDInter UnordPWMDInter::cup(const UnordPWMDInter &other) const if (other.isEmpty()) return *this; - Util::ERROR_UNLESS(arity() == other.arity() - , "LIB::Unord::cup: dimensions don't match"); - if (pieces_ == other.pieces_) return *this; @@ -317,9 +305,6 @@ UnordPWMDInter UnordPWMDInter::difference(const UnordPWMDInter &other) const if (other.isEmpty()) return *this; - Util::ERROR_UNLESS(arity() == other.arity() - , "LIB::Unord::difference: dimensions don't match"); - return intersection(other.complement()); } @@ -327,7 +312,8 @@ UnordPWMDInter UnordPWMDInter::difference(const UnordPWMDInter &other) const std::size_t UnordPWMDInter::arity() const { - Util::ERROR_UNLESS(!isEmpty(), "LIB::Unord::arity: set is empty"); + if (isEmpty()) + return 0; return begin()->arity(); } @@ -342,9 +328,6 @@ UnordPWMDInter UnordPWMDInter::concatenation(const UnordPWMDInter &other) const if (other.isEmpty()) return *this; - Util::ERROR_UNLESS(arity() == other.arity() - , "LIB::Unord::concatenation: dimensions don't match"); - for (const SetPiece &mdi : pieces_) res.emplaceBack(mdi); for (const SetPiece &mdi : other.pieces_) @@ -371,9 +354,6 @@ UnordPWMDInter UnordPWMDInter::offset(const Util::MD_NAT &off) const if (isEmpty()) return res; - Util::ERROR_UNLESS(off.arity() == arity() - , "LIB::Unord::offset: dimensions don't match"); - for (const SetPiece &mdi : pieces_) res.emplace(mdi.offset(off)); diff --git a/test/arithmetic.test b/test/arithmetic.test index 214e4ea..c3b9071 100755 --- a/test/arithmetic.test +++ b/test/arithmetic.test @@ -4,7 +4,6 @@ N = r(100, 1)-r(200,1) -(2, 5) 2+3 r(1, 2) 2*10+3 diff --git a/test/cc1.test b/test/cc1.test deleted file mode 100644 index b0d4859..0000000 --- a/test/cc1.test +++ /dev/null @@ -1,28 +0,0 @@ -N = 1000 -N1 = N -N2 = N1+N -N3 = N2+1 -N4 = N3+1 -N5 = N4+N -N6 = N5+N -N7 = N6+1 -N8 = N7+1 - -o1 = N8 -o2 = N7 -o3 = 2*N-2 -o4 = N+2 -o5 = 3*N+2 - -o6 = N5+1 -o7 = N4 -o8 = 3*N-1 -o10 = N4 - -CC( - V %= {[1:1:N1], [N1+1:1:N2], [N2+1:1:N3], [N3+1:1:N4], [N4+1:1:N5], [N5+1:1:N6], [N6+1:1:N7], [N7+1:1:N8]}; - Vmap %= <<>>; - map1 %= <<{[1:1:1]} -> 0*x+o1, {[3:1:3]} -> 0*x+o2, {[5:1:N1+3]} -> 1*x+o3, {[N4+1:1:N5]} -> 1*x-o4, {[N5+1:1:N6]} -> 1*x-o5>>; - map2 %= <<{[1:1:1]} -> 0*x+o6, {[3:1:3]} -> 0*x+o7, {[5:1:N1+3]} -> 1*x+o8, {[N4+1:1:N5]} -> 1*x+0, {[N5+1:1:N6]} -> 0*x+o10>>; - Emap %= <<>>; -) diff --git a/test/cc2.test b/test/cc2.test deleted file mode 100644 index 95487bc..0000000 --- a/test/cc2.test +++ /dev/null @@ -1,31 +0,0 @@ -N = 1000 -N1 = N -N2 = N1+N -N3 = N2+1 -N4 = N3+1 -N5 = N4+N -N6 = N5+N -N7 = N6+1 -N8 = N7+1 -N9 = N8+N-1 - -o1 = N8 -o2 = N7 -o3 = 2*N-2 -o4 = N+2 -o5 = 3*N+2 -o11 = 4*N+4 - -o6 = N5+1 -o7 = N4 -o8 = 3*N-1 -o10 = N4 -o12 = 4*N+3 - -CC( - V %= {[1:1:N1], [N1+1:1:N2], [N2+1:1:N3], [N3+1:1:N4], [N4+1:1:N5], [N5+1:1:N6], [N6+1:1:N7], [N7+1:1:N8]}; - Vmap %= <<>>; - map1 %= <<{[1:1:1]} -> 0*x+o1, {[3:1:3]} -> 0*x+o2, {[5:1:N1+3]} -> 1*x+o3, {[N4+1:1:N5]} -> 1*x-o4, {[N5+1:1:N6]} -> 1*x-o5, {[N8+1:1:N9]} -> 1*x-o11>>; - map2 %= <<{[1:1:1]} -> 0*x+o6, {[3:1:3]} -> 0*x+o7, {[5:1:N1+3]} -> 1*x+o8, {[N4+1:1:N5]} -> 1*x+0, {[N5+1:1:N6]} -> 0*x+o10, {[N8+1:1:N9]} -> 1*x-o12>>; - Emap %= <<>>; -) diff --git a/test/circuit.test b/test/circuit.test new file mode 100644 index 0000000..4f389e6 --- /dev/null +++ b/test/circuit.test @@ -0,0 +1,120 @@ +/* Matching + SCC test of the following model: + +model Circuit + constant Integer N = 100000; + Real iL[N], Ua[N], Uc[N]; + parameter Real Ra = 1, Rb = 1, Rc = 1, L = 1; +equation + der(iL[1]) = U0 - Ua[1]; // der(iL[1]) + for i in 2:N loop + L*der(iL[i]) = Uc[i-1] - Ua[i]; // der(iL[2:N]) + end for; + for i in 1:N-1 loop + Ua[i] = Rb*iL[i+1] + Uc[i]*Rb/Rc; // Ua[1:N-1] + end for; + for i in 1:N-1 loop + iL[i] = Ua[i]/Ra + Uc[i]/Rc + iL[i+1]; // Uc[1:N-1] + end for; + iL[N] = Ua[N]/Ra + Uc[N]/Rc; // Uc[N] + Ua[N] = Uc[N]*Rb/Rc; // Ua[N] +end Circuit; +*/ + +N = 100000 + +F1 = 1 +F2 = N-1+F1 +F3 = N-1+F2 +F4 = N-1+F3 +F5 = 1+F4 +F6 = 1+F5 +U1 = N+F6 // der(iL) +U2 = N+U1 // Ua +U3 = N+U2 // Uc + +E1 = 1 // F1 - der(iL[1]) +E2 = 1+E1 // F1 - Ua[1] +E3 = N-1+E2 // F2 - der(iL[i]) +E4 = N-1+E3 // F2 - Ua[i] +E5 = N-1+E4 // F2 - Uc[i-1] +E6 = N-1+E5 // F3 - Ua[i] +E7 = N-1+E6 // F3 - Uc[i] +E8 = N-1+E7 // F4 - Ua[i] +E9 = N-1+E8 // F4 - Uc[i] +E10 = 1+E9 // F5 - Ua[N] +E11 = 1+E10 // F5 - Uc[N] +E12 = 1+E11 // F6 - Ua[N] +E13 = 1+E12 // F6 - Uc[N] + +off1b = r(U1, 1)-r(E1, 1)-N+1 +off2b = r(U2, 1)-r(E2, 1)-N+1 +off3b = r(U1, 1)-r(E3, 1) +off4b = r(U2, 1)-r(E4, 1) +off5b = r(U3, 1)-r(E5, 1)-1 +off6b = r(U2, 1)-r(E6, 1)-1 +off7b = r(U3, 1)-r(E7, 1)-1 +off8b = r(U2, 1)-r(E8, 1)-1 +off9b = r(U3, 1)-r(E9, 1)-1 +off10b = r(U2, 1)-E10 +off11b = r(U3, 1)-E11 +off12b = r(U2, 1)-E12 +off13b = r(U3, 1)-E13 + +off1d = r(F1, 1)-r(E1, 1) +off2d = r(F1, 1)-r(E2, 1) +off3d = r(F2, 1)-r(E3, 1) +off4d = r(F2, 1)-r(E4, 1) +off5d = r(F2, 1)-r(E5, 1) +off6d = r(F3, 1)-r(E6, 1) +off7d = r(F3, 1)-r(E7, 1) +off8d = r(F4, 1)-r(E8, 1) +off9d = r(F4, 1)-r(E9, 1) +off10d = r(F5, 1)-r(E10, 1) +off11d = r(F5, 1)-r(E11, 1) +off12d = r(F6, 1)-r(E12, 1) +off13d = r(F6, 1)-r(E13, 1) + +V %= {[1:1:F1], [F1+1:1:F2], [F2+1:1:F3], [F3+1:1:F4], [F4+1:1:F5] + , [F5+1:1:F6], [F6+1:1:U1], [U1+1:1:U2], [U2+1:1:U3]}; +Vmap %= <<{[1:1:F1]} -> 0*x+1, {[F1+1:1:F2]} -> 0*x+2, {[F2+1:1:F3]} -> 0*x+3 + , {[F3+1:1:F4]} -> 0*x+4, {[F4+1:1:F5]} -> 0*x+5 + , {[F5+1:1:U1]} -> 0*x+6, {[U1+1:1:U2]} -> 0*x+7, {[U2+1:1:U3]} -> 0*x+8>>; +map1 %= <<{[1:1:E1]} -> 1*x+off1d, {[E1+1:1:E2]} -> 1*x+off2d, {[E2+1:1:E3]} -> 1*x+off3d + , {[E3+1:1:E4]} -> 1*x+off4d, {[E4+1:1:E5]} -> 1*x+off5d, {[E5+1:1:E6]} -> 1*x+off6d + , {[E6+1:1:E7]} -> 1*x+off7d, {[E7+1:1:E8]} -> 1*x+off8d, {[E8+1:1:E9]} -> 1*x+off9d + , {[E9+1:1:E10]} -> 1*x+off10d, {[E10+1:1:E11]} -> 1*x+off11d + , {[E11+1:1:E12]} -> 1*x+off12d, {[E12+1:1:E13]} -> 1*x+off13d>>; +map2 %= <<{[1:1:E1]} -> 1*x+off1b, {[E1+1:1:E2]} -> 1*x+off2b, {[E2+1:1:E3]} -> 1*x+off3b + , {[E3+1:1:E4]} -> 1*x+off4b, {[E4+1:1:E5]} -> 1*x+off5b, {[E5+1:1:E6]} -> 1*x+off6b + , {[E6+1:1:E7]} -> 1*x+off7b, {[E7+1:1:E8]} -> 1*x+off8b, {[E8+1:1:E9]} -> 1*x+off9b + , {[E9+1:1:E10]} -> 1*x+off10b, {[E10+1:1:E11]} -> 1*x+off11b + , {[E11+1:1:E12]} -> 1*x+off12b, {[E12+1:1:E13]} -> 1*x+off13b>>; +Emap %= <<{[1:1:E1]} -> 0*x+1, {[E1+1:1:E2]} -> 0*x+2, {[E2+1:1:E3]} -> 0*x+3 + , {[E3+1:1:E4]} -> 0*x+4, {[E4+1:1:E5]} -> 0*x+5, {[E5+1:1:E6]} -> 0*x+6 + , {[E6+1:1:E7]} -> 0*x+7, {[E7+1:1:E8]} -> 0*x+8, {[E8+1:1:E9]} -> 0*x+9 + , {[E9+1:1:E10]} -> 0*x+10, {[E10+1:1:E11]} -> 0*x+11, {[E11+1:1:E12]} -> 0*x+12 + , {[E12+1:1:E13]} -> 0*x+13>>; + +matchSCC( + V %= {[1:1:F1], [F1+1:1:F2], [F2+1:1:F3], [F3+1:1:F4], [F4+1:1:F5] + , [F5+1:1:F6], [F6+1:1:U1], [U1+1:1:U2], [U2+1:1:U3]}; + Vmap %= <<{[1:1:F1]} -> 0*x+1, {[F1+1:1:F2]} -> 0*x+2, {[F2+1:1:F3]} -> 0*x+3 + , {[F3+1:1:F4]} -> 0*x+4, {[F4+1:1:F5]} -> 0*x+5 + , {[F5+1:1:U1]} -> 0*x+6, {[U1+1:1:U2]} -> 0*x+7, {[U2+1:1:U3]} -> 0*x+8>>; + map1 %= <<{[1:1:E1]} -> 1*x+off1d, {[E1+1:1:E2]} -> 1*x+off2d, {[E2+1:1:E3]} -> 1*x+off3d + , {[E3+1:1:E4]} -> 1*x+off4d, {[E4+1:1:E5]} -> 1*x+off5d, {[E5+1:1:E6]} -> 1*x+off6d + , {[E6+1:1:E7]} -> 1*x+off7d, {[E7+1:1:E8]} -> 1*x+off8d, {[E8+1:1:E9]} -> 1*x+off9d + , {[E9+1:1:E10]} -> 1*x+off10d, {[E10+1:1:E11]} -> 1*x+off11d + , {[E11+1:1:E12]} -> 1*x+off12d, {[E12+1:1:E13]} -> 1*x+off13d>>; + map2 %= <<{[1:1:E1]} -> 1*x+off1b, {[E1+1:1:E2]} -> 1*x+off2b, {[E2+1:1:E3]} -> 1*x+off3b + , {[E3+1:1:E4]} -> 1*x+off4b, {[E4+1:1:E5]} -> 1*x+off5b, {[E5+1:1:E6]} -> 1*x+off6b + , {[E6+1:1:E7]} -> 1*x+off7b, {[E7+1:1:E8]} -> 1*x+off8b, {[E8+1:1:E9]} -> 1*x+off9b + , {[E9+1:1:E10]} -> 1*x+off10b, {[E10+1:1:E11]} -> 1*x+off11b + , {[E11+1:1:E12]} -> 1*x+off12b, {[E12+1:1:E13]} -> 1*x+off13b>>; + Emap %= <<{[1:1:E1]} -> 0*x+1, {[E1+1:1:E2]} -> 0*x+2, {[E2+1:1:E3]} -> 0*x+3 + , {[E3+1:1:E4]} -> 0*x+4, {[E4+1:1:E5]} -> 0*x+5, {[E5+1:1:E6]} -> 0*x+6 + , {[E6+1:1:E7]} -> 0*x+7, {[E7+1:1:E8]} -> 0*x+8, {[E8+1:1:E9]} -> 0*x+9 + , {[E9+1:1:E10]} -> 0*x+10, {[E10+1:1:E11]} -> 0*x+11, {[E11+1:1:E12]} -> 0*x+12 + , {[E12+1:1:E13]} -> 0*x+13>>; + , 1 +) diff --git a/test/eval/gt_data/arithmetic/SBG.log b/test/eval/gt_data/arithmetic/SBG.log index 4182b06..71f5fc4 100755 --- a/test/eval/gt_data/arithmetic/SBG.log +++ b/test/eval/gt_data/arithmetic/SBG.log @@ -6,9 +6,6 @@ Parsing succeeded N = (100/1)-(200/1) -(2, 5) - --> (2, 5) - 2+3 --> 5 diff --git a/test/eval/gt_data/interval/SBG.log b/test/eval/gt_data/interval/SBG.log index 2779952..b79ded9 100755 --- a/test/eval/gt_data/interval/SBG.log +++ b/test/eval/gt_data/interval/SBG.log @@ -20,31 +20,31 @@ isEmpty([100:1:5]) --> 1 [1:1:0]/\[100:1:500] - --> [1:0] + --> [100:1:500]/\[1:1:0] - --> [1:0] + --> [1:2:20]/\[4:3:20] --> [7:6:19] [1:2:20]/\[2:2:20] - --> [1:0] + --> [201:2:399]/\[200:4:400] - --> [1:0] + --> [300:1:1000000]/\[300:1:500] --> [300:500] minElem([500:5:499]) - --> 1 + --> minElem([500:5:600]) --> 500 maxElem([500:5:499]) - --> 0 + --> maxElem([500:5:600]) --> 600 diff --git a/test/eval/gt_data/pw_map/SBG.log b/test/eval/gt_data/pw_map/SBG.log index bc5aadf..5a62e05 100644 --- a/test/eval/gt_data/pw_map/SBG.log +++ b/test/eval/gt_data/pw_map/SBG.log @@ -13,9 +13,6 @@ Parsing succeeded <<{[1:1:10], [100:10:200]} ↦ (1)x+-3, {[500:1:600]} ↦ (1)x+5>> --> <<{[1:10], [100:10:200]} ↦ x-3, {[500:600]} ↦ x+5>> -minMap({[1:1:5], [10:1:15], [20:2:30]}, (0)x+12, (2)x+-12) - --> <<{[13:15], [20:2:30]} ↦ 12, {[1:5], [10:12]} ↦ 2x-12>> - minMap(<<{[1:1:10], [15:3:30]} ↦ (1)x+0, {[12:3:12], [50:5:100]} ↦ (1)x+1>>, <<{[1:2:20], [30:5:60]} ↦ (0)x+100, {[75:5:90], [95:1:100]} ↦ (1)x+0>>) --> <<{[100:100]} ↦ x, {[95:95]} ↦ x, {[75:5:90]} ↦ x, {[50:5:60]} ↦ x+1, {[30:30]} ↦ x, {[15:15]} ↦ x, {[1:2:9]} ↦ x>> @@ -64,9 +61,6 @@ Parsing succeeded combine(<<{[1:1:10] x [1:1:10] x [1:1:10], [1:1:10] x [20:3:30] x [20:3:30]} ↦ (1)x+0|(1)x+0|(1)x+0, {[1:1:10] x [20:3:30] x [35:5:50], [35:5:50] x [35:5:50] x [20:3:30]} ↦ (3)x+0|(3)x+0|(1)x+1>>, <<{[1:1:20] x [1:1:20] x [1:1:20]} ↦ (1)x+1|(1)x+0|(1)x+0>>) --> <<{[1:10]x[1:10]x[1:10], [1:10]x[20:3:29]x[20:3:29]} ↦ x|x|x, {[1:10]x[20:3:29]x[35:5:50], [35:5:50]x[35:5:50]x[20:3:29]} ↦ 3x|3x|x+1, {[1:10]x[1:10]x[11:20], [1:10]x[20:20]x[1:19], [11:20]x[1:20]x[1:20], [1:10]x[11:19]x[1:20]} ↦ x+1|x|x>> -minMap({[2:2:20] x [3:3:50] x [1:1:10]}, (1)x+60|(0)x+35|(2)x+2, (1)x+60|(1)x+10|(2)x+2) - --> <<{[2:2:20]x[27:3:48]x[1:10]} ↦ x+60|35|2x+2, {[2:2:20]x[3:3:24]x[1:10]} ↦ x+60|x+10|2x+2>> - reduce(<<{[4:1:15] x [4:1:15] x [4:1:15], [4:1:15] x [20:2:25] x [4:1:15]} ↦ (1)x+0|(1)x+-3|(3)x+0, {[4:1:15] x [15:5:50] x [20:2:25], [20:2:25] x [40:5:45] x [40:5:45]} ↦ (2)x+0|(1)x+0|(4)x+4>>) --> <<{[4:15]x[4:15]x[4:15], [4:15]x[20:2:24]x[4:15]} ↦ x|x-3|3x, {[4:15]x[15:5:50]x[20:2:24], [20:2:24]x[40:5:45]x[40:5:45]} ↦ 2x|x|4x+4>> diff --git a/test/implicit_indices.test b/test/implicit_indices.test index 17a0703..fa9eaa0 100644 --- a/test/implicit_indices.test +++ b/test/implicit_indices.test @@ -1,4 +1,5 @@ -/* +/* Matching test of the following model: + model implicit_indices Real a[100][100], b[100]; equation diff --git a/test/matching1.test b/test/matching1.test index 422403a..c3398aa 100644 --- a/test/matching1.test +++ b/test/matching1.test @@ -1,6 +1,18 @@ -// Matching test, with a simple recursion +/* Matching test of a single large path, +originated from the following model: -N = 10 +model matching1 + constant Integer N = 100000; + Real a[N]; +equation + a[1] = 0; + for i in 2:N loop + a[i-1] + a[i] = 0; + end for; +end matching1; +*/ + +N = 100000 V1 = 1 V2 = N-1+V1 diff --git a/test/matching2.test b/test/matching2.test index 5b8fcba..c360995 100644 --- a/test/matching2.test +++ b/test/matching2.test @@ -1,7 +1,20 @@ -// Matching test, with recursions that starts in the middle +/* Matching test of a single large path + path starting +at the middle of the first one, +originated from the following model: -N = 10000 -N2 = 5000 +model matching1 + constant Integer N = 100000; + Real a[N]; +equation + a[N/2] = 0; + for i in 2:N loop + a[i-1] + a[i] = 0; + end for; +end matching1; +*/ + +N = 100000 +N2 = 50000 V1 = 1 V2 = N-1+V1 diff --git a/test/matching3.test b/test/matching3.test index 0e19938..2285a00 100644 --- a/test/matching3.test +++ b/test/matching3.test @@ -1,4 +1,37 @@ -// Matching test, with a cycle +/* Matching test of a graph with a cycle, +originated from the model: + +model buck + parameter Real C = 1e-4, L = 1e-4, R = 10, U = 24, T = 1e-4, DC = 0.5, ROn = 1e-5, ROff = 1e5; + discrete Real Rd(start=1e5), Rs(start=1e-5), nextT(start=T),lastT,diodeon; + Real uC,iL,iD,s; + + equation + iD=(iL*Rs-U)/(Rs+Rd); + s=diodeon*iD+(1-diodeon)*iD*Rd; + der(iL) = (-iD*Rd- uC)/L; + der(uC) = (iL - uC/R)/C; + + algorithm + when time > nextT then + lastT:=nextT; + nextT:=nextT+T; + Rs := ROn; + end when; + + when time - lastT-DC*T>0 then + Rs := ROff; + end when; + + when s>0 then + Rd:=ROn; + diodeon:=1; + elsewhen s<0 then + Rd := ROff; + diodeon:=0; + end when; +end buck; +*/ V %= {[2:1:2], [3:1:3], [4:1:4], [5:1:5], [9:1:9], [10:1:10], [11:1:11], [12:1:12]}; Vmap %= <<{[2:1:2]} -> 0*x+1, {[3:1:3]} -> 0*x+2, {[4:1:4]} -> 0*x+3, {[5:1:5]} -> 0*x+4 diff --git a/test/parser/gt_data/arithmetic/SBG.log b/test/parser/gt_data/arithmetic/SBG.log index 3b436f1..3c65e5c 100755 --- a/test/parser/gt_data/arithmetic/SBG.log +++ b/test/parser/gt_data/arithmetic/SBG.log @@ -4,7 +4,6 @@ Parsing succeeded N = (100/1)-(200/1) -(2, 5) 2+3 (1/2) 2*10+3 diff --git a/test/performance/boost/perf_boost.sh b/test/performance/boost/perf_boost.sh index 91798d4..66c54c3 100755 --- a/test/performance/boost/perf_boost.sh +++ b/test/performance/boost/perf_boost.sh @@ -61,10 +61,10 @@ for i in $( awk '{ print $1; }' test_values ) done echo -echo "Average:" +echo "Average algorithm:" echo "scale=2; $total / $count" | bc - +algo=$total/$count; count=0; total=0; @@ -75,5 +75,11 @@ for i in $( awk '{ print $1; }' builder_values ) done echo -echo "Average:" +echo "Average builder:" echo "scale=2; $total / $count" | bc + +total=$algo+$total/$count; + +echo +echo "Average total:" +echo "scale=2; $total" | bc diff --git a/test/performance/matching/perf_matching.sh b/test/performance/matching/perf_matching.sh index 38a2d0c..554c750 100755 --- a/test/performance/matching/perf_matching.sh +++ b/test/performance/matching/perf_matching.sh @@ -44,7 +44,5 @@ for i in $( awk '{ print $1; }' test_values ) done echo -echo "Average:" +echo "Average matching:" echo "scale=2; $total / $count" | bc - - diff --git a/test/performance/scc/perf_scc.sh b/test/performance/scc/perf_scc.sh index 91d1e88..97551f3 100755 --- a/test/performance/scc/perf_scc.sh +++ b/test/performance/scc/perf_scc.sh @@ -63,8 +63,8 @@ echo echo "Average builder:" echo "scale=2; $total / $count" | bc -algo=$algo+$total/$count; +total=$algo+$total/$count; echo echo "Average total:" -echo "scale=2; $algo" | bc +echo "scale=2; $total" | bc diff --git a/test/pw_map1.test b/test/pw_map1.test index 8cffdb7..ce011e9 100644 --- a/test/pw_map1.test +++ b/test/pw_map1.test @@ -6,7 +6,6 @@ <<{[1:1:10], [100:10:200]} -> 1*x-3>> <<{[1:1:10], [100:10:200]} -> 1*x-3, {[500:1:600]} -> 1*x+5>> -minMap({[1:1:5], [10:1:15], [20:2:30]}, 0*x+12, 2*x-12) minMap(<<{[1:1:10], [15:3:30]} -> 1*x+0, {[12:3:12], [50:5:100]} -> 1*x+1>>, <<{[1:2:20], [30:5:60]} -> 0*x+100, {[75:5:90], [95:1:100]} -> 1*x+0>>) reduce(<<{[100:1:200]} -> 1*x-1>>) diff --git a/test/pw_map3.test b/test/pw_map3.test index 49d712a..dba68b9 100644 --- a/test/pw_map3.test +++ b/test/pw_map3.test @@ -10,6 +10,4 @@ combine(<<{[1:1:10] x [1:1:10] x [1:1:10], [1:1:10] x [20:3:30] x [20:3:30]} -> [20:3:30] x [35:5:50], [35:5:50] x [35:5:50] x [20:3:30]} -> 3*x+0|3*x+0|1*x+1>>, <<{[1:1:20] x [1:1:20] x [1:1:20]} -> 1*x+1|1*x+0|1*x+0>>) -minMap({[2:2:20] x [3:3:50] x [1:1:10]}, 1*x+60|0*x+35|2*x+2, 1*x+60|1*x+10|2*x+2) - reduce(<<{[4:1:15] x [4:1:15] x [4:1:15], [4:1:15] x [20:2:25] x [4:1:15]} -> 1*x+0|1*x-3|3*x+0, {[4:1:15] x [15:5:50] x [20:2:25], [20:2:25] x [40:5:45] x [40:5:45]} -> 2*x+0|1*x+0|4*x+4>>) diff --git a/test/rc_matching.test b/test/rc_matching.test index 81656ec..c7e6f55 100644 --- a/test/rc_matching.test +++ b/test/rc_matching.test @@ -1,21 +1,23 @@ -/* +/* Matching test originated from the following model +(the result is indicated with comments): + model rc - constant Integer n=100; + constant Integer N=100000; parameter Real RA=1,RB=1,C=1,i0=1; - Real vA[n],vB[n],vC[n],iR[n]; + Real vA[N],vB[N],vC[N],iR[N]; equation - iR[1]=i0; // Eq.(1) - for i in 1:n loop - vA[i]=RA*iR[i]; //Eq.(2) - vB[i]=RB*iR[i]; //Eq.(3) + iR[1]=i0; // iR[1] + for i in 1:N loop + vA[i]=RA*iR[i]; // iR[2:N], vA[1] + vB[i]=RB*iR[i]; // vB[1:N] end for; - for i in 2:n loop - vA[i]+vB[i]=vC[i-1]-vC[i]; //Eq.(4) + for i in 2:N loop + vA[i]+vB[i]=vC[i-1]-vC[i]; // vA[2:N] end for; - for i in 1:n-1 loop - C*der(vC[i])=iR[i]-iR[i+1]; //Eq.(5) + for i in 1:N-1 loop + C*der(vC[i])=iR[i]-iR[i+1]; // vC[1:N-1] end for; - C*der(vC[n])=iR[n]; //Eq.(6) + C*der(vC[N])=iR[N]; // der(vC[N]) end rc; */ diff --git a/test/rc_ts.test b/test/rc_ts.test index 7131756..355834d 100644 --- a/test/rc_ts.test +++ b/test/rc_ts.test @@ -1,25 +1,28 @@ -/* +/* Topological sort test originated from the model +(which is horizontally ordered and where algebraic +loops have been identified): + model rc - constant Integer n=100; - parameter Real RA=1,RB=1,C=1,i0=1; - Real vA[n],vB[n],vC[n],iR[n]; + constant Integer N=100000; + parameter Real RA=1, RB=1,C=1, i0=1; + Real vA[N], vB[N], vC[N], iR[N]; equation - iR[1]=i0; // Eq.(1) - for i in 1:n loop - vA[i]=RA*iR[i]; //Eq.(2) - vB[i]=RB*iR[i]; //Eq.(3) - end for; - for i in 2:n loop - vA[i]+vB[i]=vC[i-1]-vC[i]; //Eq.(4) + iR[1] = i0; + vA[1] = RA*iR[1]; + vB[1] = RB*iR[1]; + for i in 2:N loop + 0 = RA*iR[i] - vA[i]; // iR[2:N] + 0 = RB*iR[i] - vB[i]; // vB[2:N] + 0 = vC[i-1] - vC[i] - vA[i] - vB[i]; // vA[2:N] end for; - for i in 1:n-1 loop - C*der(vC[i])=iR[i]-iR[i+1]; //Eq.(5) + for i in 1:N-1 loop + der(vC[i]) = (iR[i]-iR[i+1])/C; end for; - C*der(vC[n])=iR[n]; //Eq.(6) + der(vC[N]) = iR[N]/C; end rc; */ -N = 100 +N = 100000 F1 = 1 F2 = N+F1 diff --git a/test/rl1_matching.test b/test/rl1_matching.test index 3951ad5..38b08de 100644 --- a/test/rl1_matching.test +++ b/test/rl1_matching.test @@ -1,25 +1,27 @@ -/* +/* Matching test originated from the following model +(the result is indicated with comments): + model testRL1 //iR[i] must be computed out of iR[i+1] //uL[i+1] must be computed out of uL[i] - constant Integer N=10; + constant Integer N=100000; Real iL[N],iR[N],uL[N]; parameter Real L=1,R=1,L1=1,I=1,R0=1; equation for i in 1:N loop - L*der(iL[i])=uL[i]; + L*der(iL[i])=uL[i]; // der(iL[1:N]) end for; for i in 1:N-1 loop - iR[i]-iR[i+1]-iL[i]=0; - uL[i]-uL[i+1]-R*iR[i+1]=0; + iR[i]-iR[i+1]-iL[i]=0; // iR[1:N-1] + uL[i]-uL[i+1]-R*iR[i+1]=0; // uL[2:N] end for; - iR[N]-iL[N]+I=0; - uL[1]+(R+R0)*iR[1]=0; + iR[N]-iL[N]+I=0; // iR[N] + uL[1]+(R+R0)*iR[1]=0; // uL[1] end testRL1; */ -N = 100 +N = 100000 F1 = N F2 = N-1+F1 diff --git a/test/rl1_scc.test b/test/rl1_scc.test index a876130..987918f 100644 --- a/test/rl1_scc.test +++ b/test/rl1_scc.test @@ -1,25 +1,28 @@ -/* +/* Detection of algebraic loops (SCC) for the following +model, where the matching is indicated with comments +for each equation: + model testRL1 //iR[i] must be computed out of iR[i+1] //uL[i+1] must be computed out of uL[i] - constant Integer N=10; + constant Integer N=100000; Real iL[N],iR[N],uL[N]; parameter Real L=1,R=1,L1=1,I=1,R0=1; equation for i in 1:N loop - L*der(iL[i])=uL[i]; + L*der(iL[i])=uL[i]; // der(iL[1:10]) end for; for i in 1:N-1 loop - iR[i]-iR[i+1]-iL[i]=0; - uL[i]-uL[i+1]-R*iR[i+1]=0; + iR[i]-iR[i+1]-iL[i]=0; // iR[1:N-1] + uL[i]-uL[i+1]-R*iR[i+1]=0; // uL[2:N] end for; - iR[N]-iL[N]+I=0; - uL[1]+(R+R0)*iR[1]=0; + iR[N]-iL[N]+I=0; // ir[N] + uL[1]+(R+R0)*iR[1]=0; // uL[1] end testRL1; */ -N = 100 +N = 100000 F1 = N F2 = N-1+F1 diff --git a/test/rl2_matching.test b/test/rl2_matching.test index 0803050..3f437c7 100644 --- a/test/rl2_matching.test +++ b/test/rl2_matching.test @@ -1,25 +1,27 @@ -/* +/* Matching test originated from the following model +(the result is indicated with comments): + model testRL2 //iR[i+1] must be computed out of iR[i] //uL[i] must be computed out of uL[i+1] - constant Integer N=10; + constant Integer N=100000; Real iL[N],iR[N],uL[N]; parameter Real L=1,R=1,L1=1,I=1,R0=1; equation for i in 1:N loop - L*der(iL[i])=uL[i]; + L*der(iL[i])=uL[i]; // der(iL[1:N]) end for; for i in 1:N-1 loop - iR[i]-iR[i+1]-iL[i]=0; - uL[i]-uL[i+1]-R*iR[i+1]=0; + iR[i]-iR[i+1]-iL[i]=0; // iR[2:N] + uL[i]-uL[i+1]-R*iR[i+1]=0; // uL[1:N-1] end for; - iR[1]=I; - uL[N]-(iR[N]-iL[N])*R0=0; + iR[1]=I; // iR[1] + uL[N]-(iR[N]-iL[N])*R0=0; // uL[N] end testRL2; */ -N = 100 +N = 100000 F1 = N F2 = N-1+F1 diff --git a/test/rl2_scc.test b/test/rl2_scc.test index 8f57bf5..07ea2bb 100644 --- a/test/rl2_scc.test +++ b/test/rl2_scc.test @@ -1,9 +1,12 @@ -/* +/* Detection of algebraic loops (SCC) for the following +model, where the matching is indicated with comments +for each equation: + model testRL2 //iR[i+1] must be computed out of iR[i] //uL[i] must be computed out of uL[i+1] - constant Integer N=10; + constant Integer N=100000; Real iL[N],iR[N],uL[N]; parameter Real L=1,R=1,L1=1,I=1,R0=1; equation @@ -19,7 +22,7 @@ equation end testRL2; */ -N = 100 +N = 100000 F1 = N F2 = N-1+F1 diff --git a/test/rl3_matching.test b/test/rl3_matching.test index 09d2c76..4c8b117 100644 --- a/test/rl3_matching.test +++ b/test/rl3_matching.test @@ -1,26 +1,28 @@ -/* +/* Matching test originated from the following model +(the result is indicated with comments): + model testRL3 //iR[i] and iR[i+1] can be computed out of each other //uL[i] and uL[i+1] can be computed out of each other //All variables form a large algebraic loop - constant Integer N=5; + constant Integer N=100000; Real iL[N],iR[N],uL[N]; parameter Real L=1,R=1,L1=1,U=1,R0=1; equation for i in 1:N loop - L*der(iL[i])=uL[i]; + L*der(iL[i])=uL[i]; // der(iL[1:N]) end for; for i in 1:N-1 loop - iR[i]-iR[i+1]-iL[i]=0; - uL[i]-uL[i+1]-R*iR[i+1]=0; + iR[i]-iR[i+1]-iL[i]=0; // iR[1], iR[3:N] + uL[i]-uL[i+1]-R*iR[i+1]=0; // iR[2], uL[2:N-1] end for; - U-uL[1]-R*iR[1]=0; - uL[N]-(iR[N]-iL[N])*R0=0; + U-uL[1]-R*iR[1]=0; // uL[1] + uL[N]-(iR[N]-iL[N])*R0=0; // uL[N] end testRL3; */ -N = 2000 +N = 100000 F1 = N F2 = N-1+F1 diff --git a/test/rl3_scc.test b/test/rl3_scc.test index 4aee62b..5b9ff02 100644 --- a/test/rl3_scc.test +++ b/test/rl3_scc.test @@ -1,10 +1,13 @@ -/* +/* Detection of algebraic loops (SCC) for the following +model, where the matching is indicated with comments +for each equation: + model testRL3 //iR[i] and iR[i+1] can be computed out of each other //uL[i] and uL[i+1] can be computed out of each other //All variables form a large algebraic loop - constant Integer N=10; + constant Integer N=100000; Real iL[N],iR[N],uL[N]; parameter Real L=1,R=1,L1=1,U=1,R0=1; equation diff --git a/test/rlc1_matching.test b/test/rlc1_matching.test index 55ec559..5b1af03 100644 --- a/test/rlc1_matching.test +++ b/test/rlc1_matching.test @@ -1,27 +1,29 @@ -/* +/* Matching test originated from the following model +(the result is indicated with comments): + model testRLC1 //iRa[i] and iRb[i] form an algebraic loop - constant Integer N=10; + constant Integer N=100000; Real iL[N],uC[N],uL[N],iRa[N],iRb[N],iC[N]; parameter Real L=1,Ra=1,Rb=1,C=1,U=1; equation for i in 1:N loop - L*der(iL[i])=uL[i]; - C*der(uC[i])=iC[i]; - iRa[i]-iRb[i]-iL[i]=0; - uL[i]-Rb*iRb[i]-uC[i]=0; + L*der(iL[i])=uL[i]; // der(iL[1:N]) + C*der(uC[i])=iC[i]; // der(uC[1:N]) + iRa[i]-iRb[i]-iL[i]=0; // iRa[1:N] + uL[i]-Rb*iRb[i]-uC[i]=0; // iRb[1], uL[2:N] end for; for i in 2:N loop - uC[i-1]-Ra*iRa[i]-Rb*iRb[i]-uC[i]=0; - iRb[i-1]-iRa[i]-iC[i-1]=0; + uC[i-1]-Ra*iRa[i]-Rb*iRb[i]-uC[i]=0; // iRb[2:N] + iRb[i-1]-iRa[i]-iC[i-1]=0; // iC[1:N-1] end for; - U-Ra*iRa[1]-uL[1]=0; + U-Ra*iRa[1]-uL[1]=0; // uL[1] iRb[N]-iC[N]=0; // iC[N] end testRLC1; */ -N = 10 +N = 100000 F1 = N F2 = N+F1 diff --git a/test/rlc1_scc.test b/test/rlc1_scc.test index d2f8745..f0a1a63 100644 --- a/test/rlc1_scc.test +++ b/test/rlc1_scc.test @@ -1,8 +1,11 @@ -/* +/* Detection of algebraic loops (SCC) for the following +model, where the matching is indicated with comments +for each equation: + model testRLC1 //iRa[i] and iRb[i] form an algebraic loop - constant Integer N=10; + constant Integer N=100000; Real iL[N],uC[N],uL[N],iRa[N],iRb[N],iC[N]; parameter Real L=1,Ra=1,Rb=1,C=1,U=1; equation @@ -21,7 +24,7 @@ equation end testRLC1; */ -N = 10 +N = 100000 F1 = N F2 = N+F1 diff --git a/test/scc1.test b/test/scc1.test index a0394e5..9fbe67d 100644 --- a/test/scc1.test +++ b/test/scc1.test @@ -1,4 +1,18 @@ -// SCC test, with a simple long cycle +/* SCC test of a graph with a long cycle, +originated from the model (where the matching +is indicated with comments for each equation): + +model scc1 + constant Integer N = 100000; + Real a[N], b; +equation + for i in 1:N-1 loop + a[i] + a[i+1] = 0; // a[1:N-1] + end for; + a[N] + b = 0; // a[N] + a[1] + b = 0; // b +end scc1; +*/ N = 100000 diff --git a/test/scc2.test b/test/scc2.test index 4c990d5..4cbb4b6 100644 --- a/test/scc2.test +++ b/test/scc2.test @@ -1,48 +1,49 @@ -// SCC test, with a simple long cycle +// SCC test, where the matching is a simple recursion with two +// border conditions in the middle of the long path -N = 100000 +N = 900000 +N2 = 300000 +N3 = 600000 V1 = 1 -V2 = N+V1 +V2 = 1+V1 V3 = N-1+V2 -V4 = 1+V3 +V4 = N+V3 E1 = 1 -E2 = N-1+E1 +E2 = 1+E1 E3 = N-1+E2 -E4 = 1+E3 -E5 = 1+E4 +E4 = N-1+E3 -off1b = r(V1, 1)-E1 -off2b = r(V2, 1)-E2-1 -off3b = r(V3, 1)-E3 -off4b = r(V2, 1)-E4 -off5b = r(V4, 1)-E5 +off1b = r(V1, 1)-r(E1, 1) +off2b = r(V2, 1)-r(E2, 1) +off3b = r(V3, 1)-r(E3, 1) +off4b = r(V3, 1)-r(E4, 1) -off1d = r(V2, 1)-E1-N+1 -off2d = r(V3, 1)-E2 -off3d = r(V2, 1)-E3 -off4d = r(V4, 1)-E4 -off5d = r(V1, 1)-E5 +off1d = r(V4, 1)-r(E1, 1)-N3 +off2d = r(V4, 1)-r(E2, 1)-N2 +off3d = r(V4, 1)-r(E3, 1)-1 +off4d = r(V4, 1)-r(E4, 1) V %= {[1:1:V1], [V1+1:1:V2], [V2+1:1:V3], [V3+1:1:V4]}; Vmap %= <<{[1:1:V1]} -> 0*x+1, {[V1+1:1:V2]} -> 0*x+2, {[V2+1:1:V3]} -> 0*x+3 - , {[V3+1:1:V4]} -> 0*x+4>>; -mapB %= <<{[1:1:E1]} -> 1*x+off1b, {[E1+1:1:E2]} -> 1*x+off2b, {[E2+1:1:E3]} -> 1*x+off3b - , {[E3+1:1:E4]} -> 1*x+off4b, {[E4+1:1:E5]} -> 1*x+off5b>>; -mapD %= <<{[1:1:E1]} -> 1*x+off1d, {[E1+1:1:E2]} -> 1*x+off2d, {[E2+1:1:E3]} -> 1*x+off3d - , {[E3+1:1:E4]} -> 1*x+off4d, {[E4+1:1:E5]} -> 1*x+off5d>>; -Emap %= <<{[1:1:E1]} -> 0*x+1, {[E1+1:1:E2], [E2+1:1:E3]} -> 0*x+2, {[E3+1:1:E4]} -> 0*x+3 - , {[E4+1:1:E5]} -> 0*x+4>>; + , {[V3+1:1:V4]} -> 0*x+4>>; +map1 %= <<{[1:1:E1]} -> 1*x+off1b, {[E1+1:1:E2]} -> 1*x+off2b, {[E2+1:1:E3]} -> 1*x+off3b + , {[E3+1:1:E4]} -> 1*x+off4b>>; +map2 %= <<{[1:1:E1]} -> 1*x+off1d, {[E1+1:1:E2]} -> 1*x+off2d, {[E2+1:1:E3]} -> 1*x+off3d + , {[E3+1:1:E4]} -> 1*x+off4d>>; +Emap %= <<{[1:1:E1]} -> 0*x+1, {[E1+1:1:E2]} -> 0*x+2 + , {[E2+1:1:E3], [E3+1:1:E4]} -> 0*x+3>>; -scc( -V %= {[1:1:V1], [V1+1:1:V2], [V2+1:1:V3], [V3+1:1:V4]}; -Vmap %= <<{[1:1:V1]} -> 0*x+1, {[V1+1:1:V2]} -> 0*x+2, {[V2+1:1:V3]} -> 0*x+3 - , {[V3+1:1:V4]} -> 0*x+4>>; -mapB %= <<{[1:1:E1]} -> 1*x+off1b, {[E1+1:1:E2]} -> 1*x+off2b, {[E2+1:1:E3]} -> 1*x+off3b - , {[E3+1:1:E4]} -> 1*x+off4b, {[E4+1:1:E5]} -> 1*x+off5b>>; -mapD %= <<{[1:1:E1]} -> 1*x+off1d, {[E1+1:1:E2]} -> 1*x+off2d, {[E2+1:1:E3]} -> 1*x+off3d - , {[E3+1:1:E4]} -> 1*x+off4d, {[E4+1:1:E5]} -> 1*x+off5d>>; -Emap %= <<{[1:1:E1]} -> 0*x+1, {[E1+1:1:E2], [E2+1:1:E3]} -> 0*x+2, {[E3+1:1:E4]} -> 0*x+3 - , {[E4+1:1:E5]} -> 0*x+4>>; +matchSCC( + V %= {[1:1:V1], [V1+1:1:V2], [V2+1:1:V3], [V3+1:1:V4]}; + Vmap %= <<{[1:1:V1]} -> 0*x+1, {[V1+1:1:V2]} -> 0*x+2, {[V2+1:1:V3]} -> 0*x+3 + , {[V3+1:1:V4]} -> 0*x+4>>; + map1 %= <<{[1:1:E1]} -> 1*x+off1b, {[E1+1:1:E2]} -> 1*x+off2b, {[E2+1:1:E3]} -> 1*x+off3b + , {[E3+1:1:E4]} -> 1*x+off4b>>; + map2 %= <<{[1:1:E1]} -> 1*x+off1d, {[E1+1:1:E2]} -> 1*x+off2d, {[E2+1:1:E3]} -> 1*x+off3d + , {[E3+1:1:E4]} -> 1*x+off4d>>; + Emap %= <<{[1:1:E1]} -> 0*x+1, {[E1+1:1:E2]} -> 0*x+2 + , {[E2+1:1:E3], [E3+1:1:E4]} -> 0*x+3>>; + , 1 ) diff --git a/test/scc3.test b/test/scc3.test index e15ce18..319aaf0 100644 --- a/test/scc3.test +++ b/test/scc3.test @@ -1,49 +1,31 @@ -// SCC test, where the matching is a simple recursion with two -// border conditions in the middle of the long path +// SCC test, with a long path, and a branch in the middle +// that goes to a minimum value -N = 900 -N2 = 300 -N3 = 600 +N = 100000 +N2 = 50000 V1 = 1 -V2 = 1+V1 -V3 = N-1+V2 -V4 = N+V3 +V2 = N+V1 E1 = 1 -E2 = 1+E1 -E3 = N-1+E2 -E4 = N-1+E3 +E2 = N-1+E1 -off1b = r(V1, 1)-r(E1, 1) -off2b = r(V2, 1)-r(E2, 1) -off3b = r(V3, 1)-r(E3, 1) -off4b = r(V3, 1)-r(E4, 1) +off1b = r(V2, 1)-E1-N2 +off2b = r(V2, 1)-E2-1 -off1d = r(V4, 1)-r(E1, 1)-N3 -off2d = r(V4, 1)-r(E2, 1)-N2 -off3d = r(V4, 1)-r(E3, 1)-1 -off4d = r(V4, 1)-r(E4, 1) +off1d = r(V1, 1)-E1 +off2d = r(V2, 1)-E2 -V %= {[1:1:V1], [V1+1:1:V2], [V2+1:1:V3], [V3+1:1:V4]}; -Vmap %= <<{[1:1:V1]} -> 0*x+1, {[V1+1:1:V2]} -> 0*x+2, {[V2+1:1:V3]} -> 0*x+3 - , {[V3+1:1:V4]} -> 0*x+4>>; -map1 %= <<{[1:1:E1]} -> 1*x+off1b, {[E1+1:1:E2]} -> 1*x+off2b, {[E2+1:1:E3]} -> 1*x+off3b - , {[E3+1:1:E4]} -> 1*x+off4b>>; -map2 %= <<{[1:1:E1]} -> 1*x+off1d, {[E1+1:1:E2]} -> 1*x+off2d, {[E2+1:1:E3]} -> 1*x+off3d - , {[E3+1:1:E4]} -> 1*x+off4d>>; -Emap %= <<{[1:1:E1]} -> 0*x+1, {[E1+1:1:E2]} -> 0*x+2 - , {[E2+1:1:E3], [E3+1:1:E4]} -> 0*x+3>>; +V %= {[1:1:V1], [V1+1:1:V2]}; +Vmap %= <<{[1:1:V1]} -> 0*x+1, {[V1+1:1:V2]} -> 0*x+2>>; +mapB %= <<{[1:1:E1]} -> 1*x+off1b, {[E1+1:1:E2]} -> 1*x+off2b>>; +mapD %= <<{[1:1:E1]} -> 1*x+off1d, {[E1+1:1:E2]} -> 1*x+off2d>>; +Emap %= <<{[1:1:E1]} -> 0*x+1, {[E1+1:1:E2]} -> 0*x+2>>; -matchSCC( - V %= {[1:1:V1], [V1+1:1:V2], [V2+1:1:V3], [V3+1:1:V4]}; - Vmap %= <<{[1:1:V1]} -> 0*x+1, {[V1+1:1:V2]} -> 0*x+2, {[V2+1:1:V3]} -> 0*x+3 - , {[V3+1:1:V4]} -> 0*x+4>>; - map1 %= <<{[1:1:E1]} -> 1*x+off1b, {[E1+1:1:E2]} -> 1*x+off2b, {[E2+1:1:E3]} -> 1*x+off3b - , {[E3+1:1:E4]} -> 1*x+off4b>>; - map2 %= <<{[1:1:E1]} -> 1*x+off1d, {[E1+1:1:E2]} -> 1*x+off2d, {[E2+1:1:E3]} -> 1*x+off3d - , {[E3+1:1:E4]} -> 1*x+off4d>>; - Emap %= <<{[1:1:E1]} -> 0*x+1, {[E1+1:1:E2]} -> 0*x+2 - , {[E2+1:1:E3], [E3+1:1:E4]} -> 0*x+3>>; - , 1 +scc( + V %= {[1:1:V1], [V1+1:1:V2]}; + Vmap %= <<{[1:1:V1]} -> 0*x+1, {[V1+1:1:V2]} -> 0*x+2>>; + mapB %= <<{[1:1:E1]} -> 1*x+off1b, {[E1+1:1:E2]} -> 1*x+off2b>>; + mapD %= <<{[1:1:E1]} -> 1*x+off1d, {[E1+1:1:E2]} -> 1*x+off2d>>; + Emap %= <<{[1:1:E1]} -> 0*x+1, {[E1+1:1:E2]} -> 0*x+2>>; ) diff --git a/test/scc4.test b/test/scc4.test index 319aaf0..ce7a6f9 100644 --- a/test/scc4.test +++ b/test/scc4.test @@ -1,31 +1,41 @@ -// SCC test, with a long path, and a branch in the middle -// that goes to a minimum value +// SCC test with a single long path, with small cycles +// between pairs of vertices N = 100000 -N2 = 50000 V1 = 1 -V2 = N+V1 +V2 = N-1+V1 +V3 = N+V2 E1 = 1 E2 = N-1+E1 +E3 = N-1+E2 +E4 = N-1+E3 -off1b = r(V2, 1)-E1-N2 -off2b = r(V2, 1)-E2-1 +off1b = r(V1, 1)-r(E1, 1) +off2b = r(V3, 1)-r(E2, 1)-1 +off3b = r(V2, 1)-r(E3, 1) +off4b = r(V2, 1)-r(E4, 1) -off1d = r(V1, 1)-E1 -off2d = r(V2, 1)-E2 +off1d = r(V3, 1)-r(E1, 1)-N+1 +off2d = r(V2, 1)-r(E2, 1) +off3d = r(V3, 1)-r(E3, 1) +off4d = r(V3, 1)-r(E4, 1)-1 -V %= {[1:1:V1], [V1+1:1:V2]}; -Vmap %= <<{[1:1:V1]} -> 0*x+1, {[V1+1:1:V2]} -> 0*x+2>>; -mapB %= <<{[1:1:E1]} -> 1*x+off1b, {[E1+1:1:E2]} -> 1*x+off2b>>; -mapD %= <<{[1:1:E1]} -> 1*x+off1d, {[E1+1:1:E2]} -> 1*x+off2d>>; -Emap %= <<{[1:1:E1]} -> 0*x+1, {[E1+1:1:E2]} -> 0*x+2>>; +V %= {[1:1:V1], [V1+1:1:V2], [V2+1:1:V3]}; +Vmap %= <<{[1:1:V1]} -> 0*x+1, {[V1+1:1:V2]} -> 0*x+2, {[V2+1:1:V3]} -> 0*x+3>>; +mapB %= <<{[1:1:E1]} -> 1*x+off1b, {[E1+1:1:E2]} -> 1*x+off2b, {[E2+1:1:E3]} -> 1*x+off3b + , {[E3+1:1:E4]} -> 1*x+off4b>>; +mapD %= <<{[1:1:E1]} -> 1*x+off1d, {[E1+1:1:E2]} -> 1*x+off2d, {[E2+1:1:E3]} -> 1*x+off3d + , {[E3+1:1:E4]} -> 1*x+off4d>>; +Emap %= <<{[1:1:E1]} -> 0*x+1, {[E1+1:1:E2], [E2+1:1:E3], [E3+1:1:E4]} -> 0*x+2>>; scc( - V %= {[1:1:V1], [V1+1:1:V2]}; - Vmap %= <<{[1:1:V1]} -> 0*x+1, {[V1+1:1:V2]} -> 0*x+2>>; - mapB %= <<{[1:1:E1]} -> 1*x+off1b, {[E1+1:1:E2]} -> 1*x+off2b>>; - mapD %= <<{[1:1:E1]} -> 1*x+off1d, {[E1+1:1:E2]} -> 1*x+off2d>>; - Emap %= <<{[1:1:E1]} -> 0*x+1, {[E1+1:1:E2]} -> 0*x+2>>; + V %= {[1:1:V1], [V1+1:1:V2], [V2+1:1:V3]}; + Vmap %= <<{[1:1:V1]} -> 0*x+1, {[V1+1:1:V2]} -> 0*x+2, {[V2+1:1:V3]} -> 0*x+3>>; + mapB %= <<{[1:1:E1]} -> 1*x+off1b, {[E1+1:1:E2]} -> 1*x+off2b, {[E2+1:1:E3]} -> 1*x+off3b + , {[E3+1:1:E4]} -> 1*x+off4b>>; + mapD %= <<{[1:1:E1]} -> 1*x+off1d, {[E1+1:1:E2]} -> 1*x+off2d, {[E2+1:1:E3]} -> 1*x+off3d + , {[E3+1:1:E4]} -> 1*x+off4d>>; + Emap %= <<{[1:1:E1]} -> 0*x+1, {[E1+1:1:E2], [E2+1:1:E3], [E3+1:1:E4]} -> 0*x+2>>; ) diff --git a/test/scc5.test b/test/scc5.test index ce7a6f9..e8ebc40 100644 --- a/test/scc5.test +++ b/test/scc5.test @@ -1,5 +1,5 @@ -// SCC test with a single long path, with small cycles -// between pairs of vertices +// SCC test with a long path in forward and backward +// directions N = 100000 @@ -11,31 +11,34 @@ E1 = 1 E2 = N-1+E1 E3 = N-1+E2 E4 = N-1+E3 +E5 = N-2+E4 off1b = r(V1, 1)-r(E1, 1) off2b = r(V3, 1)-r(E2, 1)-1 off3b = r(V2, 1)-r(E3, 1) off4b = r(V2, 1)-r(E4, 1) +off5b = r(V3, 1)-r(E5, 1)-1 off1d = r(V3, 1)-r(E1, 1)-N+1 off2d = r(V2, 1)-r(E2, 1) off3d = r(V3, 1)-r(E3, 1) off4d = r(V3, 1)-r(E4, 1)-1 +off5d = r(V2, 1)-r(E5, 1)-1 V %= {[1:1:V1], [V1+1:1:V2], [V2+1:1:V3]}; Vmap %= <<{[1:1:V1]} -> 0*x+1, {[V1+1:1:V2]} -> 0*x+2, {[V2+1:1:V3]} -> 0*x+3>>; mapB %= <<{[1:1:E1]} -> 1*x+off1b, {[E1+1:1:E2]} -> 1*x+off2b, {[E2+1:1:E3]} -> 1*x+off3b - , {[E3+1:1:E4]} -> 1*x+off4b>>; + , {[E3+1:1:E4]} -> 1*x+off4b, {[E4+1:1:E5]} -> 1*x+off5b>>; mapD %= <<{[1:1:E1]} -> 1*x+off1d, {[E1+1:1:E2]} -> 1*x+off2d, {[E2+1:1:E3]} -> 1*x+off3d - , {[E3+1:1:E4]} -> 1*x+off4d>>; -Emap %= <<{[1:1:E1]} -> 0*x+1, {[E1+1:1:E2], [E2+1:1:E3], [E3+1:1:E4]} -> 0*x+2>>; + , {[E3+1:1:E4]} -> 1*x+off4d, {[E4+1:1:E5]} -> 1*x+off5d>>; +Emap %= <<{[1:1:E1]} -> 0*x+1, {[E1+1:1:E2], [E2+1:1:E3], [E3+1:1:E4], [E4+1:1:E5]} -> 0*x+2>>; scc( - V %= {[1:1:V1], [V1+1:1:V2], [V2+1:1:V3]}; - Vmap %= <<{[1:1:V1]} -> 0*x+1, {[V1+1:1:V2]} -> 0*x+2, {[V2+1:1:V3]} -> 0*x+3>>; - mapB %= <<{[1:1:E1]} -> 1*x+off1b, {[E1+1:1:E2]} -> 1*x+off2b, {[E2+1:1:E3]} -> 1*x+off3b - , {[E3+1:1:E4]} -> 1*x+off4b>>; - mapD %= <<{[1:1:E1]} -> 1*x+off1d, {[E1+1:1:E2]} -> 1*x+off2d, {[E2+1:1:E3]} -> 1*x+off3d - , {[E3+1:1:E4]} -> 1*x+off4d>>; - Emap %= <<{[1:1:E1]} -> 0*x+1, {[E1+1:1:E2], [E2+1:1:E3], [E3+1:1:E4]} -> 0*x+2>>; +V %= {[1:1:V1], [V1+1:1:V2], [V2+1:1:V3]}; +Vmap %= <<{[1:1:V1]} -> 0*x+1, {[V1+1:1:V2]} -> 0*x+2, {[V2+1:1:V3]} -> 0*x+3>>; +mapB %= <<{[1:1:E1]} -> 1*x+off1b, {[E1+1:1:E2]} -> 1*x+off2b, {[E2+1:1:E3]} -> 1*x+off3b + , {[E3+1:1:E4]} -> 1*x+off4b, {[E4+1:1:E5]} -> 1*x+off5b>>; +mapD %= <<{[1:1:E1]} -> 1*x+off1d, {[E1+1:1:E2]} -> 1*x+off2d, {[E2+1:1:E3]} -> 1*x+off3d + , {[E3+1:1:E4]} -> 1*x+off4d, {[E4+1:1:E5]} -> 1*x+off5d>>; +Emap %= <<{[1:1:E1]} -> 0*x+1, {[E1+1:1:E2], [E2+1:1:E3], [E3+1:1:E4], [E4+1:1:E5]} -> 0*x+2>>; ) diff --git a/test/test1_matching.test b/test/test1_matching.test index 4bc9661..6558da9 100644 --- a/test/test1_matching.test +++ b/test/test1_matching.test @@ -1,12 +1,14 @@ -/* +/* Matching test originated from the following model +(the result is indicated with comments): + model Test1 constant Integer N = 100; Real a[N], b[N], x[N]; equation for i in 1:N loop - a[i] = 2 * x[i] - b[i]; - a[i] = 2 * b[i] - x[i]; - der(x[i]) = 1 - a[i]; + a[i] = 2 * x[i] - b[i]; // a[1:N] + a[i] = 2 * b[i] - x[i]; // b[1:N] + der(x[i]) = 1 - a[i]; // der(x[1:N]) end for; end Test1; */ diff --git a/test/test1_scc.test b/test/test1_scc.test index 4ea8ede..58d338f 100644 --- a/test/test1_scc.test +++ b/test/test1_scc.test @@ -1,17 +1,20 @@ -/* +/* Detection of algebraic loops (SCC) for the following +model, where the matching is indicated with comments +for each equation: + model Test1 - constant Integer N = 100; + constant Integer N = 100000; Real a[N], b[N], x[N]; equation for i in 1:N loop - a[i] = 2 * x[i] - b[i]; - a[i] = 2 * b[i] - x[i]; - der(x[i]) = 1 - a[i]; + a[i] = 2 * x[i] - b[i]; // a[1:N] + a[i] = 2 * b[i] - x[i]; // b[N:N] + der(x[i]) = 1 - a[i]; // der(x[1:N]) end for; end Test1; */ -N = 10 +N = 100000 F1 = N F2 = N+F1 diff --git a/test/test2_matching.test b/test/test2_matching.test index ae04e0f..f6a8abe 100644 --- a/test/test2_matching.test +++ b/test/test2_matching.test @@ -1,7 +1,9 @@ -/* +/* Matching test originated from the following model +(the result is indicated with comments): + model Test2 //Model with possibly wrong initial matching - constant Integer N = 100; + constant Integer N = 100000; Real a[N], x[N], b[N]; equation for i in 2:N-1 loop diff --git a/test/test2_scc.test b/test/test2_scc.test index b4f84b9..f2183e6 100644 --- a/test/test2_scc.test +++ b/test/test2_scc.test @@ -1,7 +1,10 @@ -/* +/* Detection of algebraic loops (SCC) for the following +model, where the matching is indicated with comments +for each equation: + model Test2 //Model with possibly wrong initial matching - constant Integer N = 100; + constant Integer N = 100000; Real a[N], x[N], b[N]; equation for i in 2:N-1 loop diff --git a/test/test3_matching.test b/test/test3_matching.test index 1e7937f..8871c6f 100644 --- a/test/test3_matching.test +++ b/test/test3_matching.test @@ -1,6 +1,8 @@ -/* +/* Matching test originated from the following model +(the result is indicated with comments): + model Test3 - constant Integer N = 100; + constant Integer N = 100000; Real a[N], x[N], b[N]; equation for i in 2:N-1 loop @@ -17,7 +19,7 @@ equation end Test3; */ -N = 1000000 +N = 100000 F1 = N-2 F2 = N-2+F1 diff --git a/test/test3_scc.test b/test/test3_scc.test index ecf7430..8c1218b 100644 --- a/test/test3_scc.test +++ b/test/test3_scc.test @@ -1,6 +1,9 @@ -/* +/* Detection of algebraic loops (SCC) for the following +model, where the matching is indicated with comments +for each equation: + model Test3 - constant Integer N = 100; + constant Integer N = 100000; Real a[N], x[N], b[N]; equation for i in 2:N-1 loop diff --git a/util/Makefile.include b/util/Makefile.include index a00ca09..66f9cec 100755 --- a/util/Makefile.include +++ b/util/Makefile.include @@ -4,8 +4,7 @@ UTIL_DIR := util # Sources UTIL_SRC := \ $(UTIL_DIR)/defs.cpp \ - $(UTIL_DIR)/logger.cpp \ - $(UTIL_DIR)/debug.cpp + $(UTIL_DIR)/logger.cpp # Objects UTIL_OBJ=$(addprefix $(BUILD_DIR)/, $(UTIL_SRC:.cpp=.o)) diff --git a/util/UTIL.doxyfile b/util/UTIL.doxyfile index 157b503..fc60647 100755 --- a/util/UTIL.doxyfile +++ b/util/UTIL.doxyfile @@ -38,7 +38,7 @@ PROJECT_NAME = "Util Library" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.0.0 +PROJECT_NUMBER = 3.0.0 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/util/debug.cpp b/util/debug.cpp index 1ae429f..a0bcaed 100755 --- a/util/debug.cpp +++ b/util/debug.cpp @@ -25,117 +25,6 @@ namespace SBG { namespace Util { -// controls which DEBUG messages are printed -static const char *enableFlags = NULL; - -void debugInit(const char *flagList) { enableFlags = flagList; } - -bool debugIsEnabled(char flag) -{ - if (enableFlags != NULL) - return (strchr(enableFlags, flag) != 0) || (strchr(enableFlags, '+') != 0); - else - return false; -} - -void DEBUG(char flag, const char *format, ...) -{ - if (debugIsEnabled(flag)) { - va_list ap; - va_start(ap, format); - vfprintf(stdout, format, ap); - fflush(stdout); - va_end(ap); - } -} - -bool isDebugParam(char *param) -{ - if (strcmp(param, "c") == 0) { - return true; - } - if (strcmp(param, "a") == 0) { - return true; - } - if (strcmp(param, "s") == 0) { - return true; - } - if (strcmp(param, "g") == 0) { - return true; - } - return false; -} - -void ERROR(const char *format, ...) -{ - va_list ap; - va_start(ap, format); - const char *error_string = "Error: "; - char *new_format - = new char[sizeof(char) * strlen(error_string) + strlen(format) + 1]; - strcpy(new_format, error_string); - strcat(new_format, format); - vfprintf(stderr, new_format, ap); - fprintf(stderr, "\n"); - fflush(stderr); - va_end(ap); - delete[] new_format; - exit(EXIT_FAILURE); -} - -void SBG_ERROR(const char *format, ...) -{ - va_list ap; - va_start(ap, format); - const char *error_string = "Error: "; - char *new_format - = new char[sizeof(char) * strlen(error_string) + strlen(format) + 1]; - strcpy(new_format, error_string); - strcat(new_format, format); - vfprintf(stderr, new_format, ap); - fprintf(stderr, "\n"); - fflush(stderr); - va_end(ap); - delete[] new_format; - exit(EXIT_FAILURE); -} - -void ERROR_UNLESS(bool condition, const char *format, ...) -{ - if (!condition) { - va_list ap; - va_start(ap, format); - ERROR(format, ap); - va_end(ap); - } -} - -void WARNING(const char *format, ...) -{ - va_list ap; - va_start(ap, format); - const char *error_string = "Warning: "; - char *new_format - = new char[sizeof(char) * strlen(error_string) + strlen(format) + 1]; - strcpy(new_format, error_string); - strcat(new_format, format); - vfprintf(stderr, new_format, ap); - fprintf(stderr, "\n"); - fflush(stderr); - delete[] new_format; - va_end(ap); -} - -void WARNING_UNLESS(bool condition, const char *format, ...) -{ - if (!condition) { - va_list ap; - va_start(ap, format); - WARNING(format, ap); - va_end(ap); - } -} - } // namespace Util } // namespace SBG diff --git a/util/debug.hpp b/util/debug.hpp index 2baec97..a1cbba6 100755 --- a/util/debug.hpp +++ b/util/debug.hpp @@ -36,46 +36,29 @@ namespace SBG { namespace Util { -/** - * Initialize so that only DEBUG messages with a flag in flagList - * will be printed. - * - * If the flag is "+", we enable all DEBUG messages. - * - * "flagList" is a string of characters for whose DEBUG messages are to be - * enabled. - */ -void debugInit(const char *flags); - -/** - * Print an INFO debug message, if flag is enabled. - **/ -void DEBUG(char flag, const char *format, ...); - -bool isDebugParam(char *param); -bool debugIsEnabled(char); - /* * Print an ERROR message. Then exits with EXIT_FAILURE status. - */ -void ERROR(const char *format, ...); +*/ +template +void ERROR(Args... args) +{ + (std::cerr << "ERROR>>" << ... << args); + exit(EXIT_FAILURE); +} + /** * Print an ERROR message if condition is false. * Then exits with EXIT_FAILURE status. */ -void ERROR_UNLESS(bool condition, const char *format, ...); - -/* - * Print an Warning message. - */ -void WARNING(const char *format, ...); - -/** - * Print a WARNING message if condition is false. - * Then continues with the execution. - */ -void WARNING_UNLESS(bool condition, const char *format, ...); +template +void ERROR_UNLESS(bool cond, Args... args) +{ + if (!cond) { + (std::cerr << "ERROR>>" << ... << args); + exit(EXIT_FAILURE); + } +} } // namespace Util diff --git a/util/defs.cpp b/util/defs.cpp index 267f2cb..6187a96 100755 --- a/util/defs.cpp +++ b/util/defs.cpp @@ -28,8 +28,8 @@ namespace Util { std::string toStr(NAT x) { return std::to_string(x); } MD_NAT::MD_NAT() : value_() {} -MD_NAT::MD_NAT(NAT x) : value_() { value_.emplace_back(x); } -MD_NAT::MD_NAT(unsigned int nmbr_copies, NAT x) : value_() { +MD_NAT::MD_NAT(const NAT &x) : value_() { value_.emplace_back(x); } +MD_NAT::MD_NAT(const unsigned int &nmbr_copies, const NAT &x) : value_() { for (unsigned int j = 0; j < nmbr_copies; j++) value_.emplace_back(x); } @@ -51,11 +51,6 @@ const NAT &MD_NAT::operator[](std::size_t n) const { return value_[n]; } bool MD_NAT::operator==(const MD_NAT &other) const { - ERROR_UNLESS( - arity() == other.arity() - , "Util::MD_NAT::operator==: dimensions don't match" - ); - return value_ == other.value_; } @@ -63,11 +58,6 @@ bool MD_NAT::operator!=(const MD_NAT &other) const { return !(*this == other); } bool MD_NAT::operator<(const MD_NAT &other) const { - ERROR_UNLESS( - arity() == other.arity() - , "Util::MD_NAT::operator<: dimensions don't match" - ); - for (unsigned int j = 0; j < arity(); ++j) if (operator[](j) < other[j]) return true; @@ -123,9 +113,9 @@ std::size_t hash_value(const MD_NAT &n) // Rationals ------------------------------------------------------------------- RATIONAL::RATIONAL() : value_() {} -RATIONAL::RATIONAL(NAT n) : value_(boost::rational(n, 1)) {} -RATIONAL::RATIONAL(boost::rational value) : value_(value) {} -RATIONAL::RATIONAL(INT n, INT d) : value_() { +RATIONAL::RATIONAL(const NAT &n) : value_(boost::rational(n, 1)) {} +RATIONAL::RATIONAL(const boost::rational &value) : value_(value) {} +RATIONAL::RATIONAL(const INT &n, const INT &d) : value_() { boost::rational v(n, d); set_value(v); } @@ -229,9 +219,6 @@ NAT RATIONAL::toNat() const if (denominator() == 1 && 0 <= value_) return numerator(); - std::cerr << "ERROR>>RATIONAL::toNat: " << *this << " is not NAT\n"; - exit(1); - return 0; } @@ -240,7 +227,6 @@ INT RATIONAL::toInt() const if (denominator() == 1) return numerator(); - ERROR("toInt: RATIONAL is not INT"); return 0; } diff --git a/util/defs.hpp b/util/defs.hpp index d99b6ff..950859b 100755 --- a/util/defs.hpp +++ b/util/defs.hpp @@ -81,8 +81,8 @@ struct MD_NAT { member_class(VNAT, value); MD_NAT(); - MD_NAT(NAT x); - MD_NAT(unsigned int nmbr_copies, NAT x); + MD_NAT(const NAT &x); + MD_NAT(const unsigned int &nmbr_copies, const NAT &x); MD_NAT(VNAT::iterator b, VNAT::iterator e); typedef VNAT::iterator iterator; @@ -128,9 +128,9 @@ struct RATIONAL{ member_class(boost::rational, value); RATIONAL(); - RATIONAL(NAT n); - RATIONAL(boost::rational value); - RATIONAL(INT n, INT d); + RATIONAL(const NAT &n); + RATIONAL(const boost::rational &value); + RATIONAL(const INT &n, const INT &d); bool operator==(const RATIONAL &other) const; bool operator!=(const RATIONAL &other) const;