0

(2X2) 数独ゲームを作成しており、パズルを完成させる必要があります。これは、一部の数字が不変であることを意味します (それらは別の場所に移動することはできません。

2X2 ゲームでは、16 個Digitの s があります。問題の事実はrow、s、columns、およびblocks (分かりますか?) です。が唯一のrow計画変数です。

boolean fixedの属性として指定しましたDigit。しかし(ユーザーガイドによると)、それを実装する場所が見つかりませんでした。

いくつかの計画エンティティを実際に不変にする方法は何ですか?


私はこれらの方法を見つけます:

  1. 不変の場合にのみmoveFactoryを変更する を実装します。rowこのメソッドは文書化されていません
  2. rowが a と等しくない場合はfixed_row、ハード制約を破ります。
  3. を使用し@ValueRangeFromPlanningPropertyます。不変エンティティvalue_rangeには単一の要素があり、可変エンティティには固定行を除外するリストがあります。これは、数独プロジェクトよりも大きなものには持続不可能に思えますよね? そして、(私の?) ソルバーを脱線させるとされる落とし穴がありますか?

追加の質問: 方法 #3 は、時間割の問題のようなものに推奨される方法ですか (可能な期間に教科教師を割り当てる)?

4

1 に答える 1

1

Option 4: The fixed digits are problem facts: instances of a class that does not have a @PlanningEntity annotation. The non-fixed digits are planning entities: instances of a class that does have a @PlanningEntity.

If you'd like to reuse the same class for both for design purposes:

  1. A custom MoveFactory would be the way. Writing a custom move factory is documented: it's just a matter adding an if statement to excluding moves that change a fixed digit.
  2. In that case it's not a build-in hard constraint but a normal hard constraint, I wouldn't recommend that for this use case. See manual info about "build-in hard constraints"
  3. Overkill, but it would work :)

Option 5: https://issues.jboss.org/browse/JBRULES-3359

于 2012-01-24T10:06:12.690 に答える