GabrielChu
GabrielChu

Reputation: 6166

Can more than one 'solve' be applied in MiniZinc?

I tried to applied a structure as follow in a single mzn file:

define Variables;

%% first set of constraints
constraint ...;
constraint ...;
solve satisfy;

%% second set of constraints
constraint ...;
constraint ...;
solve satisfy;

where second set of constraints are constraints applied to the results from first solve, conducting operations separately would reduce search spaces thus reduce computation time, which is the cause I came up with this structure at first place.

Is there any way to implement such dependence structure? Since MiniZinc doesn't allow two solve.

Upvotes: 0

Views: 584

Answers (1)

hakank
hakank

Reputation: 6854

As you mention MiniZinc requires exactly one solve in a model.

There are other approaches depending on the problem.

1) Write a program in another programming language which runs the first MiniZinc models and fetch the result. Then you can make (run time) another MiniZinc model which is run with the previous result. This is the approach I myself probably would use.

Development versions of MiniZinc include an interface to Python which might make this quite easy. However, I have not tested this.

2) Very much dependent on the specific problem, it might be possible to combine the two versions in the same model. For example, if the problem have two objectives, then you can have both sub problems in the model and combine these two objectives adding weights on the objectives how important each of the sub problem objective is. It's the "standard" way of handling multiple objectives (multi-objectives) found in e.g. linear programming. There is, however, no special support for this in MiniZinc.

(One related feature I would like to have in MiniZinc is support for a model which first solves an objective, and then generate all solutions that satisfying that objective. This is not possible in today's MiniZinc. However, the experimental MiniSearch extension of MiniZinc, http://www.minizinc.org/minisearch/ might make this possible, at least according to the developers. Though I have never got it to work...)

Upvotes: 2

Related Questions