In my model, various practitioners go to see patients multiple times in one visit. I am trying to ensure the same fellow is used to see a patient over multiple visits after being seized and released multiple times. I continue to receive this Type mismatch. Type Patient is the agent being pushed through the model and type Fellow belongs to a resource pool of 3 fellows.
CodePudding user response:
A few notes
- Your screenshot is of the resource pool named Fellows - yet you market the Unit type as
Patient
- it should beFellow
if you want the resource pool to contain agents of typeFellow
and have patients flow through the process flow and seize Fellows
- In the
on seize
code you have two local variables you can use
Unit - is the Fellow, the resource unit from this pool agent - the agent that seized the unit (can be literally anything) so you need to cast it to what you think it is going to be.. AnyLogic cant do it or you as it has no idea what agent type will seize it
- Your custom resource choice will then also change
We again need to cast the agent to a Patient
again
NB - remember that this logic will throw a cast class exception error if any other agent than a Patient seizes a fellow.
CodePudding user response:
You must ensure that the variable fellow
in your Patient
agent type is of type Fellow
.
You try to store the Fellow
in the Patient.fellow
variable but that variable is not of type Fellow
, causing the problem.