I am working on the development of a simulation game of a taxi calling center. Agents (in population) include:
- Home
- Call
- Car
- Taxi Station
The following code is in a function (periodically triggered by an event) in the agent Taxi Station. Home is randomly chosen.
Call o = new Call();
o.home = main.home.random();
Car c = findCar();
if (t != null)
{
send(msg, c);
}
else
{
collectionCall.addFirst(msg);
}
It reports msg cannot be resolved to a variable. Can somebody help me with this?
Vinz
2,9114 gold badges30 silver badges52 bronze badges
asked May 3, 2017 at 20:09
1
You should initialize msg variable before it’s being used:
Call o = new Call();
o.home = main.home.random();
Car c = findCar();
String msg = "some message";
if (t != null) {
send(msg, c);
} else {
collectionCall.addFirst(msg);
}
answered May 3, 2017 at 20:17
Ivan ProninIvan Pronin
1,75215 silver badges14 bronze badges
3
|
0 / 0 / 1 Регистрация: 08.08.2012 Сообщений: 90 |
|
|
1 |
|
|
07.11.2015, 21:22. Показов 17472. Ответов 4
Одна единственная ошибка встречающаяся у меня в модели это entity cannot be resolved to a variable!!! подскажите пожалуйста что мне с ней делать?
__________________
0 |
|
1816 / 1030 / 285 Регистрация: 13.02.2012 Сообщений: 3,339 |
|
|
07.11.2015, 23:13 |
2 |
|
вы обращаетесь к заявке (entity) в модели, как к обычной переменной, однако заявка это сложный объект у которого куча своих переменных. Смотрите на какой контекст (строку кода) ссылается ошибка.
0 |
|
0 / 0 / 1 Регистрация: 08.08.2012 Сообщений: 90 |
|
|
09.11.2015, 15:30 [ТС] |
3 |
|
Все оказалось очень просто. Просто взял и поменял entity на agent в AnyLogic 7
0 |
|
0 / 0 / 0 Регистрация: 09.10.2015 Сообщений: 4 |
|
|
19.11.2018, 13:46 |
4 |
|
ZORRXXX, доброго времени суток. Столкнлуся с подобной промблемой при проектировании диаграммы действий, и по вашему решению возник ряд вопросов:
0 |
|
-68 / 4 / 1 Регистрация: 17.04.2020 Сообщений: 118 |
|
|
20.05.2021, 23:01 |
5 |
|
Vorla, 3 года прошло…
0 |
У меня проблема с местонахождением агента в одной из моих симуляций Anylogic. Я хочу установить условие, определяющее путь, по которому агент будет визуализировать мою симуляцию.
В блоке задержки в основном агенте я написал
if (agent.previousStation==1){
path01;
}
else {
path21;
}
В поле местоположения агента.
При построении модели anylogic выдает мне следующие ошибки:
Description: Syntax error, insert «VariableDeclarators» to complete
LocalVariableDeclaration. Location: FVMMerkmale/shopfloor/wegzeit1 —
Delay
А также
Description: Syntax error on token(s), misplaced construct(s).
Location: FVMMerkmale/shopfloor — Agent Type
Написание «return» перед путем тоже не помогает и дает разные ошибки:
Description: Syntax error on token(s), misplaced construct(s).
Location: FVMMerkmale/shopfloor — Agent TypeDescription: path21 cannot be resolved to a variable. Location:
FVMMerkmale/shopfloor/wegzeit1 — DelayDescription: Void methods cannot return a value. Location:
FVMMerkmale/shopfloor/wegzeit1 — DelayDescription: agent cannot be resolved to a variable. Location:
FVMMerkmale/shopfloor/wegzeit1 — Delay
Элементы пути находятся в главном агенте. Использование редактора значений для выбора правильного пути будет работать.
Согласно справке anylogic, можно привязать местоположение агента к условию:
Otherwise, if you want to set different nodes for agents here, you can
write a Java expression that will return different nodes depending on
some conditions.
https://help.anylogic.com/index.jsp?topic=%2Fcom.anylogic.help%2Fhtml%2Fagentbased%2FContinuous_Layouts.html
Как мне написать условие, которое определяет путь или узел в качестве местоположения агента?