Skip to content

Commit 1535e52

Browse files
committed
Squashed commit of the following:
Release 3.0.0 commit aabb070 Author: kalashnikovni <denise.marzorati@gmail.com> Date: Wed Oct 9 11:13:50 2024 -0300 Updated eval interface commit c336451 Merge: c912a3e 7c01077 Author: kalashnikovni <denise.marzorati@gmail.com> Date: Mon Oct 7 22:04:41 2024 -0300 Update .gitignore commit c912a3e Author: kalashnikovni <denise.marzorati@gmail.com> Date: Mon Oct 7 22:00:46 2024 -0300 Updated test suite commit 7c01077 Author: joaquin.f.fernandez <joaquin.f.fernandez@gmail.com> Date: Fri Oct 4 10:40:24 2024 -0300 [iss-32] Squashed commit of the following: commit 4a1e95d Author: joaquin.f.fernandez <joaquin.f.fernandez@gmail.com> Date: Thu Oct 3 14:52:14 2024 -0300 Update file versions. commit 0597655 Author: joaquin.f.fernandez <joaquin.f.fernandez@gmail.com> Date: Thu Oct 3 11:59:22 2024 -0300 Updated gitignore. commit 13e3d56 Author: joaquin.f.fernandez <joaquin.f.fernandez@gmail.com> Date: Thu Oct 3 11:59:07 2024 -0300 Added deploy folder. commit 33bab6b Merge: 0a9a216 d17f487 Author: kalashnikovni <denise.marzorati@gmail.com> 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 <denise.marzorati@gmail.com> Date: Thu Oct 3 16:14:32 2024 -0300 Debugged SCC algorithm commit 21ac296 Author: kalashnikovni <denise.marzorati@gmail.com> Date: Thu Oct 3 16:14:13 2024 -0300 Erased debug info (performance) + Minor fixes commit ad71beb Author: kalashnikovni <denise.marzorati@gmail.com> Date: Thu Oct 3 16:13:13 2024 -0300 Encapsulation of interval commit 58ec0c6 Author: kalashnikovni <denise.marzorati@gmail.com> Date: Thu Oct 3 16:05:11 2024 -0300 Updated debugging info
1 parent d17f487 commit 1535e52

File tree

102 files changed

+1633
-1335
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+1633
-1335
lines changed

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
# Binary files
88
/bin
9+
/test/performance/boost/bin
10+
/test/performance/boost/obj
911

1012
# 3rd-party libraries.
1113
/3rd-party/gtest/usr/
@@ -33,4 +35,5 @@ Makefile
3335
/autom4te.cache
3436

3537
# Log files
36-
SBG.log
38+
*.log
39+

CHANGELOG.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Changelog
2+
3+
## [3.0.0] - 2024-10-09
4+
### Added
5+
- Implemented Ordered Sets of one-dimensional, compact MDIs.
6+
- Implemented novel versions of Maximum Matching, SCC and Topological Sort of SBG algorithms.
7+
- Implemented Minimum Vertex Cut Set SBG algorithm for Tearing.
8+
- Implemented JSON output for client code.
9+
10+
## [2.0.0] - 2023-06-05
11+
### Added
12+
- Implemented parser and pretty-printer for SBG structures.
13+
- Implemented Strongly Connected Components SBG algorithm for the detection of algebraic loops.
14+
- Implemented Topological Sort SBG algorithm for vertical equation ordering.
15+
16+
## [1.0.0] - 2022-04-04
17+
### Added
18+
- Implemented SBG structures.
19+
- Implemented Connected Components SBG algorithm for model flattening.
20+
- Implemented Maximum Matching SBG algorithm for horizontal equation ordering.

Makefile.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ doc:
8787
@mkdir -p $(ROOT)/doc/html
8888
@mkdir -p $(ROOT)/doc/latex
8989
doxygen sbg/SBG.doxyfile
90-
doxygen sbg/util/UTIL.doxyfile
90+
doxygen util/UTIL.doxyfile
9191

9292
test: lib-gtest $(SBG_TEST)
9393

README.md

+16-3
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,22 @@ Set-based graphs (SB-Graphs) are graphs in which the vertices and edges are grou
55
* Connected Components
66
* Matching
77
* Strongly Connected Components (SCC)
8+
* Topological Sort
9+
* Minimum Vertex Cut Set
810

911
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.
1012

1113
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.
1214

1315
## Related Publications
1416

