Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Anylogic中编程创建的GIS网络中的代理路由_Java_Simulation_Anylogic - Fatal编程技术网

Java Anylogic中编程创建的GIS网络中的代理路由

Java Anylogic中编程创建的GIS网络中的代理路由,java,simulation,anylogic,Java,Simulation,Anylogic,我正在通过编程在GIS地图上构建一个网格(代码写在最后)。我有一个叫做gisPoints的GIS点列表和一个叫做vehicles的代理群体。我可以在网络中创建GIS点和GIS路线。我遇到的问题是,我创建了一些在网络中行驶的车辆,它们在GIS点之间行驶,但它们不使用创建的网络来行驶 。在源模块中创建车辆时,我使用到达位置:网络/GIS节点和节点:gisPoints.get(0)。然后在moveTo块上使用Destination:Network/GIS节点,在节点上使用gisPoints.get(u

我正在通过编程在GIS地图上构建一个网格(代码写在最后)。我有一个叫做gisPoints的GIS点列表和一个叫做vehicles的代理群体。我可以在网络中创建GIS点和GIS路线。我遇到的问题是,我创建了一些在网络中行驶的车辆,它们在GIS点之间行驶,但它们不使用创建的网络来行驶

。在源模块中创建车辆时,我使用到达位置:网络/GIS节点和节点:gisPoints.get(0)。然后在moveTo块上使用Destination:Network/GIS节点,在节点上使用gisPoints.get(uniform_discr(0,gisPoints.size()-1))

我一直在疯狂地尝试这一点,但无法找到一种方法使其像手动构建网络时那样工作良好。似乎这些车辆不知何故没有进入网络。我怎样才能解决这个问题

网络生成代码

//Create list of GIS Points
List<Tuple> rows = selectFrom(gis_points).list();

for (Tuple row : rows) {
        GISPoint hub = new GISPoint(map,true,row.get( gis_points.latitude ),row.get( gis_points.longitude ));
        map.add(hub);
        gisPoints.add(hub);

}

int verticalCorners = (int) DataStructure.getCellNumericValue("GenerateCoordinates", 1, 11);
int horizontalCorners = (int) DataStructure.getCellNumericValue("GenerateCoordinates", 2, 11);

//create a new GIS network and attach it to your map element
GISNetwork network = new GISNetwork(map,"myNetwork",true);

//add all GISPoints to this network
for(GISPoint p:gisPoints){
    network.add(p);
}

//generate horizontal routes
for(int i=0;i<verticalCorners;i++){
    for(int j=0;j<horizontalCorners-1;j++){

        //create curves (neccessary for the GISRoutes)
        Curve<GISMarkupSegment> curve = new Curve<>();

        //create segment (neccessary for Curve)
        GISMarkupSegment segment = new GISMarkupSegmentLine(
        gisPoints.get(j+i*horizontalCorners).getLatitude(),
        gisPoints.get(j+i*horizontalCorners).getLongitude(),
        gisPoints.get(j+1+i*horizontalCorners).getLatitude(), 
        gisPoints.get(j+1+i*horizontalCorners).getLongitude());

        curve.addSegment(segment);  
        curve.initialize();
        network.add(new GISRoute(map,curve,gisPoints.get(j+i*horizontalCorners), gisPoints.get(j+1+i*horizontalCorners), true));
    }
}

//generate vertical routes
for(int i=0;i<horizontalCorners;i++){
    for(int j=0;j<verticalCorners-1;j++){

        //create curves (neccessary for the GISRoutes)
        Curve<GISMarkupSegment> curve = new Curve<>();

        //create segment (neccessary for Curve)
        GISMarkupSegment segment = new GISMarkupSegmentLine(
        gisPoints.get(i+j*horizontalCorners).getLatitude(),
        gisPoints.get(i+j*horizontalCorners).getLongitude(),
        gisPoints.get(i+(1+j)*horizontalCorners).getLatitude(), 
        gisPoints.get(i+(1+j)*horizontalCorners).getLongitude());

        curve.addSegment(segment);  
        curve.initialize();
        network.add(new GISRoute(map,curve,gisPoints.get(j+i*horizontalCorners), gisPoints.get(j+1+i*horizontalCorners), true));
    }
}

//Do not forget to initialize the network
network.initialize();
//创建GIS点列表
列表行=从(gis_点)中选择。列表();
for(元组行:行){
GISPoint hub=新的GISPoint(地图、真值、行.get(gis_points.latitude)、行.get(gis_points.latitude));
地图添加(中心);
添加(集线器);
}
int verticalCorners=(int)DataStructure.getCellNumericValue(“生成坐标”,1,11);
int horizontalCorners=(int)DataStructure.getCellNumericValue(“生成坐标”,2,11);
//创建新的GIS网络并将其附着到地图元素
GISNetwork=新的GISNetwork(地图,“myNetwork”,true);
//将所有点添加到此网络
用于(GISPoint p:gisPoints){
添加(p);
}
//生成水平布线

对于(int i=0;i不确定这是否是解决方案,但您可以尝试一下


我认为问题在于,您正在将网络作为局部变量生成,而应该将网络作为main中的变量…这样您的gispoints就存在了(因为它们是main中的集合)但您的网络没有,因为它是在主设置中作为局部变量创建的

不确定这是否是解决方案,但您可以尝试一下

我认为问题在于,您正在将网络作为局部变量生成,而应该将网络作为main中的一个变量…因此您的gispoints存在(因为它们是main中的一个集合),但您的网络不存在,因为它是在主设置中作为局部变量创建的

实际上,我创建的路线是错误的(垂直路线的索引是错误的)。正如您在我使用的代码中所看到的:

network.add(new GISRoute(map,curve,gisPoints.get(j+i*horizontalCorners), gisPoints.get(j+1+i*horizontalCorners), true));
正确的形式是:

network.add(new GISRoute(map,curve,gisPoints.get(i+j*horizontalCorners), gisPoints.get(i+(1+j)*horizontalCorners), true));
因此,问题在于,在不同的水平层中,没有可行的路线通过网络从起点和终点到达

我将不修改这个问题,因为我认为对于需要以编程方式创建矩形网络并考虑Felipe Haro的建议(创建GISNetwork全局变量)的人来说,它可能很有用总的来说,这比我拥有的更优雅,因为不需要创建gisPoints集合,因为所有内容(初始点和目标点)都可以直接从网络中调用。

*更新的解决方案

实际上,我创建的路线是错误的(垂直路线的索引是错误的)。正如您在我使用的代码中所看到的:

network.add(new GISRoute(map,curve,gisPoints.get(j+i*horizontalCorners), gisPoints.get(j+1+i*horizontalCorners), true));
正确的形式是:

network.add(new GISRoute(map,curve,gisPoints.get(i+j*horizontalCorners), gisPoints.get(i+(1+j)*horizontalCorners), true));
因此,问题在于,在不同的水平层中,没有可行的路线通过网络从起点和终点到达


我将不修改这个问题,因为我认为对于需要以编程方式创建矩形网络并考虑Felipe Haro的建议(创建GISNetwork全局变量)的人来说,它可能很有用总的来说,这比我拥有的更优雅,因为不需要创建gisPoints集合,因为所有内容(初始点和目标点)都可以直接从网络中调用。

是否确保在GIS网络创建后创建移动代理?另外,在源代码块的“on exit”中,调用
agent.jumpTo(somegisPointIn Network
强制将其添加到网络中。您可能还需要在其他一些位置尝试此操作(在创建代理时…@Benjamin我在启动时创建网络,第一个移动代理在模拟的20分钟左右创建。我在创建块“退出时”和moveTo块的“按回车键”,但它不起作用。还有其他想法吗?好吧,试着一步一步地返回,直到它起作用,或者创建一个“MVP”,即概念上工作的最小模型。然后,必须调查它的故障位置…很难给出更多建议,不幸的是。您是否确保在GIS网络创建后创建移动代理?另外,在源代码块的“退出”中,调用
agent.jumpTo(somegisPointIn Network
强制将其添加到网络中。您可能还需要在其他一些位置尝试此操作(在创建代理时…@Benjamin我在启动时创建网络,第一个移动代理在模拟的20分钟左右创建。我在创建块“退出时”和moveTo块的“按回车键”但它不起作用。还有其他想法吗?好吧,尝试一步一步地返回,直到它起作用,或者创建一个“MVP”,即概念上它起作用的最小模型。然后,必须调查它在哪里出故障…很难给出更多建议,不幸。嗯,尝试一步一步地返回,直到它起作用,或者创建一个“MVP”“,也就是它在概念上工作的最小模型。然后,必须调查它在哪里发生故障…很难给出更多建议,不幸的是。@Benjamin实际上我创建的路线是错误的(垂直路线的索引是错误的)因此,问题在于,在不同的水平层中,没有可行的路线通过网络从起点和终点到达。Nev