Skip to content

Commit

Permalink
✨ Option for efficient determination of non-operational status (#602)
Browse files Browse the repository at this point in the history
* ✨ function to determine efficiently if the layout is non-operational.

* 📝 Update pyfiction docstrings

Signed-off-by: GitHub Actions <actions@github.com>

* 🎨 Incorporated pre-commit fixes

* 📝 updated changelog.rst

* 🎨 small fix.

* 📝 Update pyfiction docstrings

Signed-off-by: GitHub Actions <actions@github.com>

* 🎨 small fix.

* 🎨 Incorporated pre-commit fixes

* 📝 small fix.

* 📝 small fix.

* ⚗️ small change.

* 📝 small fix.

* 🎨 Incorporated pre-commit fixes

* 🎨 small fix.

* 📝 add docu.

* 🎨 small fix.

* 🎨 Incorporated pre-commit fixes

* 🎨 small fix.

* ✅ small update.

* 🎨 Incorporated pre-commit fixes

* 📝 Update pyfiction docstrings

Signed-off-by: GitHub Actions <actions@github.com>

* 🎨 implement Marcel's comments and restructure code

* 📝 Update pyfiction docstrings

Signed-off-by: GitHub Actions <actions@github.com>

* 📝 update docu.

* 🐍 small fix.

* 📝 small fix.

* 📝 small fix.

* 📝 small fix.

* ✅ small fix.

* ✅ small fix.

* 🐍 small fix.

* 🎨 small fix.

* ✅ small fix.

* ✨ add feature to only use pruning strategies to approximate operation status.

* 📝 Update pyfiction docstrings

Signed-off-by: GitHub Actions <actions@github.com>

* 🎨 add comment.

* ✅ add more tests.

* 🎨 small restructuring.

* 📝 Update pyfiction docstrings

Signed-off-by: GitHub Actions <actions@github.com>

* 📝 Update pyfiction docstrings

Signed-off-by: GitHub Actions <actions@github.com>

* 🎨 small fix.

* 🎨 small restructure.

* 🎨 restructure.

* 📝 Update pyfiction docstrings

Signed-off-by: GitHub Actions <actions@github.com>

* 🎨 small fix.

* 🎨 small fix.

* ✅ revert changes.

* ✅ add further test to cover special case.

* 🎨 small updates.

* 📝 Update pyfiction docstrings

Signed-off-by: GitHub Actions <actions@github.com>

* 🚸 add experiment.

* 🎨 small fix.

* 🐛 fixed wrong cell type.

* 🐛 fixed wrong truth table for wire and inv.

* 🎨 several fixes.

* 🐛 fixed wrong cell type.

* 🐛 fix while loop.

* 🚸 update experiment.

* 🎨 fix quickexact after implementing clone function for cds.

* 📝 Update pyfiction docstrings

Signed-off-by: GitHub Actions <actions@github.com>

* 🎨 revert changes to avoid runtime change of QE.

* 📝 Update pyfiction docstrings

Signed-off-by: GitHub Actions <actions@github.com>

* 📝 minor changes.

* 📝 Update pyfiction docstrings

Signed-off-by: GitHub Actions <actions@github.com>

* ⚡ update benchmark results.

* ✅ change outdated test.

* 🐛 fix wrong setting in unit test. Windows CI should be fixed now.

* 🎨 update is_operational_impl constructor to control initialization of the input iterator.

* 📝 Update pyfiction docstrings

Signed-off-by: GitHub Actions <actions@github.com>

* ✅ small update of the test.

* 🎨 implement Marcel's feedback.

* 📝 Update pyfiction docstrings

Signed-off-by: GitHub Actions <actions@github.com>

* ✅ small change.

* 📝 small fix/update.

* ⚗️ update experiment.

* 🎨 add static_cast.

* 🎨 add assert.

* 🎨 increase consistency.

* 📝 Update pyfiction docstrings

Signed-off-by: GitHub Actions <actions@github.com>

* 📝 small fix.

* 📝 Update pyfiction docstrings

Signed-off-by: GitHub Actions <actions@github.com>

* ⚗️ add pruning runtime.

* ✅ add a small comment.

* ⚗️ update experiment after change.

* ✅ small bug fix.

* ⚗️ small rephrasing.

* ⚗️ small rephrasing.

* 📝 Update pyfiction docstrings

Signed-off-by: GitHub Actions <actions@github.com>

* 🎨 implement Marcel's feedback.

* 📝 Update pyfiction docstrings

Signed-off-by: GitHub Actions <actions@github.com>

* 🎨 use the previous version for the evaluate_output function.

* 📝 Update pyfiction docstrings

Signed-off-by: GitHub Actions <actions@github.com>

* 🎨 remove unused header.

* 🎨 solve missing renaming.

* 📝 Update pyfiction docstrings

Signed-off-by: GitHub Actions <actions@github.com>

* ✅ test same test.

* 🐛 fix bugs that occurred during merging.

---------

Signed-off-by: GitHub Actions <actions@github.com>
Co-authored-by: GitHub Actions <actions@github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Marcel Walter <marcel.walter@tum.de>
  • Loading branch information
4 people authored Jan 14, 2025
1 parent 9ff9b53 commit 7ba71fb
Show file tree
Hide file tree
Showing 35 changed files with 2,127 additions and 880 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Created by marcel on 21.11.23.
//

#ifndef PYFICTION_CAN_POSITIVE_CHARGE_OCCUR_HPP
#define PYFICTION_CAN_POSITIVE_CHARGE_OCCUR_HPP
#ifndef PYFICTION_CAN_POSITIVE_CHARGES_OCCUR_HPP
#define PYFICTION_CAN_POSITIVE_CHARGES_OCCUR_HPP

#include "pyfiction/documentation.hpp"
#include "pyfiction/types.hpp"
Expand Down Expand Up @@ -40,4 +40,4 @@ inline void can_positive_charges_occur(pybind11::module& m)

} // namespace pyfiction