15-
[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.
17+
[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
1618

17-
[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.
19+
[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.
1820

19-
[3] Pablo Zimmermann, Joaquin Fernandez, Ernesto Kofman.
21+
[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.
22+
23+
[4] Pablo Zimmermann, Joaquin Fernandez, Ernesto Kofman.
2024
**Set-based graph methods for fast equation sorting in large DAE systems**
2125
EOOLT '19: Proceedings of the 9th International Workshop on Equation-based Object-oriented Modeling Languages and Tools 2019
2226

@@ -110,3 +114,12 @@ Please see the file called LICENSE.
110114
## Bug Reporting
111115

112116
Report bugs to: marzorati@cifasis-conicet.gov.ar or fernandez@cifasis-conicet.gov.ar
117+
118+
# Changelog
119+
120+
## [3.0.0] - 2024-10-09
121+
### Added
122+
- Implemented Ordered Sets of one-dimensional, compact MDIs.
123+
- Implemented novel versions of Maximum Matching, SCC and Topological Sort of SBG algorithms.
124+
- Implemented Cut Set SBG algorithm for Tearing.
125+
- Implemented JSON output for client code.

ast/statement.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ ConfigDims::ConfigDims(Util::NAT nmbr_dims) : nmbr_dims_() {
4141
if (nmbr_dims > 0)
4242
set_nmbr_dims(nmbr_dims);
4343

44-
else Util::ERROR("AST::ConfigDims: Should have ate least one dimension");
44+
else
45+
Util::ERROR("ConfigDims: dimension should be greater than 0\n");
4546
}
4647

4748
member_imp(ConfigDims, Util::NAT, nmbr_dims);

deploy/linux/README.md

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
**Release procedure**
2+
3+
- Checkout `sb-graph-release` branch.
4+
- Create branch `release-X.X.X`.
5+
- Merge `sb-graph-dev` -> `sb-graph-release`.
6+
- Update `version` file to `X.X.X`.
7+
- Run `update.sh`.
8+
- Commit update changes with `-n`.
9+
- Update `CHANGELOG` and `README.md` files.
10+
- Commit changes with `-n`.
11+
- Push branch.
12+
- Merge pushed branch in `sb-graph-release` with `--squash`.
13+
- Push `sb-graph-release` branch.
14+
- Merge `sb-graph-release` in `sb-graph-dev`.
15+
16+
**Github Realease**
17+
18+
- Select Releases -> Draft a new release.
19+
- Choose the corresponding version tag of the new release.
20+
- Select sb-graph-release as the target branch.
21+
- Update release title and description.
22+
- Upload deb files.
23+
- Publish the release.

deploy/linux/build.sh

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
#!/bin/bash
2+
#===================================================================================
3+
#
4+
# FILE: build.sh
5+
#
6+
# USAGE: build.sh
7+
#
8+
# DESCRIPTION: Build the Linux deb package for Set Based Graph Library.
9+
#
10+
# PARAMETERS: ---
11+
# OPTIONS: ---
12+
# REQUIREMENTS: ---
13+
# NOTES: ---
14+
# AUTHOR: Joaquin Fernandez, joaquin.f.fernandez@gmail.com
15+
# PROJECT: Set Based Graph Library
16+
# VERSION: 3.0.0
17+
#===================================================================================
18+
19+
LIB_NAME=sb-graph-lib
20+
21+
rm -rf $LIB_NAME-*.deb
22+
23+
cd ../../
24+
ARCH=`uname -m`
25+
echo "Retrieving latest from Git";
26+
git pull
27+
28+
# Set library version
29+
VER=`cat ./deploy/linux/version`
30+
31+
# Set OS config files.
32+
CONTROL_FILE="control.amd64"
33+
PACKAGE_NAME=$LIB_NAME-$VER
34+
SYSTEM_VERSION=`lsb_release -d`
35+
if [[ "$SYSTEM_VERSION" == *"22.04"* ]]; then
36+
CONTROL_FILE="control.amd64.u22"
37+
PACKAGE_NAME=$PACKAGE_NAME-u22
38+
fi
39+
40+
# Set solver branch
41+
BRANCH=`git rev-parse --abbrev-ref HEAD`
42+
43+
# If build from development branch, update package name to unstable.
44+
if [ "$BRANCH" != "sb-graph-release" ]; then
45+
PACKAGE_NAME=$PACKAGE_NAME-unstable
46+
fi
47+
48+
PACKAGE_NAME=$PACKAGE_NAME.deb
49+
50+
echo "Building SB Graph DEB package for $ARCH version $VER";
51+
echo "Building Binaries";
52+
autoconf
53+
./configure
54+
make clean
55+
make
56+
57+
echo "Creating temp folders..."
58+
rm -rf tmp_deb
59+
rm -rf tmp
60+
mkdir tmp_deb
61+
mkdir tmp
62+
echo "Done."
63+
64+
echo "Export repo to temp folder..."
65+
CHECKOUT_PATH=./tmp/
66+
mkdir -p $CHECKOUT_PATH
67+
git checkout-index -a -f --prefix=$CHECKOUT_PATH
68+
echo "Done."
69+
70+
echo "Export tmp files to deb container..."
71+
72+
USER_FOLDER=usr
73+
INSTALL_FOLDER=$USER_FOLDER/local
74+
INCLUDE=include
75+
LIB=lib
76+
BIN=bin
77+
78+
cp -r ./deploy/linux/deb/* ./tmp_deb/
79+
chmod 0755 tmp_deb/DEBIAN/post*
80+
mkdir ./tmp_deb/$USER_FOLDER
81+
mkdir ./tmp_deb/$INSTALL_FOLDER
82+
mkdir ./tmp_deb/$INSTALL_FOLDER/$BIN
83+
mkdir ./tmp_deb/$INSTALL_FOLDER/$INCLUDE
84+
mkdir ./tmp_deb/$INSTALL_FOLDER/$INCLUDE/sb-graph
85+
mkdir ./tmp_deb/$INSTALL_FOLDER/$INCLUDE/sb-graph/ast
86+
mkdir ./tmp_deb/$INSTALL_FOLDER/$INCLUDE/sb-graph/eval
87+
mkdir ./tmp_deb/$INSTALL_FOLDER/$INCLUDE/sb-graph/parser
88+
mkdir ./tmp_deb/$INSTALL_FOLDER/$INCLUDE/sb-graph/sbg
89+
mkdir ./tmp_deb/$INSTALL_FOLDER/$INCLUDE/sb-graph/util
90+
mkdir ./tmp_deb/$INSTALL_FOLDER/$LIB
91+
92+
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
93+
rm ./tmp_deb/DEBIAN/$CONTROL_FILE
94+
95+
cp bin/sbg-eval ./tmp_deb/$INSTALL_FOLDER/$BIN
96+
cp bin/sbg-parser ./tmp_deb/$INSTALL_FOLDER/$BIN
97+
cp lib/libsbgraph.a ./tmp_deb/$INSTALL_FOLDER/$LIB
98+
cp -r ./tmp/ast/*.hpp ./tmp_deb/$INSTALL_FOLDER/$INCLUDE/sb-graph/ast
99+
cp -r ./tmp/eval/*.hpp ./tmp_deb/$INSTALL_FOLDER/$INCLUDE/sb-graph/eval
100+
cp -r ./tmp/parser/*.hpp ./tmp_deb/$INSTALL_FOLDER/$INCLUDE/sb-graph/parser
101+
cp -r ./tmp/sbg/*.hpp ./tmp_deb/$INSTALL_FOLDER/$INCLUDE/sb-graph/sbg
102+
cp -r ./tmp/util/*.hpp ./tmp_deb/$INSTALL_FOLDER/$INCLUDE/sb-graph/util
103+
104+
chmod 0644 `find tmp_deb/ -iname *.hpp`
105+
chmod 0755 `find tmp_deb/ -type d`
106+
fakeroot dpkg -b tmp_deb $LIB_NAME.deb
107+
mv $LIB_NAME.deb ./deploy/linux/$PACKAGE_NAME
108+
rm -rf tmp_deb
109+
rm -rf tmp
110+
cd deploy/linux

deploy/linux/deb/DEBIAN/control.amd64

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Package: sb-graph-lib
2+
Version:
3+
Architecture: amd64
4+
Maintainer: Denise Marzorati <marzorati@cifasis-conicet.gov.ar>
5+
Installed-Size: 801758
6+
Section: science
7+
Priority: extra
8+
Homepage: https://github.com/CIFASIS/sb-graph
9+
Description: Set Based Graph library.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Package: sb-graph-lib
2+
Version:
3+
Architecture: amd64
4+
Maintainer: Denise Marzorati <marzorati@cifasis-conicet.gov.ar>
5+
Installed-Size: 801758
6+
Section: science
7+
Priority: extra
8+
Homepage: https://github.com/CIFASIS/sb-graph
9+
Description: Set Based Graph library.

deploy/linux/deb/DEBIAN/postinst

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
# End automatically added section

deploy/linux/deb/DEBIAN/postrm

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
# Automatically added by dh_installmenu
3+
# End automatically added section

deploy/linux/update-version.sh

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
#===================================================================================
3+
#
4+
# FILE: update-version.sh
5+
#
6+
# USAGE: update-version.sh
7+
#
8+
# DESCRIPTION: Helper script to update version info in all project related files.
9+
#
10+
# PARAMETERS: ---
11+
# OPTIONS: ---
12+
# REQUIREMENTS: ---
13+
# NOTES: ---
14+
# AUTHOR: Joaquin Fernandez, joaquin.f.fernandez@gmail.com
15+
# PROJECT: Set Based Graph Library
16+
#===================================================================================
17+
18+
VER=`cat ./version`
19+
20+
# Update deploy files.
21+
sed -i "s/VERSION:.*/VERSION: $VER/" ./build.sh
22+
23+
# Update doxyfiles.
24+
sed -i "s/PROJECT_NUMBER =.*/PROJECT_NUMBER = $VER/" ../../sbg/SBG.doxyfile
25+
sed -i "s/PROJECT_NUMBER =.*/PROJECT_NUMBER = $VER/" ../../util/UTIL.doxyfile
26+
27+
# Update main bynary files version.
28+
sed -i "s/SBG library v.*/SBG library v$VER\" << std::endl;/" ../../parser/main.cpp
29+
sed -i "s/SBG library v.*/SBG library v$VER\" << std::endl;/" ../../eval/main.cpp

deploy/linux/version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.0.0

eval/Makefile.include

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ EVAL := bin/sbg-eval
1010
all: $(EVAL)
1111

1212
EVAL_SRC := \
13-
$(UTIL_DIR)/debug.cpp \
1413
$(UTIL_DIR)/defs.cpp \
1514
$(UTIL_DIR)/logger.cpp \
1615
$(EVAL_DIR)/main.cpp \

eval/defs.cpp

+14-13
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ namespace SBG {
2323

2424
namespace Eval {
2525

26+
using Util::operator<<;
27+
2628
// Environments ----------------------------------------------------------------
2729

2830
VarEnv::VarEnv() : mapping_() {}
@@ -41,11 +43,11 @@ MaybeVValue VarEnv::operator[](VKey k) const
4143

4244
FuncEnv::FuncEnv() {}
4345
FuncEnvType FuncEnv::mapping_ = {
44-
{"isEmpty", 0}, {"isMember", 1}, {"minElem", 2}, {"maxElem", 3}, {"lt", 4}
45-
, {"compose", 5}, {"inv", 6}, {"image", 7}, {"preImage", 8}, {"dom", 9}
46-
, {"combine", 10}, {"firstInv", 11}, {"minMap", 12}, {"reduce", 13}
47-
, {"minAdj", 14}, {"mapInf", 15}, {"CC", 16}, {"matching", 17}, {"scc", 18}
48-
, {"sort", 19}, {"matchSCC", 20}, {"matchSCCTS", 21}, {"cut", 22}
46+
{"isEmpty", 0}, {"minElem", 1}, {"maxElem", 2}
47+
, {"compose", 3}, {"inv", 4}, {"image", 5}, {"preImage", 6}, {"dom", 7}
48+
, {"combine", 8}, {"firstInv", 9}, {"minMap", 10}, {"reduce", 11}
49+
, {"minAdj", 12}, {"mapInf", 13}, {"CC", 14}, {"matching", 15}, {"scc", 16}
50+
, {"sort", 17}, {"matchSCC", 18}, {"matchSCCTS", 19}, {"cut", 20}
4951
};
5052

5153
MaybeFValue FuncEnv::operator[](FKey k) const
@@ -57,21 +59,20 @@ MaybeFValue FuncEnv::operator[](FKey k) const
5759
// Classes for pretty printing ------------------------------------------------
5860

5961
template<typename T, typename... Ts>
60-
std::ostream& operator<<(std::ostream& os, const std::variant<T, Ts...>& v)
62+
std::ostream &operator<<(std::ostream &out, const std::variant<T, Ts...> &v)
6163
{
62-
std::visit([&os](auto&& arg) {
63-
os << arg;
64-
}, v);
65-
return os;
64+
std::visit([&out](auto&& arg) {
65+
out << arg;
66+
}, v);
67+
68+
return out;
6669
}
6770

6871
std::ostream &operator<<(std::ostream &out, const ExprEval &e)
6972
{
7073
out << std::get<0>(e) << "\n --> ";
7174
ExprBaseType ebt = std::get<1>(e);
72-
auto printer = [&](auto v) { out << v; };
73-
std::visit(printer, ebt);
74-
out << "\n";
75+
out << ebt << "\n";
7576

7677
return out;
7778
}

eval/defs.hpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,15 @@ struct FuncEnv{
121121
static FuncEnvType mapping_;
122122
};
123123

124-
typedef enum { empty, member, min, max, lt, comp, inv, im, preim, dom, comb
124+
typedef enum { empty, min, max, comp, inv, im, preim, dom, comb
125125
, first_inv, min_map, red, min_adj, inf, connected, matching, scc, ts
126126
, match_scc, match_scc_ts, cut_set } Func;
127127

128128
// Classes for pretty printing ------------------------------------------------
129129

130+
template<typename T, typename... Ts>
131+
std::ostream &operator<<(std::ostream &out, const std::variant<T, Ts...> &v);
132+
130133
typedef std::tuple<AST::Expr, ExprBaseType> ExprEval;
131134
std::ostream &operator<<(std::ostream &out, const ExprEval &e);
132135
typedef std::vector<ExprEval> ExprEvalList;

0 commit comments

Comments
 (0)