使用合金4.2的地形排序

时间:2015-11-04 16:31:38

标签: alloy

我尝试使用拓扑排序来找到遵循其先决条件的两个不同的顺序计划。当我执行代码时,没有找到实例,我不知道为什么。这是我的代码:

open util/relation

abstract sig Course {
    prereq: set Course, -- c->d in prereq if c is a prerequisite of d
    s1, s2: set Course      -- two sequential course schedules
}
one sig cs1121, cs1122, cs1141, cs2311, cs2321,
                cs3000, cs3141, cs3311, cs3331, cs3411, cs3421, cs3425 extends Course { }

fact {
    no prereq.cs1121
    prereq.cs1122 = cs1121
    prereq.cs1141 = cs1122
    prereq.cs2311 = cs1121
    prereq.cs2321 = cs1122
    prereq.cs3000 = cs3141
    prereq.cs3141 = cs2311
    prereq.cs3141 = cs2321
    prereq.cs3311 = cs2311
    prereq.cs3331 = cs1141
    prereq.cs3331 = cs2311
    prereq.cs3331 = cs2321
    prereq.cs3411 = cs1141
    prereq.cs3411 = cs3421
    prereq.cs3421 = cs1122
    prereq.cs3425 = cs2311 
    prereq.cs3425 = cs2321
}

-- is the given schedule a topological sort of the prereq relation?
pred topoSort [schedule: Course->Course] {
    (all c: Course | lone c.schedule and lone schedule.c) -- no branching in the schedule
    and totalOrder[*schedule, Course] -- and it's a total order
    and prereq in ^schedule -- and it obeys the prerequisite graph
}


pred show {
    s1.irreflexive  and s2.irreflexive  -- no retaking courses!
    s1.topoSort and s2.topoSort -- both schedules are topological sorts of the prereq relation
    s1 != s2    -- the schedules are different
}

run show

1 个答案:

答案 0 :(得分:2)

将解算器(在“选项”菜单下)切换到带有Unsat Core的MiniSAT,然后查看核心。你会看到它突出显示

 prereq.cs3141 = cs2311
 prereq.cs3141 = cs2321

与你的无分支规则相矛盾。