I was wondering if this sentence is okay:
The algorithm is inspired by the indirect local communication among the
individuals of a population of ants when (they are) searching for food
If I omit ‘they are’, does it remains correct? Can I replace ‘when’ with ‘while’ or ‘whereas’?
Yes, it’s correct after you remove “they are”. It’s understood from context that it’s the ants doing the searching.
“while” is just as correct and maybe very slightly more clear.
“whereas” doesn’t work here. It is used for contrast between things. For example
eagles are birds, whereas dogs are mammals”