In the paper we present results of computational experiments to suggest the possibility of a general optimality condition of complex systems: a system demonstrates the optimal performance for a problem, when the structural complexity of the system is in a certain relationship with the structural complexity of the problem. The optimality condition could be used as a basic principle in the design of intelligent systems optimizing their performance in the dynamic environment.