Slightly unusual constraint solving problem I'm trying to implement in MiniZinc: I have a CSP that has some hard constraints and a soft constraint that the relations in the solution should have a statistically similar profile to an example solution. That is, if the input has 5 'red' and 12 'green', the found solution doesn't have to have exactly 5 and 12, but should be statistically likely to have a similar distribution...but also allow rare solutions that, for example, have no red.
While I could have a hard constraint that the distribution must exactly match the distribution, or get all of the possible solutions and sample from that, I'd prefer a search strategy that can get one solution that is statistically likely to have similar distribution (but can vary). Or a performance-equivalent way to do it.
Using the indomain random
for the assignmentannotation
seems like it might work, but from my understanding the only way to use weighting with it is to populate the domains with multiple values to pad out the domain with the correct weighting.
I could, alternately, frame it as an optimization problem and look for a solution that maximizes the similarity to the desired distribution, but I'd prefer something that meets the hard constraints and does a weighted sample from the entire possible solution space for the soft constraints.