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
8 changes: 8 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changes

## clinguin 2.7.5

* Fix bug:
* Not using explicit show when browsing solutions
* Features:
* The operation `next_solution` can now have an optimality timeout in seconds.


## clinguin 2.7.4

* New flags to improve performance
Expand Down
21 changes: 14 additions & 7 deletions clinguin/server/application/backends/clingo_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -1142,14 +1142,19 @@ def remove_atom(self, predicate):
self._ground()
self._outdate()

def next_solution(self, opt_mode="ignore"):
def next_solution(self, opt_mode="ignore", opt_timeout=None):
"""
Obtains the next solution. If a no browsing has been started yet, then it calls solve,
otherwise it iterates the models in the last call. To keep the atoms shown in the solution, use :func:`~select`.

Arguments:
opt_mode: The clingo optimization mode, bu default is 'ignore', to browse only optimal models use 'optN'
opt_timeout: The timeout in seconds to find an optimal solution. If not provided, the default timeout
provided in the command line is used. If no timeout is provided, it will wait until an optimal
solution is found. Otherwise, if the timeout is reached, it will return the current solution
without proving optimality.
"""
opt_timeout = int(opt_timeout) if opt_timeout is not None else None
if self._ctl.configuration.solve.opt_mode != opt_mode:
self._logger.debug("Ended browsing since opt mode changed")
self._outdate()
Expand All @@ -1176,7 +1181,9 @@ def next_solution(self, opt_mode="ignore"):
model = next(self._iterator)
self._clear_cache(["_ds_model"])
self._on_model(model)
self._model = model.symbols(shown=True, atoms=True, theory=True)
self._model = model.symbols(
shown=True, atoms=not self._explicit_show, theory=True
)
while optimizing and not model.optimality_proven:
if len(model.cost) == 0:
self._messages.append(
Expand All @@ -1187,10 +1194,8 @@ def next_solution(self, opt_mode="ignore"):
" in 'next_solution' operation. Exiting browsing."
)
break
if (
self._opt_timeout is not None
and time.time() - start > self._opt_timeout
):
timeout = opt_timeout if opt_timeout is not None else self._opt_timeout
if timeout is not None and time.time() - start > timeout:
self._logger.warning(
"Timeout for finding optimal model was reached. Returning model without proving optimality."
)
Expand All @@ -1200,7 +1205,9 @@ def next_solution(self, opt_mode="ignore"):
self._clear_cache(["_ds_model"])
self._on_model(model)

self._model = model.symbols(shown=True, atoms=True, theory=True)
self._model = model.symbols(
shown=True, atoms=not self._explicit_show, theory=True
)
except StopIteration:
if optimizing:
m = "No more optimal solutions"
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
author = "Susana Hahn, Alexander Beiser"

# The full version, including alpha/beta/rc tags
release = "2.7.4"
release = "2.7.5"

# -- General configuration ---------------------------------------------------

Expand Down
1 change: 1 addition & 0 deletions examples/angular/placement/encoding.lp
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@

% Least empty seats possible
#minimize{1@1,S,T:seat(S,T),assign(seat(_,T),_),not assign(seat(S,T),_)}.

1 change: 1 addition & 0 deletions examples/angular/placement/ui.lp
Original file line number Diff line number Diff line change
Expand Up @@ -256,3 +256,4 @@ attr(nav_container, class, ("d-flex";"flex-column")).
attr(m, message, "Optimality not proven"):- _clinguin_optimizing, not _clinguin_optimal.
attr(m, type, success):- _clinguin_optimizing, _clinguin_optimal.
attr(m, type, warning):- _clinguin_optimizing, not _clinguin_optimal.

2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = clinguin
version = 2.7.4
version = 2.7.5
author = Alexander Beiser, Susana Hahn (Potassco)
author_email = [email protected], [email protected]
description = An interactive visualizer for clingo
Expand Down
2 changes: 1 addition & 1 deletion tests/reference_json_output/health.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Health:
def get_reference_json(cls):
json_dict = {
"name": "clinguin",
"version": "2.7.4",
"version": "2.7.5",
"description": "An interactive visualizer for clingo",
}

Expand Down
Loading