Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion python/htps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3169,6 +3169,10 @@ static PyObject *PyHTPS_is_done(PyHTPS *self, PyObject *Py_UNUSED(ignored)) {
return res;
}

static PyObject *PyHTPS_expansions(PyHTPS *self, void *closure) {
return PyLong_FromSize_t(self->graph.num_expansions());
}

static void PyHTPS_dealloc(PyHTPS *self) {
self->graph.~HTPS();
Py_TYPE(self)->tp_free((PyObject *) self);
Expand Down Expand Up @@ -3217,6 +3221,11 @@ static PyObject *PyHTPS_from_jsonstr(PyTypeObject *type, PyObject *args) {
}
}

static PyGetSetDef HTPS_getsetters[] = {
{"expansions", (getter) PyHTPS_expansions, NULL, "Number of expansions", NULL},
{NULL}
};

static PyMethodDef HTPS_methods[] = {
{"theorems_to_expand", (PyCFunction) PyHTPS_theorems_to_expand, METH_NOARGS, "Returns a list of subsequent theorems to expand"},
{"expand_and_backup", (PyCFunction) PyHTPS_expand_and_backup, METH_VARARGS, "Expands and backups using the provided list of EnvExpansion objects"},
Expand Down Expand Up @@ -3258,7 +3267,7 @@ static PyTypeObject HTPSType = {
NULL,
HTPS_methods,
NULL,
NULL,
HTPS_getsetters,
NULL,
NULL,
NULL,
Expand Down
4 changes: 4 additions & 0 deletions src/graph/htps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1425,6 +1425,10 @@ void HTPS::set_params(const htps_params &new_params) {
policy = std::make_shared<Policy>(params.policy_type, params.exploration);
}

size_t HTPS::num_expansions() const {
return expansion_count;
}

HTPS HTPS::from_json(const nlohmann::json &j) {
HTPS htps;
htps.root = j["root"];
Expand Down
2 changes: 2 additions & 0 deletions src/graph/htps.h
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,8 @@ namespace htps {
explicit operator nlohmann::json() const;

htps::htps_params get_params() const;

size_t num_expansions() const;
};

}
Expand Down