我已经在 repast simphony 中构建了一个 3D 模型,并且它运行(相当)良好。然而,由于模型的性质,代理倾向于形成密集的团块。我想知道是否有一种方法可以通过生成连续更新的 2D 显示或最终状态 View 来生成穿过团块中间的 2D 切片或横截面,以查看代理在团块内部做什么。
我已经探索了 gui 中的显示选项并尝试了不同的代理分层,但由于密度的原因,这些都不起作用。有没有办法稍微改变 gui 的这一方面,以在 50x50x50 网格中给出 x=25 处 yz 平面的 2D View (例如)。
预先感谢您的帮助!
最佳答案
您可以通过基于代理的可见性属性更改样式类中的透明度属性来更改 3D 显示中形状的透明度。例如,您的代理可以检查他们在 3D 空间中的当前位置,并且仅当代理位于您想要可视化的空间平面时才返回 isVisible() true。这将仅在 3D 显示中显示您定义的平面上存在的代理,该平面可以是通过空间的任何 x、y、z 方向。在您的样式类中,您需要更新 getAppearance(...) 方法中的透明度,如下所示:
public TaggedAppearance getAppearance(MyAgent agent, TaggedAppearance taggedAppearance, Object shapeID) {
if (taggedAppearance == null) {
taggedAppearance = new TaggedAppearance();
// Customize your agent style here...
AppearanceFactory.setMaterialAppearance(taggedAppearance.getAppearance(), Color.white);
}
if (trans == null) {
trans = new TransparencyAttributes();
trans.setCapability(TransparencyAttributes.ALLOW_VALUE_READ);
trans.setCapability(TransparencyAttributes.ALLOW_VALUE_WRITE);
trans.setCapability(TransparencyAttributes.ALLOW_MODE_READ);
trans.setCapability(TransparencyAttributes.ALLOW_MODE_WRITE);
trans.setTransparencyMode(TransparencyAttributes.FASTEST);
taggedAppearance.getAppearance().setTransparencyAttributes(trans);
}
if (agent.isVisible())
trans.setTransparency(0.0f);
else
trans.setTransparency(1.0f);
return taggedAppearance;
}
您还可以将透明度值从 0 调整到 1 以提供不同级别的透明度,以便感兴趣的代理完全不透明 (0.0f) 而外围的代理非常透明 (0.8f)。
关于agent-based-modeling - 如何在 Repast Simphony(gui 或样式代码?)中生成不同的 2D 显示?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52411053/