2016-12-29 63 views
1

我對AnyLogic PMI庫的「split」組件有個疑問。爲了更好地解釋案例,我將發佈我正在構建的部分場景的圖片。 AnyLogic circuit我可以在AnyLogic拆分組件中將單個代理拆分爲多個代理嗎?

在上圖中,左側的源元素生成「Requirement」類型的對象(它是從Agent類繼承的自定義類)。此類表示具有每個產品「PI」的要求爲每一個客戶「次」(矩陣的例子中給出)的矩陣:

Requirement Matrix

該矩陣可以被看作是代理的集合,因爲每個行是我的第一個電路塊所關注的代理(邏輯上它包含關於從產品供應商訂購的產品Pi的數量的信息),並且每一列是另一個我的電路塊的代理有關(邏輯上它包含客戶Ci的銷售預測)。

在拆分塊的「on at enter」事件中,可能會構建一個腳本,該腳本首先對行進行迭代,然後在「out」split端口上發出每個端口,然後迭代列併發出每一個「out-copy」分割的端口。我會張貼我想在「關於在輸入」事件,將這個腳本的僞代碼:

matrix = (Requirement)agent; 
Iterator<Object> reqIter = matrix.getRequirements(); //iterate the rows 
while (reqIter.hasNext()) 
{ 
    Object current = reqIter.next(); 
    //PUSH current in the out port of the split 
} 

Iterator<Object> sellIter = matrix.getRequirements(); //iterate the columns 
while (sellIter.hasNext()) 
{ 
    Object current = sellIter.next(); 
    //PUSH current in the out-copy port of the split 
} 

回答

2

我會把SinkExitnuove matrici後。如果初始代理矩陣可以在代理生成後被破壞,則使用Sink;如果初始代理應該稍後保存並重新使用,則使用ExitSplit塊可以被刪除。代替塊,將兩個Enter塊連接到相應的以下隊列。

Inside On EnterSink\Exit的操作執行代碼。所生成劑可以被注入到相應的隊列enterBlockName.take(new MyAgent(args...));

例如,考慮到代碼生成Agent類型的實例將是:

matrix = (Requirement)agent; 
Iterator<Object> reqIter = matrix.getRequirements(); //iterate the rows 
while (reqIter.hasNext()) 
{ 
    Object current = reqIter.next(); 
    enter.take(new MyAgent(current)); //PUSH current in the top flow 
} 

Iterator<Object> sellIter = matrix.getRequirements(); //iterate the columns 
while (sellIter.hasNext()) 
{ 
    Object current = sellIter.next(); 
    enter1.take(new MyAgent(current)); //PUSH current in the bottom flow 
}