Mathematical modeling of complex homeostatic systems