微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

从数据库导出数据时模型停止模拟

如何解决从数据库导出数据时模型停止模拟

我正在从我的 AnyLogic 模型导出数据,方法是从保存到内部数据库的数据中写入/附加每个运行的文本文件。我在实验的 After simulation run 字段中使用以下代码

// create header
file.println("id"+","+"replicate"+","+"diagnostic_pathway_duration"+","+"total_cost_patient"+","+
                "referred_gh"+","+"referred_th"+","+"tx_gh"+","+"tx_th"+","+"tx_ah"+","+"arrival_gh"+","+
                "complete_gh"+","+"arrival_th"+","+"complete_th"+","+"arrival_ah"+","+"complete_ah"+","+
                "pathway_concluded");

// Write data from dbase table                                
List<Tuple> rows = selectFrom(patient_export).list();

for (Tuple row : rows) {
        file.println(        row.get( patient_export.id ) + "," + 
                                        row.get( patient_export.replicate ) + "," + 
                                        row.get( patient_export.diagnostic_pathway_duration ) + "," + 
                                        row.get( patient_export.total_cost_patient ) + "," + 
                                        row.get( patient_export.referred_gh ) + "," + 
                                        row.get( patient_export.referred_th ) + "," + 
                                        row.get( patient_export.tx_gh ) + "," + 
                                        row.get( patient_export.tx_th ) + "," + 
                                        row.get( patient_export.tx_ah ) + "," + 
                                        row.get( patient_export.arrival_gh ) + "," + 
                                        row.get( patient_export.complete_gh ) + "," + 
                                        row.get( patient_export.arrival_th ) + "," + 
                                        row.get( patient_export.complete_th ) + "," + 
                                        row.get( patient_export.arrival_ah ) + "," + 
                                        row.get( patient_export.complete_ah ) + "," + 
                                        row.get( patient_export.pathway_concluded ));
}
file.close();
deleteFrom(patient_export).execute();

initial experiment setup 字段中,我包含了以下代码

deleteFrom(patient_export).execute();

但是,一段时间后不再执行模拟运行。该模型不再有任何进展,并且 cpu 不再被征税。在一个例子中,实验在 45 次迭代后停止模拟,结果产生了一个 210 mb 的文本文件,大约有 110 万行。

我通过使用事件触发 Patient 中的函数将数据保存到内部数据库。这是代码

insertInto(patient_export)
    .columns(patient_export.iteration,patient_export.replicate,patient_export.id,patient_export.diagnostic_pathway_duration,patient_export.total_cost_patient,patient_export.referred_gh,patient_export.referred_th,patient_export.tx_gh,patient_export.tx_th,patient_export.tx_ah,patient_export.arrival_gh,patient_export.complete_gh,patient_export.arrival_th,patient_export.complete_th,patient_export.arrival_ah,patient_export.complete_ah,patient_export.pathway_concluded
            ) //database tables
    .values(main.v_iteration,main.v_replicate,p_patientId,p_diagnostic_pathway_duration,p_totalCost,p_referred_GH,p_referred_TH,p_Tx_GH,p_Tx_TH,p_Tx_AH,p_timeArrivedDxGH,p_timeCompletedDxGH,p_timeArrivedDxTH,p_timeCompletedDxTH,p_timeArrivedDxAH,p_timeCompletedDxAH,p_diagnosticPathwayConcluded
    .execute();

在这里做错了什么?内部数据库正在播放吗?非常感谢所有帮助。

解决方法

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。