Automatic design of optimal structures