Layers
To get units avoid the enemy units by a safe margin I have to bake the enemy units LOS into the obstacle map. First I'm saving the LOS of each unit into a separate layer. Then I'm merging all the layers and save the result into the obstacle map. Ranged units can attack workers from distance. I'm also saving the areas from which a worker can be attacked. One layer per worker. Then I'm merging those too. When a ranged unit has to attack a worker it moves to a tile from which a worker can be attacked provided that tile is not found on the enemy LOS map (the tile is not in the range of an enemy combat unit). The resulting navigation map looks like this:

Discussion