Skip to content

Commit

Permalink
added the oRatio executable, and moved the library into oRatioSolver..
Browse files Browse the repository at this point in the history
  • Loading branch information
riccardodebenedictis committed Oct 4, 2022
1 parent e85cf8d commit 36456f8
Show file tree
Hide file tree
Showing 27 changed files with 248 additions and 178 deletions.
12 changes: 10 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.0.0)
project(oRatio VERSION 0.1.0)
project(oRatioSolver VERSION 0.1.0)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand Down Expand Up @@ -38,6 +38,9 @@ GENERATE_EXPORT_HEADER(${PROJECT_NAME})
target_include_directories(${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>/include $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>/include/flaws $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>/include/types $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>/include/heuristics $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}> $<INSTALL_INTERFACE:>)
target_link_libraries(${PROJECT_NAME} PRIVATE ratioCore RiDDLe SeMiTONE json)

add_executable(oRatio src/exec/main.cpp)
target_link_libraries(oRatio PRIVATE oRatioSolver ratioCore RiDDLe SeMiTONE json)

message(STATUS "Temporal network type: ${TEMPORAL_NETWORK_TYPE}")
if(TEMPORAL_NETWORK_TYPE STREQUAL DL)
target_compile_definitions(${PROJECT_NAME} PRIVATE DL_TN)
Expand Down Expand Up @@ -92,9 +95,14 @@ endif()
install(
TARGETS ${PROJECT_NAME}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
install(
TARGETS oRatio
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install(
FILES ${RATIO_HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/oratio_export.h
FILES ${RATIO_HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/oratiosolver_export.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}
)
configure_package_config_file(src/${PROJECT_NAME}Config.cmake.in ${PROJECT_NAME}Config.cmake INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} PATH_VARS CMAKE_INSTALL_INCLUDEDIR)
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ once the building requirements are installed, move to a desired folder and clone
git clone --recurse-submodules https://github.com/ratioSolver/oRatio
```

finally, build oRatio
finally, build and install oRatio

```shell
mkdir build
cd build
cmake ..
make
sudo make install
```

### Building on OS X
Expand All @@ -62,13 +62,13 @@ The easiest way to install the building requirements on OS X consists in downloa
git clone --recurse-submodules https://github.com/ratioSolver/oRatio
```

finally, build oRatio
finally, build and install oRatio

```shell
mkdir build
cd build
cmake ..
make
sudo make install
```

### Building on Windows
Expand Down
2 changes: 1 addition & 1 deletion extern/core
Submodule core updated 2 files
+1 −0 CMakeLists.txt
+1 −1 extern/riddle
16 changes: 8 additions & 8 deletions include/causal_graph.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "oratio_export.h"
#include "oratiosolver_export.h"
#include "rational.h"
#include "lit.h"
#include <unordered_set>
Expand All @@ -26,7 +26,7 @@ namespace ratio::solver
friend class solver;

public:
ORATIO_EXPORT causal_graph();
ORATIOSOLVER_EXPORT causal_graph();
causal_graph(const causal_graph &orig) = delete;

inline solver &get_solver() const noexcept { return *slv; }
Expand All @@ -41,10 +41,10 @@ namespace ratio::solver
virtual semitone::rational get_estimated_cost(const resolver &) const noexcept { return semitone::rational::ZERO; }

protected:
ORATIO_EXPORT virtual void init(solver &s);
ORATIOSOLVER_EXPORT virtual void init(solver &s);

private:
ORATIO_EXPORT void check();
ORATIOSOLVER_EXPORT void check();

virtual void enqueue(flaw &) {}
virtual void propagate_costs(flaw &) {}
Expand All @@ -55,10 +55,10 @@ namespace ratio::solver

virtual void push() {}
virtual void pop() {}
ORATIO_EXPORT virtual void activated_flaw(flaw &f);
ORATIO_EXPORT virtual void negated_flaw(flaw &f);
ORATIO_EXPORT virtual void activated_resolver(resolver &r);
ORATIO_EXPORT virtual void negated_resolver(resolver &r);
ORATIOSOLVER_EXPORT virtual void activated_flaw(flaw &f);
ORATIOSOLVER_EXPORT virtual void negated_flaw(flaw &f);
ORATIOSOLVER_EXPORT virtual void activated_resolver(resolver &r);
ORATIOSOLVER_EXPORT virtual void negated_resolver(resolver &r);

protected:
void new_flaw(std::unique_ptr<flaw> f, const bool &enqueue = true) const noexcept;
Expand Down
8 changes: 4 additions & 4 deletions include/flaw.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "oratio_export.h"
#include "oratiosolver_export.h"
#include "lit.h"
#include "rational.h"
#include <vector>
Expand All @@ -17,7 +17,7 @@ namespace ratio::solver
friend class resolver;

public:
ORATIO_EXPORT flaw(solver &slv, std::vector<resolver *> causes, const bool &exclusive = false);
ORATIOSOLVER_EXPORT flaw(solver &slv, std::vector<resolver *> causes, const bool &exclusive = false);
flaw(const flaw &orig) = delete;
virtual ~flaw() = default;

Expand All @@ -31,7 +31,7 @@ namespace ratio::solver
inline semitone::rational get_estimated_cost() const noexcept { return est_cost; }
inline bool is_expanded() const noexcept { return expanded; }

ORATIO_EXPORT resolver *get_cheapest_resolver() const noexcept;
ORATIOSOLVER_EXPORT resolver *get_cheapest_resolver() const noexcept;
virtual resolver *get_best_resolver() const noexcept { return get_cheapest_resolver(); }

virtual json::json get_data() const noexcept = 0;
Expand Down Expand Up @@ -70,5 +70,5 @@ namespace ratio::solver
};

inline uintptr_t get_id(const flaw &f) noexcept { return reinterpret_cast<uintptr_t>(&f); }
ORATIO_EXPORT json::json to_json(const flaw &rhs) noexcept;
ORATIOSOLVER_EXPORT json::json to_json(const flaw &rhs) noexcept;
} // namespace ratio::solver
8 changes: 4 additions & 4 deletions include/flaws/atom_flaw.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace ratio::solver
inline ratio::core::atom &get_atom() const noexcept { return static_cast<ratio::core::atom &>(*atm); }
inline ratio::core::expr get_atom_expr() const noexcept { return atm; }