#endif // PYFICTION_CAN_POSITIVE_CHARGE_OCCUR_HPP
#endif // PYFICTION_CAN_POSITIVE_CHARGES_OCCUR_HPP
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
#include "pyfiction/documentation.hpp"
#include "pyfiction/types.hpp"

#include <fiction/algorithms/simulation/sidb/detect_bdl_wires.hpp>
#include <fiction/algorithms/simulation/sidb/is_operational.hpp>

#include <pybind11/pybind11.h>
#include <pybind11/stl.h>

#include <optional>
#include <vector>

namespace pyfiction
{
Expand All @@ -26,23 +28,59 @@ void is_operational(pybind11::module& m)
{
namespace py = pybind11;

m.def("is_operational", &fiction::is_operational<Lyt, py_tt>, py::arg("lyt"), py::arg("spec"),
py::arg("params") = fiction::is_operational_params{}, py::arg("input_bdl_wire") = std::nullopt,
py::arg("output_bdl_wire") = std::nullopt, DOC(fiction_is_operational));

m.def("operational_input_patterns", &fiction::operational_input_patterns<Lyt, py_tt>, py::arg("lyt"),
py::arg("spec"), py::arg("params") = fiction::is_operational_params{},
m.def("is_operational",
py::overload_cast<const Lyt&, const std::vector<py_tt>&, const fiction::is_operational_params&>(
&fiction::is_operational<Lyt, py_tt>),
py::arg("lyt"), py::arg("spec"), py::arg("params") = fiction::is_operational_params{},
DOC(fiction_is_operational));

m.def("is_operational",
py::overload_cast<const Lyt&, const std::vector<py_tt>&, const fiction::is_operational_params&,
const std::vector<fiction::bdl_wire<Lyt>>&, const std::vector<fiction::bdl_wire<Lyt>>&,
const std::optional<Lyt>&>(&fiction::is_operational<Lyt, py_tt>),
py::arg("lyt"), py::arg("spec"), py::arg("params"), py::arg("input_bdl_wire"), py::arg("output_bdl_wire"),
py::arg("canvas_lyt") = std::nullopt, DOC(fiction_is_operational_2));

m.def("operational_input_patterns",
py::overload_cast<const Lyt&, const std::vector<py_tt>&, const fiction::is_operational_params&>(
&fiction::operational_input_patterns<Lyt, py_tt>),
py::arg("lyt"), py::arg("spec"), py::arg("params") = fiction::is_operational_params{},
DOC(fiction_operational_input_patterns));

m.def("is_kink_induced_non_operational", &fiction::is_kink_induced_non_operational<Lyt, py_tt>, py::arg("lyt"),
py::arg("spec"), py::arg("params") = fiction::is_operational_params{},
py::arg("input_bdl_wire") = std::nullopt, py::arg("output_bdl_wire") = std::nullopt,
DOC(fiction_is_kink_induced_non_operational));
m.def("operational_input_patterns",
py::overload_cast<const Lyt&, const std::vector<py_tt>&, const fiction::is_operational_params&,
const std::vector<fiction::bdl_wire<Lyt>>&, const std::vector<fiction::bdl_wire<Lyt>>&,
const std::optional<Lyt>&>(&fiction::operational_input_patterns<Lyt, py_tt>),
py::arg("lyt"), py::arg("spec"), py::arg("params") = fiction::is_operational_params{},
py::arg("input_bdl_wire"), py::arg("output_bdl_wire"), py::arg("canvas_lyt") = std::nullopt,
DOC(fiction_operational_input_patterns_2));

m.def("kink_induced_non_operational_input_patterns",
&fiction::kink_induced_non_operational_input_patterns<Lyt, py_tt>, py::arg("lyt"), py::arg("spec"),
py::arg("params") = fiction::is_operational_params{},
py::overload_cast<const Lyt&, const std::vector<py_tt>&, const fiction::is_operational_params&>(
&fiction::kink_induced_non_operational_input_patterns<Lyt, py_tt>),
py::arg("lyt"), py::arg("spec"), py::arg("params") = fiction::is_operational_params{},
DOC(fiction_kink_induced_non_operational_input_patterns));

m.def(
"kink_induced_non_operational_input_patterns",
py::overload_cast<const Lyt&, const std::vector<py_tt>&, const fiction::is_operational_params&,
const std::vector<fiction::bdl_wire<Lyt>>&, const std::vector<fiction::bdl_wire<Lyt>>&,
const std::optional<Lyt>&>(&fiction::kink_induced_non_operational_input_patterns<Lyt, py_tt>),
py::arg("lyt"), py::arg("spec"), py::arg("params"), py::arg("input_bdl_wire"), py::arg("output_bdl_wire"),
py::arg("canvas_lyt") = std::nullopt, DOC(fiction_kink_induced_non_operational_input_patterns_2));

m.def("is_kink_induced_non_operational",
py::overload_cast<const Lyt&, const std::vector<py_tt>&, const fiction::is_operational_params&>(
&fiction::is_kink_induced_non_operational<Lyt, py_tt>),
py::arg("lyt"), py::arg("spec"), py::arg("params") = fiction::is_operational_params{},
DOC(fiction_is_kink_induced_non_operational));

m.def("is_kink_induced_non_operational",
py::overload_cast<const Lyt&, const std::vector<py_tt>&, const fiction::is_operational_params&,
const std::vector<fiction::bdl_wire<Lyt>>&, const std::vector<fiction::bdl_wire<Lyt>>&,
const std::optional<Lyt>&>(&fiction::is_kink_induced_non_operational<Lyt, py_tt>),
py::arg("lyt"), py::arg("spec"), py::arg("params"), py::arg("input_bdl_wire"), py::arg("output_bdl_wire"),
py::arg("canvas_lyt") = std::nullopt, DOC(fiction_is_kink_induced_non_operational_2));
}

} // namespace detail
Expand All @@ -56,11 +94,12 @@ inline void is_operational(pybind11::module& m)
.value("NON_OPERATIONAL", fiction::operational_status::NON_OPERATIONAL,
DOC(fiction_operational_status_NON_OPERATIONAL));

py::enum_<fiction::operational_condition>(m, "operational_condition", DOC(fiction_operational_condition))
.value("TOLERATE_KINKS", fiction::operational_condition::TOLERATE_KINKS,
DOC(fiction_operational_condition_TOLERATE_KINKS))
.value("REJECT_KINKS", fiction::operational_condition::REJECT_KINKS,
DOC(fiction_operational_condition_REJECT_KINKS));
py::enum_<fiction::is_operational_params::operational_condition>(
m, "operational_condition", DOC(fiction_is_operational_params_operational_condition))
.value("TOLERATE_KINKS", fiction::is_operational_params::operational_condition::TOLERATE_KINKS,
DOC(fiction_is_operational_params_operational_condition_TOLERATE_KINKS))
.value("REJECT_KINKS", fiction::is_operational_params::operational_condition::REJECT_KINKS,
DOC(fiction_is_operational_params_operational_condition_REJECT_KINKS));

py::class_<fiction::is_operational_params>(m, "is_operational_params", DOC(fiction_is_operational_params))
.def(py::init<>())
Expand All @@ -71,7 +110,10 @@ inline void is_operational(pybind11::module& m)
.def_readwrite("input_bdl_iterator_params", &fiction::is_operational_params::input_bdl_iterator_params,
DOC(fiction_is_operational_params_input_bdl_iterator_params))
.def_readwrite("op_condition", &fiction::is_operational_params::op_condition,
DOC(fiction_is_operational_params_op_condition));
DOC(fiction_is_operational_params_op_condition))
.def_readwrite("strategy_to_analyze_operational_status",
&fiction::is_operational_params::strategy_to_analyze_operational_status,
DOC(fiction_is_operational_params_strategy_to_analyze_operational_status));

// NOTE be careful with the order of the following calls! Python will resolve the first matching overload!
detail::is_operational<py_sidb_100_lattice>(m);
Expand Down
Loading

0 comments on commit 7ba71fb

Please sign in to comment.