| Andrew Cooke | Contents | Latest | RSS | Twitter | Previous | Next


Welcome to my blog, which was once a mailing list of the same name and is still generated by mail. Please reply via the "comment" links.

Always interested in offers/projects/new ideas. Eclectic experience in fields like: numerical computing; Python web; Java enterprise; functional languages; GPGPU; SQL databases; etc. Based in Santiago, Chile; telecommute worldwide. CV; email.

Personal Projects

Lepl parser for Python.

Colorless Green.

Photography around Santiago.

SVG experiment.

Professional Portfolio

Calibration of seismometers.

Data access via web services.

Cache rewrite.

Extending OpenSSH.

C-ORM: docs, API.

Last 100 entries

Have to add...; Culturally Liberal and Nothing More; Weird Finite / Infinite Result; Your diamond is a beaten up mess; Maths Books; Good Bike Route from Providencia / Las Condes to Panul\; Iain Pears (Author of Complex Plots); Plum Jam; Excellent; More Recently; For a moment I forgot StackOverflow sucked; A Few Weeks On...; Chilean Book Recommendations; How To Write Shared Libraries; Jenny Erpenbeck (Author); Dijkstra, Coins, Tables; Python libraries error on OpenSuse; Deserving Trump; And Smugness; McCloskey Economics Trilogy; cmocka - Mocks for C; Concept Creep (Americans); Futhark - OpenCL Language; Moved / Gone; Fan and USB issues; Burgers in Santiago; The Origin of Icosahedral Symmetry in Viruses; autoenum on PyPI; Jars Explains; Tomato Chutney v3; REST; US Elections and Gender: 24 Point Swing; PPPoE on OpenSuse Leap 42.1; SuperMicro X10SDV-TLN4F/F with Opensuse Leap 42.1; Big Data AI Could Be Very Bad Indeed....; Cornering; Postcapitalism (Paul Mason); Black Science Fiction; Git is not a CDN; Mining of Massive Data Sets; Rachel Kaadzi Ghansah; How great republics meet their end; Raspberry, Strawberry and Banana Jam; Interesting Dead Areas of Math; Later Taste; For Sale; Death By Bean; It's Good!; Tomato Chutney v2; Time ATAC MX 2 Pedals - First Impressions; Online Chilean Crafts; Intellectual Variety; Taste + Texture; Time Invariance and Gauge Symmetry; Jodorowsky; Tomato Chutney; Analysis of Support for Trump; Indian SF; TP-Link TL-WR841N DNS TCP Bug; TP-Link TL-WR841N as Wireless Bridge; Sending Email On Time; Maybe run a command; Sterile Neutrinos; Strawberry and Banana Jam; The Best Of All Possible Worlds; Kenzaburo Oe: The Changeling; Peach Jam; Taste Test; Strawberry and Raspberry Jam; flac to mp3 on OpenSuse 42.1; Also, Sebald; Kenzaburo Oe Interview; Otake (Kitani Minoru) move Black 121; Is free speech in British universities under threat?; I am actually good at computers; Was This Mansplaining?; WebFaction / LetsEncrypt / General Disappointment; Sensible Philosophy of Science; George Ellis; Misplaced Intuition and Online Communities; More Reading About Japan; Visibilty / Public Comments / Domestic Violence; Ferias de Santiago; More (Clearly Deliberate); Deleted Obit Post; And then a 50 yo male posts this...; We Have Both Kinds Of Contributors; Free Springer Books; Books on Religion; Books on Linguistics; Palestinan Electronica; Books In Anthropology; Taylor Expansions of Spacetime; Info on Juniper; Efficient Stream Processing; The Moral Character of Crypto; Hearing Aid Info; Small Success With Go!; Re: Quick message - This link is broken; Adding Reverb To The Echo Chamber; Sox Audio Tools

© 2006-2015 Andrew Cooke (site) / post authors (content).

Installing Gecode/J (Opensuse)

From: "andrew cooke" <andrew@...>

Date: Sat, 13 Sep 2008 20:29:23 -0400 (CLT)

First, you need the C library - http://www.gecode.org/download.html

This is just the usual ./configure --prefix=... ; make; make install

Next, the Java library - http://www.gecode.org/gecodej/download.html

This needs to find the C libs installed previously, so if they weren't in
a standard location you'll need to do something like:

export PKG_CONFIG_PATH=".../gecode-2.2.0/lib/pkgconfig"

before the ./configure --prefix=... ; make; make install

(You also need a JDK, ant, etc).

The documentation can be built with "make doc", but it's doxygen,not
javadoc, which is no doubt much cooler, but is also frustrating if you're
a seasoned Java coder (I suspect this is written by a bunch of academics
who are only touching Java in a bid to be popular...).  You can build
javadoc using

javadoc -d javadoc -subpackages org -sourcepath .