ORATIO_EXPORT json::json get_data() const noexcept override;
ORATIOSOLVER_EXPORT json::json get_data() const noexcept override;

private:
void compute_resolvers() override;
Expand All @@ -34,7 +34,7 @@ namespace ratio::solver
activate_fact(const semitone::lit &r, atom_flaw &f);
activate_fact(const activate_fact &that) = delete;

ORATIO_EXPORT json::json get_data() const noexcept override;
ORATIOSOLVER_EXPORT json::json get_data() const noexcept override;

private:
void apply() override;
Expand All @@ -47,7 +47,7 @@ namespace ratio::solver
activate_goal(const semitone::lit &r, atom_flaw &f);
activate_goal(const activate_goal &that) = delete;

ORATIO_EXPORT json::json get_data() const noexcept override;
ORATIOSOLVER_EXPORT json::json get_data() const noexcept override;

private:
void apply() override;
Expand All @@ -59,7 +59,7 @@ namespace ratio::solver
unify_atom(atom_flaw &atm_flaw, ratio::core::atom &trgt, const std::vector<semitone::lit> &unif_lits);
unify_atom(const unify_atom &that) = delete;

ORATIO_EXPORT json::json get_data() const noexcept override;
ORATIOSOLVER_EXPORT json::json get_data() const noexcept override;

private:
void apply() override;
Expand Down
4 changes: 2 additions & 2 deletions include/flaws/bool_flaw.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace ratio::solver
bool_flaw(solver &slv, std::vector<resolver *> causes, ratio::core::bool_item &b_itm);
bool_flaw(const bool_flaw &orig) = delete;

ORATIO_EXPORT json::json get_data() const noexcept override;
ORATIOSOLVER_EXPORT json::json get_data() const noexcept override;

private:
void compute_resolvers() override;
Expand All @@ -23,7 +23,7 @@ namespace ratio::solver
choose_value(semitone::rational cst, bool_flaw &bl_flaw, const semitone::lit &val);
choose_value(const choose_value &that) = delete;

ORATIO_EXPORT json::json get_data() const noexcept override;
ORATIOSOLVER_EXPORT json::json get_data() const noexcept override;

