本文整理汇总了C#中Arc.getVar1Column方法的典型用法代码示例。如果您正苦于以下问题:C# Arc.getVar1Column方法的具体用法?C# Arc.getVar1Column怎么用?C# Arc.getVar1Column使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Arc
的用法示例。
在下文中一共展示了Arc.getVar1Column方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: revise
//Purpose: Returns true iff we revise the domain of Xi
private bool revise(Arc arc)
{
int x = 0;//used to hold value from domain
//revised <- false;
bool revised = false;
//for(each x in the domain){
for (int i = 0; i < board[arc.getVar1Row(), arc.getVar1Column()].getDomain().Count; i++) {
x = board[arc.getVar1Row(), arc.getVar1Column()].getDomain()[i];
//if (no value y in Dj allows (x,y) to satisfy the constraint between Xi and Xj){
if (board[arc.getVar2Row(), arc.getVar2Column()].getValue() == x) {
//delete x from Di
board[arc.getVar1Row(), arc.getVar1Column()].removeVarFromDomain(x);
//revised = true;
revised = true;
}
}
return revised;
}
示例2: AC3
//Purpose: returns false if an inconsistency is found and true otherwise
public bool AC3()
{
//AC3 Algorithm from the book
//local variables: Queue of arcs, initially all the arcs in CSP
Queue<Arc> arcQueue = new Queue<Arc>();
//Add all the arcs into the queue
for (int i = 0; i < boardWidthAndHeight; i++)
{
for (int j = 0; j < boardWidthAndHeight; j++)
{
for (int k = 0; k < board[i, j].getConstraints().Count; k++)
{
Arc temp = new Arc();//used for loading arcs into the arc queue,
temp.setVar1Row(i);
temp.setVar1Column(j);
temp.setVar2Row(board[i, j].getConstraints()[k].getRow());
temp.setVar2Column(board[i, j].getConstraints()[k].getColumn());
arcQueue.Enqueue(temp);
}
}
}
//while(queue is not empty) do
while (arcQueue.Count > 0)
{
Arc temp = new Arc();//holds the object removed from the queue
//(Xi, Xj) <- Remove First(queue)
temp = arcQueue.Dequeue();
//if (Revise(csp, Xi, Xj))
if (revise(temp))
{
//if (size of Domain == 0)
if (board[temp.getVar1Row(), temp.getVar1Column()].getDomain().Count == 0)
{
return false;
}
//for (each Xk in Xi, Neighbors - {Xj} do
for (int k = 0; k < board[temp.getVar1Row(), temp.getVar1Column()].getConstraints().Count; k++)
{
Arc temp2 = new Arc();//used for loading new arcs into the arc queue
//add (Xk, Xi) to the queue
temp2.setVar1Row(board[temp.getVar1Row(), temp.getVar1Column()].getConstraints()[k].getRow());
temp2.setVar1Column(board[temp.getVar1Row(), temp.getVar1Column()].getConstraints()[k].getColumn());
temp2.setVar2Row(temp.getVar1Row());
temp2.setVar2Column(temp.getVar1Column());
arcQueue.Enqueue(temp2);
}
}
}
return true;
}