Metamaterials and metasurfaces can be designed optimally utilizing optimization algorithms linked with numerical analyses.