Multiscale modeling for application-oriented optimization of resistive random-access memory