(assuming you're in the main gecodej dir) but it has doxygen markup all
over the place.

And the docs suck big time.  There's a general intro to constraints at
http://kti.mff.cuni.cz/~bartak/constraints/ but it's completely separate
from Gecode (so it's not clear how things tie in) and the english isn't
that great .

There's also a Ruby interface Gecode/R - http://gecoder.rubyforge.org/ -
which as a few more examples.

Ah well.  Onwards...


Programming Constraint Services

From: "andrew cooke" <andrew@...>

Date: Sat, 13 Sep 2008 23:49:27 -0400 (CLT)

Just found a good reference for all this - Christian Schulte's thesis -

I am not sure it describes Gecode - I think it's describing the Oz
precursor - but in the first couple of chapters it's already a answered a
whole pile of questions I had (probably worth reading the article I linked
to earlier first since as general background).  If understanding the
implementation details (at some limited ;evel) will help you understand
the system, this is for you.

Will continue reading tomorrow.


Commented GecodeJ Example

From: "andrew cooke" <andrew@...>

Date: Sun, 14 Sep 2008 11:33:22 -0400 (CLT)

This is Queens (again), but with a bit more explanation that in the
GecodeJ docs.  The output looks like:

Copy constructor for:

package org.acooke.jbv.example;

import static org.gecode.Gecode.branch;
import static org.gecode.Gecode.distinct;

import java.util.Iterator;

import org.gecode.DFSIterator;
import org.gecode.IntValBranch;
import org.gecode.IntVar;
import org.gecode.IntVarBranch;
import org.gecode.Options;
import org.gecode.Space;
import org.gecode.VarArray;

 * A space is a node in the search tree - it does the same work as a
 * stack frame might in a recursive search.
public class Queens extends Space {

  public static final int BOARD_SIZE = 8;

   * We force there to be one queen per row by the way we store the
   * data (we store only a column for each row, rather than a [row,
   * column] pair).  This is a good thing - it gives us a constraint
   * for free and reduces the search space.
  VarArray<IntVar> columnForRow;

   * This is used to create the initial space, so we define the
   * starting conditions.
  public Queens() {
    // the VarArray needs a reference to the space and a size
    columnForRow = new VarArray<IntVar>(this, BOARD_SIZE,
        // the next args construct the contents by calling
        // the constructor of the given class with the args
        // (which in this case will be min and max values -
        // the domain limits are inclusive(!), hence the "-1")
        IntVar.class, 0, BOARD_SIZE-1);
    // (note - this is a static import from Gecode which provides a
    // selection of pre-packaged constraints)
    // add the constraint that every value is distinct
    distinct(this, columnForRow);
    // another constraint saying that
    // x[i] + delta[i] != x[j] + delta[j]
    // gives us one constraint along diagonals
    distinct(this, diagonals(1), columnForRow);
    // and this gives the other
    distinct(this, diagonals(-1), columnForRow);
    // once all constraints have been applied we may still need to
    // search.  so here we describe how to partition the remaining
    // space with an additional constraint
    // http://kti.mff.cuni.cz/~bartak/constraints/ordering.html
    // (again this is a static import from Gecode)
    // so we need to give the space and variables
    branch(this, columnForRow,
        // @see IntVarBranch - this describes which variable to pick
        IntVarBranch.INT_VAR_NONE, // anything!
        // @see IntValBranch - what to do with the values
        IntValBranch.INT_VAL_SPLIT_MAX); // split in half

   * Offsets for constraints on diagonals.
   * @param scale 1 or -1, to give the two directions.
   * @return
  private static int[] diagonals(int scale) {
    int[] delta = new int[BOARD_SIZE];
    for (int i = 0; i < BOARD_SIZE; ++i) {
      delta[i] = i * scale;
    return delta;

   * This is used to clone the space for child nodes.
   * @param share If true, data can be shared (basically, if share is
   * false you've got to expect that different instances will be accessed
   * by different threads).
   * @param s Another instance of this class to copy (not sure why Space
   * doesn't have the signature Space<S extends Space>).
  protected Queens(Boolean share, Queens q) {
    super(share, q);
    System.err.print("Copy constructor for:\n" + q.toString());
    // there's a constructor that does all the work for us
    columnForRow = new VarArray<IntVar>(this, share, q.columnForRow);

  public String toString() {
    StringBuilder builder = new StringBuilder();
    for (IntVar queen: columnForRow) {
      for (int column = 0; column < BOARD_SIZE; ++column) {
        // we need to be careful here - we can't access values if
        // they haven't been assigned.
        if (! queen.assigned()) {
        } else if (queen.val() == column) {
        } else {
    return builder.toString();

  public static void main(String[] args) {
    Queens space = new Queens();
    // let's use depth first search with whatever the defaults are
    // (there doesn't seem to be an interface that exposes Iterable)
    Iterator<Queens> results =
      new DFSIterator<Queens>(space, new Options());
    while (results.hasNext()) {
      System.out.println("Result:\n" + results.next().toString());


Not to be popular...

From: "andrew cooke" <andrew@...>

Date: Mon, 15 Sep 2008 08:54:37 -0400 (CLT)

---------------------------- Original Message ----------------------------
From:    "Mikael Zayenz Lagerkvist" <zayenz@...>
Date:    Mon, September 15, 2008 5:42 am

"I suspect this is written by a bunch of academics
who are only touching Java in a bid to be popular..."

Well, we might be academics, but the Java interface was done out of
neccessity, not to be popular.

Mikael Zayenz Lagerkvist, http://www.ict.kth.se/~zayenz/

GecodeJ Not for "Real Use"

From: "andrew cooke" <andrew@...>

Date: Mon, 15 Sep 2008 08:56:41 -0400 (CLT)

Turns out GecodeJ is only intended for teaching; for decent efficiency you
apparently need to use the C++ library.


Big pity...



From: "andrew cooke" <andrew@...>

Date: Mon, 15 Sep 2008 09:08:24 -0400 (CLT)

I missed this earlier.  At first glance it seems to have some of the same
annoyances as GecodeJ (eg ranges are inclusive instead of half open), but
the documentation is hugely better: there's a readable guide at
http://choco-solver.net/index.php?title=User_guide and javadocs at

Also, it seems to be a pure Java implementation, so hopefully extending it
won't be so tricky.


Comment on this post