A retinal mosaic, the spatial organization of a population of homotypic neurons, is thought to sample a specific visual feature into the feedforward visual pathway. The purpose of this study was to propose a universal modeling approach for precisely generating retinal mosaics and overcoming the limitations of previous models, especially in modeling abnormal mosaic patterns under disease conditions. Here, we developed the optimization-based pairwise interaction point process (O-PIPP). It incorporates optimization techniques into previous simulation approaches, enabling directional control of the simulation process according to the user-designed optimization target. For the convenience of the community, we implemented the O-PIPP approach into a Python package and a website application. We showed that the O-PIPP can generate more precise neural spatial patterns of healthy and diseased mosaics compared to previous phenomenological approaches. Notably, through modeling the retinal neural circuitry with O-PIPP-simulated retinitis pigmentosa cone mosaics, we elucidated how the cone mosaic rearrangement impacted the information processing of ganglion cells. The O-PIPP provides a precise and universal tool to simulate realistic mosaics, which could help to investigate the function of retinal mosaics in vision.