Previous studies have used numerical methods to optimize the hyperpolarizability of a one-dimensional quantum system. These studies were used to suggest properties of one-dimensional organic molecules, such as the degree of modulation of conjugation, that could potentially be adjusted to improve the nonlinear-optical response. However, there were no conditions set on the optimized potential energy function to ensure that the resulting energies were consistent with what is observed in real molecules. Furthermore, the system was placed in a one-dimensional box with infinite walls, forcing the wavefunctions to vanish at the ends of the molecule. In the present work, the walls are separated by a distance much larger than the molecule's length; and, the variations of the potential energy function are restricted to levels that are more typical of a real molecule. In addition to being a more physically-reasonable model, our present approach better approximates the bound states and approximates the continuum states — which are usually ignored. We find that the same universal properties continue to be important for optimizing the nonlinear-optical response, though the details of the wavefunctions differ from previous results.