Clingo: Ask clingo to maximise first rule before other rules

90 Views Asked by At

I have a clingo program that comes with multiple soft constraints distributed by different weight.

maximize {1@100, X: constraint1(X)}.
minimize {1@70, X: constraint2(X)}.
.
.
.
minimize {1@1, X: constraintK(X)}.

As the program runs, the optimiser does something like this (Cost of model):

(1,0,0,...,0) => (2,1,0,...,0) => (2,0,0,...,0) => (3,1,1,...,1) => (3,0,1,...,1)

I hope the example is clear. What happens here is that the solver tries to optimise all soft constraints at once. As in, it starts to optimise constraint2 onward before constraint1 is fully optimised. What I would like the program to behave on the other hand is to have the solver to optimize the constraints coming first before moving on to the other constraints. For example:

(1,0,0,...,0) => (2,1,0,...,0) => (3,2,1,...,0) => ... 
=> (99,75,30,...,70) # at this point optimal for constraint 1 is reached
=> (99,70,29,...,70) # start optimising 2nd constraint
=> ...
=> (99,46,19,...,43) # optimal for constraint 2 reached, optimising 3rd constraint etc

Is there anyway to achieve such behavior? Or is it fundamentally against ASP paradigm?

1

There are 1 best solutions below

2
Max Ostrowski On

Citing from clingo --help=3

Clasp.Search Options:

  --opt-strategy=<arg>    : Configure optimization strategy
      <arg>: {bb|usc}[,<tactics>]
        bb : Model-guided optimization with <tactics {lin|hier|inc|dec}> [lin]
          lin : Basic lexicographical descent
          hier: Hierarchical (highest priority criteria first) descent 
          inc : Hierarchical descent with exponentially increasing steps
          dec : Hierarchical descent with exponentially decreasing steps

I think the hier optimization strategy should do exactly what you want to do. So something like --opt-strategy=bb,hier