ngspice optimizer using ngspice scripts
Friedrich Schmidt (see his web site) has intensively used circuit optimization during his development of Nonlinear loadflow computation with Spice based simulators. He has provided an optimizer using the internal ngspice scripting language (see Chapt. 17.8). His original scripts are found here. A slightly modified and concentrated set of his scripts is available from the ngspice optimizer directory.
The simple example given in the scripts is ok with current ngspice. Real circuits have still to be tested.