For constrained optimization, one optimization method is GA, which needs training a VAE along with an extra neural network that learns to predict the target function value y from the latent vector z. The new latent vector z ′ can be calculated using the gradient of the target function y with respect to the latent vector z and the configurable learning rate α as in the equation ( ). Then, new molecular candidates can be decoded from these modified latent vectors using the VAE decoder and their target function values can be calculated. These steps can be repeated for a certain number of iterations or until a condition is met.