Skip to content

Commit

Permalink
[iss-71]
Browse files Browse the repository at this point in the history
Squashed commit of the following:

commit a832320
Author: joaquin.f.fernandez <[email protected]>
Date:   Wed Jul 3 14:04:43 2024 -0300

    [iss-75]
    Squashed commit of the following:

    commit d8125a1
    Author: joaquin.f.fernandez <[email protected]>
    Date:   Wed Jul 3 13:34:01 2024 -0300

        Keep causalize test empty rule.

    commit 4505341
    Author: joaquin.f.fernandez <[email protected]>
    Date:   Wed Jul 3 12:00:18 2024 -0300

        Update Doxyfile.

    commit e2c3069
    Author: joaquin.f.fernandez <[email protected]>
    Date:   Wed Jul 3 11:25:10 2024 -0300

        Update sbg causalization makefile.

    commit 283013e
    Author: joaquin.f.fernandez <[email protected]>
    Date:   Wed Jul 3 11:24:46 2024 -0300

        Fixed main makefile rules.

    commit 63d0cfe
    Author: joaquin.f.fernandez <[email protected]>
    Date:   Wed Jul 3 11:24:07 2024 -0300

        Restore connections id method call.

    commit be6e3a5
    Author: joaquin.f.fernandez <[email protected]>
    Date:   Wed Jul 3 11:23:17 2024 -0300

        Updated sbg 1.0.0 lib.

    commit 255c820
    Author: joaquin.f.fernandez <[email protected]>
    Date:   Tue Jul 2 14:11:55 2024 -0300

        p
         Please enter the commit message for your changes. Lines starting
        rkflow file.

    commit d75a3ca
    Author: joaquin.f.fernandez <[email protected]>
    Date:   Tue Jul 2 12:02:40 2024 -0300

        Update sbg boost include prefix.

    commit ba17343
    Author: joaquin.f.fernandez <[email protected]>
    Date:   Tue Jul 2 11:51:11 2024 -0300

        Update sbg implementation make rules.

    commit c3cf870
    Author: joaquin.f.fernandez <[email protected]>
    Date:   Tue Jul 2 11:50:37 2024 -0300

        Added rules for legacy sbg lib.

    commit 4d28eb9
    Author: joaquin.f.fernandez <[email protected]>
    Date:   Tue Jul 2 11:50:19 2024 -0300

        Add dummy main for sbg implementation.

    commit c762c23
    Author: joaquin.f.fernandez <[email protected]>
    Date:   Tue Jul 2 11:49:10 2024 -0300

        Fix flatter id method call.

    commit cb053b4
    Author: joaquin.f.fernandez <[email protected]>
    Date:   Tue Jul 2 11:48:51 2024 -0300

        Fix solve compilation error.

    commit 8ee5150
    Author: joaquin.f.fernandez <[email protected]>
    Date:   Tue Jul 2 11:48:10 2024 -0300

        Update flatter makefile.

    commit 1ac50c1
    Author: joaquin.f.fernandez <[email protected]>
    Date:   Tue Jul 2 11:04:46 2024 -0300

        Update gitignore.

    commit 3f9b537
    Author: joaquin.f.fernandez <[email protected]>
    Date:   Tue Jul 2 10:56:47 2024 -0300

        Update gitignore.

    commit 63e8ea7
    Author: joaquin.f.fernandez <[email protected]>
    Date:   Tue Jul 2 10:43:41 2024 -0300

        Added sbg version 1 for legacy code.

commit d625aa1
Author: joaquin.f.fernandez <[email protected]>
Date:   Tue Jul 2 10:33:39 2024 -0300

    Update config files.

commit 1ea268e
Author: joaquin.f.fernandez <[email protected]>
Date:   Tue Jul 2 10:29:34 2024 -0300

    Add/modified makefiles rules.

commit 8c95ced
Author: joaquin.f.fernandez <[email protected]>
Date:   Tue Jul 2 10:23:13 2024 -0300

    Updated gitignore.

