简体   繁体   中英

L1 regularisation in cplex

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?

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);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM