L1 regularisation in cplex

79 Views Asked by At

I am trying to perform optimization which uses the L1 regularisation method.

However, I am using cplex and I do not see an obvious way of performing L1 regularisation when I use cplex. Can someone please help?

1

There are 1 best solutions below

5
Alex Fleischer On

Let me start with the example curve fitting from Model Building

Without regularization:

int n=...;
range points=1..n;
float x[points]=...;
float y[points]=...;



// y== b*x+a

dvar float a;
dvar float b;

minimize sum(i in points) (b*x[i]+a-y[i])^2;

subject to
{

}

execute
{
writeln("b=",b);
writeln("a=",a);
}

The Lasso Version (L1 regularisation) would be:

int n=...;
range points=1..n;
float x[points]=...;
float y[points]=...;

float lambda=0.1;

// y== b*x+a

dvar float a;
dvar float b;

minimize sum(i in points) (b*x[i]+a-y[i])^2+lambda*(abs(a)+abs(b));

subject to
{

}

execute
{
writeln("b=",b);
writeln("a=",a);
}