Skip to content

Finding solution that satisfies the Maximum possible number of constraints #2288

Answered by XiaowenHu96
YiwenDong98 asked this question in Q&A
Discussion options

You must be logged in to vote

Here is my idea of using the choice constraint in Souffle:

Assign each constraint with a score, 1 if the constraint is satisfied and 0 otherwise.
Modify seating so each solution has a score, indicating how many constraints are satisfied.
Assign seating a choice construct such that for each score, we only keep one solution.
Boostraping seating with a score = 0.
Modify seating so seating with score x is fired iff there is a seating with score (x-1).

.decl seating(tb1_per1: symbol, tb1_per2: symbol, 
        tb2_per1: symbol, tb2_per2: symbol, score: number) choice-domain score
.output seating(IO=stdout)
seating("", "", "", "", 0).
seating(tb1_per1, tb1_per2, tb2_per1, tb2_per2, score) :-

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@XiaowenHu96
Comment options

@YiwenDong98
Comment options

Answer selected by YiwenDong98
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants