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
4 changes: 3 additions & 1 deletion .github/ci/generated-source-freshness.sh
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,9 @@ normalize_generated_whitespace() {
gecode/flatzinc/parser.tab.hpp; do
normalize_generated_whitespace "$output"
done
flex -ogecode/flatzinc/lexer.yy.cpp ./gecode/flatzinc/lexer.lxx
# Without #line directives, the output of upstream Flex 2.6.4 matches that
# of distribution builds that patch its line numbering.
flex -L -ogecode/flatzinc/lexer.yy.cpp ./gecode/flatzinc/lexer.lxx
)

generated_files=(
Expand Down
11 changes: 3 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,10 @@ jobs:
sudo apt-get update
sudo apt-get install -y flex bison libgmp-dev libmpfr-dev

- name: Install generated-source tools
if: runner.os == 'macOS'
shell: bash
run: |
# The freshness helper bootstraps the pinned Autoconf version itself.
brew install m4 bison flex

- name: Check generated source freshness
if: runner.os == 'macOS'
# Ubuntu LTS keeps Bison 3.8.2 and Flex 2.6.4, while Homebrew moves on.
# The freshness helper bootstraps the pinned Autoconf version itself.
if: runner.os == 'Linux'
shell: bash
run: bash .github/ci/generated-source-freshness.sh

Expand Down
2 changes: 1 addition & 1 deletion Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -1791,7 +1791,7 @@ ifeq "@HAVE_FLEXBISON@" "yes"
gecode/flatzinc/lexer.yy.cpp: \
$(top_srcdir)/gecode/flatzinc/lexer.lxx \
$(top_srcdir)/gecode/flatzinc/parser.tab.hpp | mkcompiledirs
flex -ogecode/flatzinc/lexer.yy.cpp \
flex -L -ogecode/flatzinc/lexer.yy.cpp \
$(top_srcdir)/gecode/flatzinc/lexer.lxx

gecode/flatzinc/parser.tab.hpp gecode/flatzinc/parser.tab.cpp: \
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ The tutorial *Modeling and Programming with Gecode* explains how to model
and solve problems with Gecode, and the reference documentation describes
the complete API.

For source-level breaking changes, see the
[Gecode 7 migration notes](docs/gecode-7-migration.md).

## Download Gecode

Gecode 6.5.0 is distributed as source code. Source archives can be downloaded from
Expand Down
10 changes: 10 additions & 0 deletions changelog.in
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ Date: unreleased
[DESCRIPTION]
This is the development changelog for the next Gecode release.

[ENTRY]
Module: search
What: change
Rank: major
[DESCRIPTION]
Rename the meta-search Space hooks master() and slave() to hub() and spoke().
[MORE]
There are no compatibility aliases. An old override marked override fails to
compile; one without it is never called. See docs/gecode-7-migration.md.

[ENTRY]
Module: search
What: change
Expand Down
41 changes: 41 additions & 0 deletions docs/gecode-7-migration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Gecode 7 migration notes

## Meta-search hooks: master() and slave() are now hub() and spoke()

Rename the overrides. Their signatures and return values are unchanged:

```cpp
// Gecode 6
bool master(const Gecode::MetaInfo& mi) override;
bool slave(const Gecode::MetaInfo& mi) override;

// Gecode 7
bool hub(const Gecode::MetaInfo& mi) override;
bool spoke(const Gecode::MetaInfo& mi) override;
```

There are no compatibility aliases. An old override marked `override` fails
to compile; one without it compiles but is never called. Restart-based search (RBS) and portfolio-based search
(PBS) call the renamed hooks at the same points and with the same defaults
as before.

The hooks run on these spaces:

- RBS calls `hub()` after each solution and at each restart. The hub
carries the last solution and the no-goods from one restart to the next.
RBS calls `spoke()` on each new spoke, a clone of the hub, including the
first. The default `hub()` constrains the hub with the last solution, if
any, and posts the no-goods.
- PBS calls `hub()` once, then calls `spoke()` with the asset number on the
spoke of each asset, the hub or a clone of it. The default `hub()`
removes all branchers, so `spoke()` must post the branching of each
asset.

The examples show typical overrides:

- `examples/crossword.cpp`: a `hub()` that posts no-goods and continues
after a solution instead of restarting.
- `examples/photo.cpp`: an RBS `spoke()` that relaxes the last solution for
large neighbourhood search.
- `examples/qcp.cpp`: a PBS `spoke()` that posts a different branching for
each asset.
2 changes: 1 addition & 1 deletion examples/crossword.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ class Crossword : public Script {
<< n;
}
/// Do not perform a restart when a solution is found
bool master(const MetaInfo& mi) {
bool hub(const MetaInfo& mi) {
if (mi.type() == MetaInfo::RESTART)
// Post no-goods
mi.nogoods().post(*this);
Expand Down
30 changes: 15 additions & 15 deletions examples/job-shop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -700,16 +700,16 @@ solve(const JobShopOptions& opt) {
{
Support::Timer t; t.start();
Search::Statistics stat;
JobShopProbe* master = new JobShopProbe(opt);
JobShopProbe* root = new JobShopProbe(opt);

if (master->status() != SS_SOLVED) {
delete master;
if (root->status() != SS_SOLVED) {
delete root;
std::cerr << "Error: has no solution..." << std::endl;
return;
}

l = master->cost().min();
u = master->cost().max();
l = root->cost().min();
u = root->cost().max();

FailTimeStop fts(opt.fail_probe(),opt.time_probe());
CommonOptions so(opt);
Expand All @@ -722,7 +722,7 @@ solve(const JobShopOptions& opt) {
<< std::endl;

for (unsigned int p=0; p<opt.probes(); p++) {
JobShopProbe* jsp = static_cast<JobShopProbe*>(master->clone());
JobShopProbe* jsp = static_cast<JobShopProbe*>(root->clone());
jsp->branch(p,rnd);
DFS<JobShopProbe> dfs(jsp,so);
JobShopProbe* s = dfs.next();
Expand All @@ -740,7 +740,7 @@ solve(const JobShopOptions& opt) {
}
stat += statj;
}
delete master;
delete root;

print(stat,false);
std::cout << "\t\t\truntime: ";
Expand All @@ -756,11 +756,11 @@ solve(const JobShopOptions& opt) {

// Dichotomic search
{
JobShopSolve* master = new JobShopSolve(opt);
JobShopSolve* model = new JobShopSolve(opt);


if (master->status() == SS_FAILED) {
delete master;
if (model->status() == SS_FAILED) {
delete model;
std::cerr << "Error: has no solution..." << std::endl;
return;
}
Expand All @@ -775,7 +775,7 @@ solve(const JobShopOptions& opt) {
while (l < u) {
std::cout << "\t\tBounds: [" << l << "," << u << "]"
<< std::endl;
JobShopSolve* jss = static_cast<JobShopSolve*>(master->clone());
JobShopSolve* jss = static_cast<JobShopSolve*>(model->clone());
int m = (l + u) / 2;
rel(*jss, jss->cost() >= l);
rel(*jss, jss->cost() <= m);
Expand Down Expand Up @@ -810,7 +810,7 @@ solve(const JobShopOptions& opt) {
}

if (l == u) {
delete master;
delete model;
std::cout << std::endl
<< "\tFound best solution and proved optimality."
<< std::endl;
Expand All @@ -822,15 +822,15 @@ solve(const JobShopOptions& opt) {
Support::Timer t; t.start();
std::cout << std::endl << "\tSolving..." << std::endl;

rel(*master, master->cost() >= l);
rel(*master, master->cost() < u);
rel(*model, model->cost() >= l);
rel(*model, model->cost() < u);

CommonOptions so(opt);
if (opt.time_solve() > 0U)
so.stop = Search::Stop::time(opt.time_solve());
so.cutoff = Search::Cutoff::geometric(JobShopConfig::restart_scale,
JobShopConfig::restart_base);
RBS<JobShopSolve,BAB> rbs(master,so);
RBS<JobShopSolve,BAB> rbs(model,so);
while (JobShopSolve* s = rbs.next()) {
s->print(std::cout);
u = s->cost().val();
Expand Down
4 changes: 2 additions & 2 deletions examples/photo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ class Photo : public IntMinimizeScript {
break;
}
}
/// Slave function for restarts
bool slave(const MetaInfo& mi) {
/// Spoke function for restarts
bool spoke(const MetaInfo& mi) {
if ((mi.type() == MetaInfo::RESTART) &&
(mi.restart() > 0) && (p > 0.0)) {
const Photo& l = static_cast<const Photo&>(*mi.last());
Expand Down
4 changes: 2 additions & 2 deletions examples/qcp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ class QCP : public Script {
}
}
}
/// Slave function for portfolio search
virtual bool slave(const MetaInfo& mi) {
/// Spoke function for portfolio search
virtual bool spoke(const MetaInfo& mi) {
if (mi.type() == MetaInfo::PORTFOLIO) {
double tbf = opt.tbf();
Rnd r(seeds[mi.asset() % n_seeds]);
Expand Down
4 changes: 2 additions & 2 deletions gecode/flatzinc.hh
Original file line number Diff line number Diff line change
Expand Up @@ -682,8 +682,8 @@ namespace Gecode { namespace FlatZinc {
virtual void constrain(const Space& s);
/// Copy function
virtual Gecode::Space* copy(void);
/// Slave function for restarts
virtual bool slave(const MetaInfo& mi);
/// Spoke function for restarts
virtual bool spoke(const MetaInfo& mi);

/// \name AST to variable and value conversion
//@{
Expand Down
2 changes: 1 addition & 1 deletion gecode/flatzinc/flatzinc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2131,7 +2131,7 @@ namespace Gecode { namespace FlatZinc {
}

bool
FlatZincSpace::slave(const MetaInfo& mi) {
FlatZincSpace::spoke(const MetaInfo& mi) {
if (mi.type() == MetaInfo::RESTART) {
if (restart_data.initialized() && restart_data().mark_complete) {
// Fail the space
Expand Down
Loading
Loading