Couldn't you then simply not accept the nearest idle resident when demand appears and check the next one?
IE If a Factory has generated demand, search the nearest idle house. If it's too close to the factory [Let's say less than 8 blocks away in Manhattan Distance] move unto the next nearest idle house. Once the 8 Blocks away condition is met, assign it. If none meet it, simply keep checking every time a house is generated in the future.