commit 38dee92
Author: joaquin.f.fernandez <[email protected]>
Date:   Tue Jul 2 10:21:43 2024 -0300

    Added boost 1.81 source files.
  • Loading branch information
joaquinffernandez committed Jul 3, 2024
1 parent 8b75e93 commit 4a6458e
Show file tree
Hide file tree
Showing 12 changed files with 55 additions and 92 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ jobs:
sudo apt-get install g++
sudo apt-get install libginac-dev
sudo apt-get install make
sudo apt-get install rapidjson-dev
- name: Autoconf
working-directory: .
run: autoconf
Expand All @@ -33,7 +34,7 @@ jobs:

- name: SBG
working-directory: .
run: make update-lib-sbg repo_checkout=https
run: make update-sbg repo_checkout=https

- name: Build
working-directory: .
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ configure

# 3rd-party files.
/3rd-party/gtest/usr/*
/3rd-party/sbg/sb-graph-dev.tar.gz
/3rd-party/sbg/sb-graph-dev
/3rd-party/sbg/*.tar.gz
/3rd-party/sbg/sb-graph-1.0.0
/3rd-party/boost/boost-1.81.0/

# Test generated files.
/flatter/test/test_data/*
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"iostream": "cpp"
"iostream": "cpp",
"thread": "cpp"
}
}
Binary file added 3rd-party/boost/boost-1.81.0.tar.xz
Binary file not shown.
Binary file added 3rd-party/sbg/sb-graph-1.0.0.tar.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ EXCLUDE_SYMLINKS = NO
# against the file with absolute path, so to exclude all test directories
# for example use the pattern */test/*

EXCLUDE_PATTERNS =
EXCLUDE_PATTERNS = */3rd-party/*

# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
# (namespaces, classes, functions, etc.) that should be excluded from the
Expand Down
48 changes: 35 additions & 13 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,32 @@ AST_DIR := ast
PARSER_DIR := parser
SBG_LIB := sbg
SBG_DEV := sb-graph-dev
SBG_1_0_0 := sb-graph-1.0.0
BOOST_LIB_PATH := $(3RD_PARTY_DIR)/boost
BOOST_1_81 := boost-1.81.0
BOOST_1_81_LIB := $(BOOST_1_81).tar.xz
BOOST_1_81_INC := -I$(BOOST_LIB_PATH)/$(BOOST_1_81)/include


# Flags, Libraries and Includes
INCLUDES := -I. -I$(3RD_PARTY_DIR)/$(SBG_LIB)/$(SBG_DEV)/usr/include
CXXFLAGS := -std=c++17 -Wall -Werror -Wno-reorder -O3
SBG_LIB_DEV_INCLUDE := -I$(3RD_PARTY_DIR)/$(SBG_LIB)/$(SBG_DEV)/usr/include
SBG_LIB_1_0_0_INCLUDE := -I$(3RD_PARTY_DIR)/$(SBG_LIB)/$(SBG_1_0_0)/usr/include
INCLUDES := -I.
CXXFLAGS := -std=c++17 -Wall -Wno-reorder -O3
ifeq ($(MODE),Debug)
CXXFLAGS += -ggdb
endif
LIBMODELICA = lib/libmodelica.a
LIBS := -L./lib -L$(3RD_PARTY_DIR)/$(SBG_LIB)/$(SBG_DEV)/usr/lib -lsbgraph -lginac -lmodelica
LIBS := -L./lib -lginac -lmodelica
SBG_LIB_DEV_LINK := -L$(3RD_PARTY_DIR)/$(SBG_LIB)/$(SBG_DEV)/usr/lib -lsbgraph
SBG_LIB_1_0_0_LINK := -L$(3RD_PARTY_DIR)/$(SBG_LIB)/$(SBG_1_0_0)/usr/lib -lsbgraph

all: $(LIBMODELICA)

include antialias/Makefile.include
include mmo/Makefile.include
include flatter/Makefile.include
include causalize/Makefile.include
include test/causalize/Makefile.include

# Sources
COMMON_SRC := \
Expand All @@ -57,23 +66,36 @@ COMMON_SRC := \
COMMON_OBJ=$(addprefix $(BUILD_DIR)/, $(COMMON_SRC:.cpp=.o))

$(BUILD_DIR)/%.o : %.cpp
$(CC) $(INCLUDES) $(CXXFLAGS) -MM -MT $@ -MF $(patsubst %.o,%.d,$@) $<
$(CC) $(INCLUDES) -c $< -o $@ $(CXXFLAGS)
$(CC) $(INCLUDES) $(SBG_LIB_1_0_0_INCLUDE) $(CXXFLAGS) -MM -MT $@ -MF $(patsubst %.o,%.d,$@) $<
$(CC) $(INCLUDES) $(SBG_LIB_1_0_0_INCLUDE) -c $< -o $@ $(CXXFLAGS)

$(COMMON_OBJ): | create-folders

update-lib-sbg:
cd $(3RD_PARTY_DIR)/$(SBG_LIB); ./update.py --branch_name $(sbg_branch) --repo_checkout $(repo_checkout)
cd $(3RD_PARTY_DIR)/$(SBG_LIB); tar xvzf $(SBG_DEV).tar.gz
lib-boost:
ifeq ("$(wildcard $(BOOST_LIB_PATH)/$(BOOST_1_81))","")
cd $(BOOST_LIB_PATH); tar -xvf $(BOOST_1_81_LIB)
endif

lib-sbg:
update-sbg:
cd $(3RD_PARTY_DIR)/$(SBG_LIB); ./update.py --branch_name $(sbg_branch) --repo_checkout $(repo_checkout)
cd $(3RD_PARTY_DIR)/$(SBG_LIB); tar -zxvf $(SBG_DEV).tar.gz

lib-sbg: lib-boost
ifeq ("$(wildcard $(3RD_PARTY_DIR)/$(SBG_LIB)/$(SBG_1_0_0))","")
cd $(3RD_PARTY_DIR)/$(SBG_LIB); tar -zxvf $(SBG_1_0_0).tar.gz
cd $(3RD_PARTY_DIR)/$(SBG_LIB)/$(SBG_1_0_0); autoconf
cd $(3RD_PARTY_DIR)/$(SBG_LIB)/$(SBG_1_0_0); ./configure
cd $(3RD_PARTY_DIR)/$(SBG_LIB)/$(SBG_1_0_0); make
cd $(3RD_PARTY_DIR)/$(SBG_LIB)/$(SBG_1_0_0); mkdir -p usr
cd $(3RD_PARTY_DIR)/$(SBG_LIB)/$(SBG_1_0_0); make install prefix=./usr
endif
ifeq ("$(wildcard $(3RD_PARTY_DIR)/$(SBG_LIB)/$(SBG_DEV))","")
make update-lib-sbg
make update-sbg
endif
ifeq ($(build_sbg), True)
cd $(3RD_PARTY_DIR)/$(SBG_LIB)/$(SBG_DEV); autoconf
cd $(3RD_PARTY_DIR)/$(SBG_LIB)/$(SBG_DEV); autoconf
cd $(3RD_PARTY_DIR)/$(SBG_LIB)/$(SBG_DEV); ./configure
cd $(3RD_PARTY_DIR)/$(SBG_LIB)/$(SBG_DEV); make
cd $(3RD_PARTY_DIR)/$(SBG_LIB)/$(SBG_DEV); make boost_libdir=../../boost/$(BOOST_1_81)
cd $(3RD_PARTY_DIR)/$(SBG_LIB)/$(SBG_DEV); mkdir -p usr
cd $(3RD_PARTY_DIR)/$(SBG_LIB)/$(SBG_DEV); make install prefix=./usr
endif
Expand Down
12 changes: 8 additions & 4 deletions causalize/sbg_implementation/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,28 @@ all: $(CAUSALIZE_SBG)
# Sources
CAUSALIZE_SBG_SRC := \
$(CAUSALIZE_SBG_DIR)/main.cpp\
$(CAUSALIZE_SBG_DIR)/matching_graph_builder.cpp\
$(UTIL_DIR)/ast_visitors/matching_exps.cpp \
$(UTIL_DIR)/ast_visitors/pwl_map_values.cpp \
$(UTIL_DIR)/logger.cpp

# Objects
CAUSALIZE_SBG_OBJ=$(addprefix $(BUILD_DIR)/, $(CAUSALIZE_SBG_SRC:.cpp=.o))

$(BUILD_DIR)/$(CAUSALIZE_DIR)/sbg_implementation/%.o : $(CAUSALIZE_SBG_DIR)/%.cpp
$(CC) $(INCLUDES) $(BOOST_1_81_INC) $(SBG_LIB_DEV_INCLUDE) $(CXXFLAGS) -MM -MT $@ -MF $(patsubst %.o,%.d,$@) $<
$(CC) $(INCLUDES) $(BOOST_1_81_INC) $(SBG_LIB_DEV_INCLUDE) -c $< -o $@ $(CXXFLAGS)

create-folders::
@mkdir -p $(BUILD_DIR)/$(CAUSALIZE_DIR)/sbg_implementation

$(CAUSALIZE_SBG): $(CAUSALIZE_SBG_OBJ) $(CAUSALIZE_COMMON_OBJ) $(LIBMODELICA)
$(CXX) $(CXXFLAGS) $(INCLUDES) -o $(CAUSALIZE_SBG) $(CAUSALIZE_COMMON_OBJ) $(CAUSALIZE_SBG_OBJ) $(LIBS)
$(CXX) $(CXXFLAGS) $(INCLUDES) $(BOOST_1_81_INC) $(SBG_LIB_DEV_INCLUDE) -o $(CAUSALIZE_SBG) $(CAUSALIZE_COMMON_OBJ) $(CAUSALIZE_SBG_OBJ) $(LIBS) $(SBG_LIB_DEV_LINK)

# Disable the tests until we have the binary/API interface working.
$(CAUSALIZE_SBG_TEST):
@echo BUILDING CAUSALIZE TESTS
@cd causalize/sbg_implementation/test && $(MAKE) bin/test-causalize
# @cd causalize/sbg_implementation/test && $(MAKE) bin/test-causalize
@echo Done
@echo RUNNING CAUSALIZE TESTS
@cd causalize/sbg_implementation/test && $(MAKE) test-causalize
# @cd causalize/sbg_implementation/test && $(MAKE) test-causalize
@echo Done
64 changes: 0 additions & 64 deletions causalize/sbg_implementation/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,17 @@
#include <boost/variant/get.hpp>
#include <getopt.h>

#include <causalize/sbg_implementation/matching_graph_builder.h>
#include <mmo/mmo_class.h>
#include <parser/parser.h>
#include <util/ast_visitors/state_variables_finder.h>
#include <util/debug.h>
#include <util/logger.h>
//#include <sbg/graph_builders/matching_graph_builder.hpp>
#include <sbg/descs.hpp>
#include <sbg/graph_builders/order_graph_builder.hpp>
#include <sbg/graph_builders/scc_graph_builder.hpp>
#include <sbg/sbg.hpp>
#include <sbg/sbg_algorithms.hpp>
#include <sbg/sbg_printer.hpp>

using namespace std;
using namespace Modelica;
using namespace Modelica::AST;
using namespace Causalize;

void usage()
{
Expand All @@ -59,22 +52,6 @@ void version()
cout << "There is NO WARRANTY, to the extent permitted by law." << endl;
}

void print_result(MatchingStruct m, SCCStruct scc, OrderStruct o, VertexOrder vo)
{
SBG::IO::UndirectedConverter uc(m.g());
SBG::IO::GraphIO g_io = uc.convert_graph();
BOOST_FOREACH (Set s, vo) {
BOOST_FOREACH (MultiInterval mi, s.asets()) {
SBG::Set represented = scc.rmap().preImage(Set(mi));

SBG::IO::MatchingIO s_io = uc.convert_matching(represented);
std::cout << s_io << "\n";
}
}

return;
}

int main(int argc, char **argv)
{
int opt;
Expand Down Expand Up @@ -127,46 +104,5 @@ int main(int argc, char **argv)
StateVariablesFinder setup_state_var(mmo_class);
setup_state_var.findStateVariables();

MatchingGraphBuilder matching_graph_builder(mmo_class);

SBG::SBGraph matching_graph = matching_graph_builder.makeGraph();
SBG::GraphPrinter printer(matching_graph, 0);

printer.printGraph(output_path+mmo_class.name()+".dot");

MatchingStruct match(matching_graph);
pair<SBG::Set, bool> res = match.SBGMatching();

LOG << "\n" << matching_graph << "\n";
LOG << res.first << "\n";

SCCGraphBuilder scc_builder(match);
scc_builder.build();
DSBGraph scc_graph = scc_builder.result();
SCCStruct scc_struct(scc_graph);
PWLMap scc = scc_struct.SBGSCC();

LOG << scc_graph << "\n";
LOG << scc << "\n";

OrderGraphBuilder order_builder(scc_struct);
order_builder.build();
DSBGraph order_graph = order_builder.result();
OrderStruct order_struct(order_graph);
VertexOrder order = order_struct.order();

LOG << order_graph << "\n";
LOG << order << "\n";

SBG::IO::DirectedConverter dc(order_graph);
SBG::IO::GraphIO g_io = dc.convert_graph();
SBG::IO::VertexOrderIO order_io = dc.convert_vertex_order(order);

BOOST_FOREACH (SetVertexDesc vd, vertices(matching_graph)) {
SBG::SetVertex v = matching_graph[vd];
std::cout << v.id() << ": " << v.desc().text() << "\n";
}
std::cout << "\n";
print_result(match, scc_struct, order_struct, order);
return 0;
}
2 changes: 1 addition & 1 deletion flatter/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ create-folders::
@mkdir -p $(BUILD_DIR)/$(MMO_DIR)

$(FLATTER): $(FLATTER_OBJ) $(LIBMODELICA)
$(CXX) $(CXXFLAGS) $(INCLUDES) $(FLATTER_OBJ) -o $(FLATTER) $(LIBS)
$(CXX) $(CXXFLAGS) $(INCLUDES) $(SBG_LIB_1_0_0_INCLUDE) $(FLATTER_OBJ) -o $(FLATTER) $(LIBS) $(SBG_LIB_1_0_0_LINK)

$(FLATTER_TEST):
@echo BUILDING FLATTER TESTS
Expand Down
1 change: 1 addition & 0 deletions util/solve/solve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <fstream>
#include <set>
#include <algorithm>
#include <ginac/ginac.h>

#include <ast/queries.h>
#include <ast/equation.h>
Expand Down
6 changes: 1 addition & 5 deletions util/solve/solve.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,11 @@
along with Modelica C Compiler. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/

#ifndef SOLVE_H
#define SOLVE_H
#pragma once

#include <ast/equation.h>
#include <util/table.h>
#include <mmo/mmo_class.h>
#include <ginac/ginac.h>

using namespace Modelica::AST;
class EquationSolver {
Expand All @@ -33,4 +30,3 @@ class EquationSolver {
static Equation Solve(Equation eq, Expression exp, VarSymbolTable &syms, std::list<std::string> &c_code, ClassList &cl,
const std::string path);
};
#endif

0 comments on commit 4a6458e

Please sign in to comment.