# General purpose solver

## Main Question or Discussion Point

Can anyone recommend a good general purpose solver for optimisation problems. E.g. something better than Excels' Solver add-in. I'm looking for something that is relatively quick and easy to use, and prefereably can be made to work with Excel spreadsheets without too much effort.

Thanks..

Mathematica 6.0.

You can do constrained nonlinear optimization with the maximize and minimize command.

For example, I want to maximize a profit function of two variables that is not linear subject to the constraints on two item prices, p1 and p2:

constraint 1
region of viable prices that leads to non-negative demand:
$$10395 \text{p1}+5150\geq 9983 \text{p2}\land \left(\left(\text{p1}>\frac{3000037}{199980}\land 10 \text{p1}\leq 37 \text{p2}+\frac{3000037}{19998}\right)\lor \left(\text{p2}\geq 0\land 0\leq \text{p1}\land \text{p1}\leq \frac{3000037}{199980}\right)\right)$$

constraint 2
budget constraint is equivalent to:
$$236059065 \text{p1}=921404813 \text{p2}+1676144666$$

And the approximate profit function:
$$-1.31380\times 10^6+133216. \text{p1}-5934.12 \text{p1}^2-172176. \text{p2}+22612.1 \text{p1} \text{p2}-629.842 \text{p2}^2$$

So the command I enter is this:
$$\text{Maximize}\left[\left\{profit[p1,p2],10395 \text{p1}+5150\geq 9983 \text{p2}\land \left(\left(\text{p1}>\frac{3000037}{199980}\land 10 \text{p1}\leq 37 \text{p2}+\frac{3000037}{19998}\right)\lor \left(\text{p2}\geq 0\land 0\leq \text{p1}\land \text{p1}\leq \frac{3000037}{199980}\right)\right),$$$$-\frac{20 (236059065 \text{p1}-921404813 \text{p2}-7017594666)}{106829}=1000000\right\},\{\text{p1},\text{p2}\}]$$
The list is of the form {profit[p1,p2], constraint 1, constraint 2} and it gives the EXACT answer which is really long but can be approximated by throwing //N after it.
$$\{2.22971\times 10^6,\{\text{p1}\to 133.135,\text{p2}\to 32.2893\}\}$$So for my fictitious company, the max profit will be about 2.2 million dollars, achieved when the price of the first item is 133.14 and the other is 32.29. Incidentally, this was a basic model of a company that sells a hardcover and softcover edition of a book, the cheaper one being the latter of course.

In a word: Mathematica 6.0.