private:
void apply() override;
Expand Down
4 changes: 2 additions & 2 deletions include/flaws/disj_flaw.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace ratio::solver
disj_flaw(solver &slv, std::vector<resolver *> causes, std::vector<semitone::lit> lits);
disj_flaw(const disj_flaw &orig) = delete;

ORATIO_EXPORT json::json get_data() const noexcept override;
ORATIOSOLVER_EXPORT json::json get_data() const noexcept override;

private:
void compute_resolvers() override;
Expand All @@ -22,7 +22,7 @@ namespace ratio::solver
choose_lit(semitone::rational cst, disj_flaw &disj_flaw, const semitone::lit &p);
choose_lit(const choose_lit &that) = delete;

ORATIO_EXPORT json::json get_data() const noexcept override;
ORATIOSOLVER_EXPORT json::json get_data() const noexcept override;

private:
void apply() override;
Expand Down
4 changes: 2 additions & 2 deletions include/flaws/disjunction_flaw.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace ratio::solver
disjunction_flaw(solver &slv, std::vector<resolver *> causes, std::vector<std::unique_ptr<ratio::core::conjunction>> conjs);
disjunction_flaw(const disjunction_flaw &orig) = delete;

ORATIO_EXPORT json::json get_data() const noexcept override;
ORATIOSOLVER_EXPORT json::json get_data() const noexcept override;

private:
void compute_resolvers() override;
Expand All @@ -24,7 +24,7 @@ namespace ratio::solver
choose_conjunction(disjunction_flaw &disj_flaw, std::unique_ptr<ratio::core::conjunction> conj);
choose_conjunction(const choose_conjunction &that) = delete;

ORATIO_EXPORT json::json get_data() const noexcept override;
ORATIOSOLVER_EXPORT json::json get_data() const noexcept override;

private:
void apply() override;
Expand Down
4 changes: 2 additions & 2 deletions include/flaws/enum_flaw.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace ratio::solver
enum_flaw(solver &slv, std::vector<resolver *> causes, ratio::core::enum_item &v_itm);
enum_flaw(const enum_flaw &orig) = delete;

ORATIO_EXPORT json::json get_data() const noexcept override;
ORATIOSOLVER_EXPORT json::json get_data() const noexcept override;

private:
void compute_resolvers() override;
Expand All @@ -23,7 +23,7 @@ namespace ratio::solver
choose_value(semitone::rational cst, enum_flaw &enm_flaw, semitone::var_value &val);
choose_value(const choose_value &that) = delete;

ORATIO_EXPORT json::json get_data() const noexcept override;
ORATIOSOLVER_EXPORT json::json get_data() const noexcept override;

private:
void apply() override;
Expand Down
10 changes: 5 additions & 5 deletions include/resolver.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "oratio_export.h"
#include "oratiosolver_export.h"
#include "lit.h"
#include "rational.h"
#include <vector>
Expand All @@ -16,15 +16,15 @@ namespace ratio::solver
friend class flaw;

public:
ORATIO_EXPORT resolver(semitone::rational cost, flaw &eff);
ORATIO_EXPORT resolver(semitone::lit r, semitone::rational cost, flaw &eff);
ORATIOSOLVER_EXPORT resolver(semitone::rational cost, flaw &eff);
ORATIOSOLVER_EXPORT resolver(semitone::lit r, semitone::rational cost, flaw &eff);
resolver(const resolver &that) = delete;
virtual ~resolver() = default;

inline solver &get_solver() const noexcept { return slv; }
inline semitone::lit get_rho() const noexcept { return rho; }
inline semitone::rational get_intrinsic_cost() const noexcept { return intrinsic_cost; }
ORATIO_EXPORT semitone::rational get_estimated_cost() const noexcept;
ORATIOSOLVER_EXPORT semitone::rational get_estimated_cost() const noexcept;
inline flaw &get_effect() const noexcept { return effect; }
inline const std::vector<flaw *> &get_preconditions() const noexcept { return preconditions; }

Expand All @@ -47,5 +47,5 @@ namespace ratio::solver
};

inline uintptr_t get_id(const resolver &r) noexcept { return reinterpret_cast<uintptr_t>(&r); }
ORATIO_EXPORT json::json to_json(const resolver &rhs) noexcept;
ORATIOSOLVER_EXPORT json::json to_json(const resolver &rhs) noexcept;
} // namespace ratio::solver
Loading

0 comments on commit 36456f8

Please sign in to comment.