[Numpy-discussion] How can I constrain linear_least_squares to integer solutions?
Charles R Harris
charlesr.harris@gmail....
Wed Nov 28 00:07:30 CST 2007
On Nov 27, 2007 9:51 PM, Mark Schmucker <Mark.Schmucker@4dtechnology.com>
wrote:
> Hi,
>
>
>
> I have successfully used LinearAlgebra.linear_least_squares to estimate
> solutions to continuous functions. The coefficients returned in that case
> are of course floating-point values.
>
>
>
> Now I have a problem where some of the terms are continuous but some must
> be constrained to integer multiples. As a simple example,
>
>
>
> y = c1 * x^2 + c0 * x
>
>
>
> where c1 is floating-point in the usual way, but c0 can only be
> integer-valued. (The actual problem has many more terms.)
>
>
>
> Can anyone tell me how to constrain some of the coefficients to integer
> values?
>
> This is not a trivial problem, as you can see by googling mixed integer
least squares (MILS). Much will depend on the nature of the parameters, the
number of variables you are using in the fit, and how exact the solution
needs to be. One approach would be to start by rounding the coefficients
that must be integer and improve the solution using annealing or genetic
algorithms to jig the integer coefficients while fitting the remainder in
the usual least square way, but that wouldn't have the elegance of some of
the specific methods used for this sort of problem. However, I don't know of
a package in scipy that implements those more sophisticated algorithms,
perhaps someone else on this list who knows more about these things than I
can point you in the right direction.
Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20071127/8d6aa4ae/attachment.html
More information about the Numpy-discussion
mailing list