help-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-glpk] GLPK and Smoothing Splines


From: Mineo, Eduardo Phillipe
Subject: [Help-glpk] GLPK and Smoothing Splines
Date: Thu, 6 Oct 2016 22:19:09 -0300

I still got no luck with this problem. I changed my approach though
and that's what I'm doing. If someone could give me some light, I'd
appreciate.

I have a curve fitting problem with smoothing B-splines. So, I have a
set I of n points x[i] and y[i] and I want to calculate a linear
(degree=1) interpolating spline with n coefficients such that the
curve would be approximated by S(x) = sum {i in I} a[i] * B(x)[i],
B(x) being the basis of B-splines of degree 1 which I'm evaluating
with GNU Scientific Library.

The linear program is formulated in such a way that we can give a
lambda factor for smoothing effects, in other words, if lambda = 0 we
end up with a interpolating function and with lambda = infinity we end
up with a line between extreme points.

The analytical problem is this, http://oi65.tinypic.com/lid0z.jpg,
where n is the number of points, N = n - 2 and m = 2 (degree 1).



###############################################
set I; # dataset, = n
set J; # coefficients of the spline, in linear case = n
set N; # = n - 2

param X {i in I};
param Y {i in I};
param B {x in X} {j in J} # B-spline basis calculated with GSL
param B' {x in X} {j in J} # B-spline basis first derivatives
calculated with GSL
param lambda;

var error {i in I}, >= 0;

minimize error: sum {i in I} error;

s.t. c1 {i in I} : sum {j in J} a[j] * B(x[i])[j] + erro[i] >= y[i];
s.t. c2 {i in I} : sum {j in J} a[j] * B(x[i])[j] - erro[i] <= y[i];
s.t. c3 {i in N} : sum {j in J} a[j] * lambda * (B'(x[i+1])[j] -
B'(x[i])[j]) - erro[i] <= 0;
s.t. c4 {i in N} : sum {j in J} a[j] * lambda * (B'(x[i])[j] -
B'(x[i+1])[j]) - erro[i] <= 0;

solve;
###############################################

When I solve with lambda = 0, I get a perfect interpolation as you can
see here: http://oi65.tinypic.com/2l96t09.jpg , pretty much the same
thing when I run COBS library in R:
http://oi63.tinypic.com/33mn2x2.jpg

But when I increase the lambda, the chart diverges
http://oi66.tinypic.com/2z513lv.jpg while the COBS library in R gives
me a strict line: http://oi68.tinypic.com/kdplbb.jpg

Certainly the error is how I formulated the constraints c3 and c4, but
I am out of ideas...

Ref: http://franke.nau.edu/pin-ng/working/cobs_cs.pdf

Thanks!



reply via email to

[Prev in Thread] Current Thread [Next in Thread]