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
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1432,6 +1432,7 @@ if(BUILD_TESTING)
Search::DFS::Sol::Binary::Nary::Binary::1::1::1)
if(GECODE_ENABLE_FLATZINC)
list(INSERT GECODE_CHECK_TESTS 1
FlatZinc::Options
FlatZinc::magic_square
FlatZinc::blackbox)
endif()
Expand Down
2 changes: 1 addition & 1 deletion Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -1363,7 +1363,7 @@ CHECKTESTS = Branch::Int::Dense::3 \
Set::Wait

ifeq "@enable_flatzinc@" "yes"
CHECKTESTS += FlatZinc::blackbox
CHECKTESTS += FlatZinc::Options FlatZinc::blackbox
BLACKBOXCHECKENV = \
GECODE_TEST_BLACKBOX_EXEC=$(abspath $(BLACKBOXEXEC)) \
GECODE_TEST_BLACKBOX_DLL=$(abspath $(BLACKBOXDLL)) \
Expand Down
10 changes: 10 additions & 0 deletions changelog.in
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,16 @@ Compute interval medians without overflowing at large positive or negative
bounds. Float search over an unbounded FlatZinc variable can otherwise fail to
make progress.

[ENTRY]
Module: flatzinc
What: bug
Rank: minor
Issue: 99
[DESCRIPTION]
Keep an explicitly selected Gist execution mode when FlatZinc statistics are
requested, and report an error instead of silently running in solution mode
when Gist support is unavailable.

[ENTRY]
Module: flatzinc
What: new
Expand Down
2 changes: 1 addition & 1 deletion gecode/flatzinc.hh
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ namespace Gecode { namespace FlatZinc {
if (_time_limit.value()) {
_time.value(_time_limit.value());
}
if (_stat.value())
if (_stat.value() && (_mode.value() == Gecode::SM_SOLUTION))
_mode.value(Gecode::SM_STAT);
}

Expand Down
5 changes: 5 additions & 0 deletions gecode/flatzinc/flatzinc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2039,6 +2039,11 @@ namespace Gecode { namespace FlatZinc {
void
FlatZincSpace::run(std::ostream& out, const Printer& p,
const FlatZincOptions& opt, Support::Timer& t_total) {
#ifndef GECODE_HAS_GIST
if (opt.mode() == SM_GIST)
throw FlatZinc::Error("FlatZinc",
"Gist mode is unavailable in this build");
#endif
switch (_method) {
case MIN:
case MAX:
Expand Down
37 changes: 37 additions & 0 deletions test/flatzinc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,43 @@ namespace Test { namespace FlatZinc {

TupleSetAutoRepresentation tuple_set_auto_representation;

/// Verify that statistics do not override an explicit Gist mode.
class GistStatisticsMode : public Base {
private:
static Gecode::ScriptMode mode(std::vector<std::string> args) {
Gecode::FlatZinc::FlatZincOptions opt("Gecode/FlatZinc");
std::string cmd("fzn-gecode");
int argc = static_cast<int>(args.size()) + 1;
std::vector<char*> argv(argc);
argv[0] = const_cast<char*>(cmd.data());
for (int i=1; i<argc; i++)
argv[i] = const_cast<char*>(args[i-1].data());
opt.parse(argc,argv.data());
return opt.mode();
}
public:
GistStatisticsMode(void)
: Base("FlatZinc::Options::GistStatisticsMode") {}

virtual bool run(void) {
return
(mode({"-s"}) == Gecode::SM_STAT) &&
(mode({"-mode", "gist", "-s"}) == Gecode::SM_GIST) &&
(mode({"-s", "-mode", "gist"}) == Gecode::SM_GIST);
}
};

GistStatisticsMode gist_statistics_mode;

#ifndef GECODE_HAS_GIST
/// Verify that unavailable Gist mode is rejected instead of running search.
FlatZincErrorTest gist_unavailable(
"Options::GistUnavailable",
"var 1..1: x :: output_var;\nsolve satisfy;\n",
{"-mode", "gist", "-s"},
"Gist mode is unavailable in this build");
#endif

}

FlatZincTest::FlatZincTest(const std::string& name, const std::string& source,
Expand Down
Loading