从数据库中读取 Anylogic 计划异常 table

Read Anylogic schedule exceptions from database table

如何从 Excel 文件中读取时间表的例外日期列表,而不必分别采用文件中的每个日期?我正在尝试制定一个考虑到未来 5 年假期等因素的轮班计划。为此,我创建了一个包含假期日期列表的 Excel table,我现在想在我的 AnyLogic 模拟中使用它。我尝试了我的计划对象的异常部分,但没有找到将此部分连接到我的 excel 文件的方法。我在这里得到的唯一选择是手动输入每个日期...因为这会非常乏味,我正在寻找解决方法(Java 代码?)。有人可以帮忙吗?

是的,没有内置的方法。您需要对您的日程安排进行编码。这允许以编程方式添加异常,请参阅 https://anylogic.help/anylogic/data/schedule.html#creating-and-initializing-schedule-from-code-on-model-startup

具体来说:

假设您有一个整数类型的计划对象和一个充满异常日期的数据库table,您希望计划的整数值在一整天都为 0。

然后您可以使用以下代码以编程方式将例外情况添加到您的日程安排中

List<Tuple> rows = selectFrom(db_table).list();

for (Tuple row : rows) {
    Date exceptionDate = row.get( db_table.db_column );
    schedule.addException(exceptionDate.getYear(), exceptionDate.getMonth(), exceptionDate.getDay(), exceptionDate.getHours(), exceptionDate.getMinutes(), exceptionDate.getSeconds(), 
                        exceptionDate.getYear(), exceptionDate.getMonth(), exceptionDate.getDay()+1, exceptionDate.getHours(), exceptionDate.getMinutes(), exceptionDate.getSeconds(),
0, false);
}

添加异常的格式有点繁琐但是是:

schedule.addException(startYear, startMonth, startDay, startHour, startMinute, startSecond, endYear, endMonth, endDay, endHour, endMinute, endSecond, value, annually);

value 对象是您的日程表类型的值