0

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?

P. Khoza
  • 21
  • 4

1 Answers1

1

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);
}
Alex Fleischer
  • 9,276
  • 2
  • 12
  • 15
  • Thank you, is abs() also supported by the cplex concert technology if I am using c++? – P. Khoza Dec 13 '21 at 09:38
  • Yes : IloAbs returns the absolute value of its argument. – Alex Fleischer Dec 13 '21 at 09:46
  • Hi Alex,I am getting an error when I use abs as indicated above. The error says: No matching function for call to abs. Why is this the case? – P. Khoza Dec 14 '21 at 11:55
  • IloAbs returns the absolute value of its argument. Concert Technology offers predefined functions that return an expression from an algebraic function on expressions. These predefined functions also return a numeric value from an algebraic function on numeric values as well. IloAbs returns the absolute value of its argument. What Is Extracted IloAbs is extracted by an instance of IloCplex and linearized automatically. – Alex Fleischer Dec 14 '21 at 12:09
  • Thank you Alex, it works well. – P. Khoza Dec 15 '21 at 03:58