Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
Release 3.0.0

commit aabb070
Author: kalashnikovni <[email protected]>
Date:   Wed Oct 9 11:13:50 2024 -0300

    Updated eval interface

commit c336451
Merge: c912a3e 7c01077
Author: kalashnikovni <[email protected]>
Date:   Mon Oct 7 22:04:41 2024 -0300

    Update .gitignore

commit c912a3e
Author: kalashnikovni <[email protected]>
Date:   Mon Oct 7 22:00:46 2024 -0300

    Updated test suite

commit 7c01077
Author: joaquin.f.fernandez <[email protected]>
Date:   Fri Oct 4 10:40:24 2024 -0300

    [iss-32]
    Squashed commit of the following:

    commit 4a1e95d
    Author: joaquin.f.fernandez <[email protected]>
    Date:   Thu Oct 3 14:52:14 2024 -0300

        Update file versions.

    commit 0597655
    Author: joaquin.f.fernandez <[email protected]>
    Date:   Thu Oct 3 11:59:22 2024 -0300

        Updated gitignore.

    commit 13e3d56
    Author: joaquin.f.fernandez <[email protected]>
    Date:   Thu Oct 3 11:59:07 2024 -0300

        Added deploy folder.

commit 33bab6b
Merge: 0a9a216 d17f487
Author: kalashnikovni <[email protected]>
Date:   Thu Oct 3 16:15:20 2024 -0300

    Merge branch 'sb-graph-dev' of https://github.com/CIFASIS/sb-graph into sb-graph-dev

commit 0a9a216
Author: kalashnikovni <[email protected]>
Date:   Thu Oct 3 16:14:32 2024 -0300

    Debugged SCC algorithm

commit 21ac296
Author: kalashnikovni <[email protected]>
Date:   Thu Oct 3 16:14:13 2024 -0300

    Erased debug info (performance) + Minor fixes

commit ad71beb
Author: kalashnikovni <[email protected]>
Date:   Thu Oct 3 16:13:13 2024 -0300

    Encapsulation of interval

commit 58ec0c6
Author: kalashnikovni <[email protected]>
Date:   Thu Oct 3 16:05:11 2024 -0300

    Updated debugging info
  • Loading branch information
Kalashnikovni committed Oct 9, 2024
1 parent d17f487 commit 1535e52
Show file tree
Hide file tree
Showing 102 changed files with 1,633 additions and 1,335 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

# Binary files
/bin
/test/performance/boost/bin
/test/performance/boost/obj

# 3rd-party libraries.
/3rd-party/gtest/usr/
Expand Down Expand Up @@ -33,4 +35,5 @@ Makefile
/autom4te.cache

# Log files
SBG.log
*.log

20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 1 addition & 1 deletion Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,22 @@ 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.

This new approach was used in the flatter and causalization stage of the Modelica compiler, ModelicaCC (https://github.com/CIFASIS/modelicacc). Nevertheless, many fields could benefit of its use.

## 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

Expand Down Expand Up @@ -110,3 +114,12 @@ Please see the file called LICENSE.
## Bug Reporting

Report bugs to: [email protected] or [email protected]

# 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.
3 changes: 2 additions & 1 deletion ast/statement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
23 changes: 23 additions & 0 deletions deploy/linux/README.md
Original file line number Diff line number Diff line change
@@ -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.
110 changes: 110 additions & 0 deletions deploy/linux/build.sh
Original file line number Diff line number Diff line change
@@ -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, [email protected]
# 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
9 changes: 9 additions & 0 deletions deploy/linux/deb/DEBIAN/control.amd64
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Package: sb-graph-lib
Version:
Architecture: amd64
Maintainer: Denise Marzorati <[email protected]>
Installed-Size: 801758
Section: science
Priority: extra
Homepage: https://github.com/CIFASIS/sb-graph
Description: Set Based Graph library.
9 changes: 9 additions & 0 deletions deploy/linux/deb/DEBIAN/control.amd64.u22
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Package: sb-graph-lib
Version:
Architecture: amd64
Maintainer: Denise Marzorati <[email protected]>
Installed-Size: 801758
Section: science
Priority: extra
Homepage: https://github.com/CIFASIS/sb-graph
Description: Set Based Graph library.
2 changes: 2 additions & 0 deletions deploy/linux/deb/DEBIAN/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
# End automatically added section
3 changes: 3 additions & 0 deletions deploy/linux/deb/DEBIAN/postrm
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
# Automatically added by dh_installmenu
# End automatically added section
29 changes: 29 additions & 0 deletions deploy/linux/update-version.sh
Original file line number Diff line number Diff line change
@@ -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, [email protected]
# 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
1 change: 1 addition & 0 deletions deploy/linux/version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0.0
1 change: 0 additions & 1 deletion eval/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
27 changes: 14 additions & 13 deletions eval/defs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ namespace SBG {

namespace Eval {

using Util::operator<<;

// Environments ----------------------------------------------------------------

VarEnv::VarEnv() : mapping_() {}
Expand All @@ -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
Expand All @@ -57,21 +59,20 @@ MaybeFValue FuncEnv::operator[](FKey k) const
// Classes for pretty printing ------------------------------------------------

template<typename T, typename... Ts>
std::ostream& operator<<(std::ostream& os, const std::variant<T, Ts...>& v)
std::ostream &operator<<(std::ostream &out, const std::variant<T, Ts...> &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;
}
Expand Down
5 changes: 4 additions & 1 deletion eval/defs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<typename T, typename... Ts>
std::ostream &operator<<(std::ostream &out, const std::variant<T, Ts...> &v);

typedef std::tuple<AST::Expr, ExprBaseType> ExprEval;
std::ostream &operator<<(std::ostream &out, const ExprEval &e);
typedef std::vector<ExprEval> ExprEvalList;
Expand Down
Loading

0 comments on commit 1535e52

Please sign in to comment.