← All Picat Flashcard Decks

Constraint Programming with CP Flashcards

7 cards from real Picat practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.

Read the first 7 Constraint Programming with CP flashcards as text
  1. In Picat CP, what does `fd_dom(Var, Dom)` return?

    Answer: The domain of Var as a list of values or ranges

    `fd_dom(Var, Dom)` unifies Dom with a representation of all remaining values in Var's finite domain.

  2. Which constraint ensures that the values of variables in a list form a permutation of 1..N in Picat CP?

    Answer: all_different(List) with domain 1..N

    Combining `all_different(List)` with each variable's domain set to `1..N` exactly models a permutation constraint.

  3. What happens if you post two contradictory constraints, such as `X #= 3` and `X #= 5`, on the same variable in Picat CP?

    Answer: The predicate fails, triggering backtracking

    Constraint propagation detects the empty domain immediately and causes the current goal to fail, which triggers backtracking in the search.

  4. In Picat's CP module, the `circuit/1` global constraint is used to model which type of problem?

    Answer: Hamiltonian cycle over a set of successor variables

    `circuit(Succ)` constrains the array Succ so that the successor relation forms a single Hamiltonian cycle visiting every node exactly once.

  5. Which predicate tests whether a CP variable is already instantiated (ground) in Picat?

    Answer: ground(Var)

    `ground(Var)` succeeds if Var is fully instantiated and contains no unbound logical variables.

  6. In Picat CP, what does the `max_regret` variable-selection heuristic do?

    Answer: Chooses the variable whose two best values differ most, maximizing the cost of wrong choice

    `max_regret` selects the variable where the difference between the best and second-best domain values is greatest, focusing on high-stakes decisions.

  7. What is the role of `scalar_product/4` in Picat's CP module?

    Answer: Models a linear constraint between a coefficient vector and variable vector

    `scalar_product(Coeffs, Vars, Rel, Bound)` posts the linear constraint Coeffs · Vars Rel Bound using the specified relational operator.