4.Solving Constraint Satisfaction Problems(2)

Summary of solutions

1.Pure backtracking
— If the current partial assignment is consistent
— Choose a variable, assign each value from its domain in turn
— Search the resulting sub-tree
2.Forward checking
— Prune values from neighbor variables if they are not supported by the assigned one

3.Arc consistency
— Prune similarly for all pairs of values related by a constraint

Constraint learning

? Learned constraints may be added to the network or kept separately
? A separate store of nogoods is usual, as they are usually large
— May add binary ones to the network and store the rest
— Data structures matter: indexing for rapid inference is important
? Every branch may add another nogood, so there are too many of them
— Storage requires exponential space
? Hence common to have a strategy for forgetting them
— e.g. let the longest ones lapse after a while
— or just keep the “tail” and discard when backtracking leaves the region
where it applies
? Constraint learning useful for CSP solvers; essential for SAT solvers

Constraint graphs

One of Graph Constraint

· vertices are decision variables
· edges are constraints

  1. Graph contains information about the structure of the problem.
  2. The dual graph: the vertices are the constraints and an edge between two constraints means they share a variable, gives yet another view.
  3. The bipartite graph: variable nodes and constraint nodes.
  4. the constraint graph only shows which decision variables are connected. It is not affected by whether the problem has solutions or not.

Tree-like constraint graphs

Example
  1. Choose a vertex to be the root of the tree
  2. Start assigning values at the root
  3. Don’t assign a value to a variable before its parent in the tree
  4. Do forward checking at each step

Symmetry

Value symmetry and variable symmetry are frequently present in CSPs

Example:
Suppose we have a pigeonhole problem: show that it’s impossible to fit 10 pigeons in 9 pigeonholes (without overcrowding)

Answer:
9! backtracks, even with arc consistency; no solution.
But one pigeon looks just like another (to a CSP solver), and one hole looks just like another as well.
A good symmetry-breaker is ?x?y((x < y) → (hole(x) < hole(y))). —would be true of 1 solution if there were just enough holes.
Therefore, 9! branches reduced to 1.

The bad part: if a problem has lots of symmetries, we can waste huge amounts of time searching symmetric (and equally empty) sub-spaces, or generating solutions that tell us nothing really new.

The good part: if we explore one of these sub-spaces, we know we can prune all of the others without losing anything essential

How to use: Note that if solutions are symmetric, partial assignments have (at least) the same symmetries, so early pruning may be possible.

The usual method for removing symmetric sub-problems is to add symmetry-breaking constraints

Tightening CSPs by learning from mistakes

if we found (v1 : b, v2 : r, v3 : b) was no good, remember that combination (v1 : b, v2 : r, v3 : b) as a disallowed triple of a (3-ary) constraint.

Never repeat a mistake: don’t backtrack twice for the same reason.

Two common ways of defining “better” or “worse” solutions:

  1. via an objective function: a quantity to me minimized (or maximized)
  2. via soft constraints: can be violated, but as little as possible
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末赦拘,一起剝皮案震驚了整個(gè)濱河市侥袜,隨后出現(xiàn)的幾起案子馅而,更是在濱河造成了極大的恐慌包吝,老刑警劉巖,帶你破解...
    沈念sama閱讀 217,084評(píng)論 6 503
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件腹纳,死亡現(xiàn)場(chǎng)離奇詭異痢掠,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī)嘲恍,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,623評(píng)論 3 392
  • 文/潘曉璐 我一進(jìn)店門足画,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人佃牛,你說我怎么就攤上這事淹辞。” “怎么了俘侠?”我有些...
    開封第一講書人閱讀 163,450評(píng)論 0 353
  • 文/不壞的土叔 我叫張陵象缀,是天一觀的道長(zhǎng)彬向。 經(jīng)常有香客問我,道長(zhǎng)攻冷,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,322評(píng)論 1 293
  • 正文 為了忘掉前任遍希,我火速辦了婚禮等曼,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘凿蒜。我一直安慰自己禁谦,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,370評(píng)論 6 390
  • 文/花漫 我一把揭開白布废封。 她就那樣靜靜地躺著州泊,像睡著了一般。 火紅的嫁衣襯著肌膚如雪漂洋。 梳的紋絲不亂的頭發(fā)上遥皂,一...
    開封第一講書人閱讀 51,274評(píng)論 1 300
  • 那天,我揣著相機(jī)與錄音刽漂,去河邊找鬼演训。 笑死,一個(gè)胖子當(dāng)著我的面吹牛贝咙,可吹牛的內(nèi)容都是我干的样悟。 我是一名探鬼主播,決...
    沈念sama閱讀 40,126評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼庭猩,長(zhǎng)吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼窟她!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起蔼水,我...
    開封第一講書人閱讀 38,980評(píng)論 0 275
  • 序言:老撾萬榮一對(duì)情侶失蹤震糖,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后徙缴,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體试伙,經(jīng)...
    沈念sama閱讀 45,414評(píng)論 1 313
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,599評(píng)論 3 334
  • 正文 我和宋清朗相戀三年于样,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了疏叨。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 39,773評(píng)論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡穿剖,死狀恐怖蚤蔓,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情糊余,我是刑警寧澤秀又,帶...
    沈念sama閱讀 35,470評(píng)論 5 344
  • 正文 年R本政府宣布单寂,位于F島的核電站,受9級(jí)特大地震影響吐辙,放射性物質(zhì)發(fā)生泄漏宣决。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,080評(píng)論 3 327
  • 文/蒙蒙 一昏苏、第九天 我趴在偏房一處隱蔽的房頂上張望尊沸。 院中可真熱鬧,春花似錦贤惯、人聲如沸洼专。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,713評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽屁商。三九已至,卻和暖如春颈墅,著一層夾襖步出監(jiān)牢的瞬間蜡镶,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 32,852評(píng)論 1 269
  • 我被黑心中介騙來泰國打工精盅, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留帽哑,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 47,865評(píng)論 2 370
  • 正文 我出身青樓叹俏,卻偏偏與公主長(zhǎng)得像妻枕,于是被迫代替她去往敵國和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子粘驰,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,689評(píng)論 2 354

推薦閱讀更多精彩內(nèi)容