Maximize a exponential equation using scalanlp breeze optmize library

195 views Asked by At

I have a formula (known as Chritoffersen test) like this: ∑(1-C(i) )(log⁡(a * b * D(i)^(b-1))-1))

where a = ∑(1 - C(i)/∑D(i)^b and b is double value The summation is over i from 1 to n ( +ve integer) and C & D are equal length vectors.

I want to find the maximum value of the first expression for 0 < b < infinity

This is how I reached so far. I couldn't find log, or how to express that b range (If I say b is a double, then those expression & constraint don't work, if I say b is a Real then those multiplication don't work)

val lp = new LinearProgram()
    import lp._

    val d = DenseVector(0.1, 0.23, 0.45)
    val c = DenseVector(2.3, 4.5, 0.45)
    val b= Real()

    import breeze.numerics._

    val one  = Integer()

    val apowerb = (one - (c(0)+ c(1) + c(2))) * pow(Real(pow(d(0), b)) + Real(pow(d(1), b)) + Real(pow(d(2), b)), -1)

    val dpowerbminusone = Real(pow(d(0), b-1)) + Real(pow(d(1), b-1))+ Real(pow(d(2), b-1))

    val objective : lp.Expression = (1 - (c(0)+c(1)+c(2)))(apowerb.*(b).*(dpowerbminusone) -1)

    val constraintb = ((objective)
      subjectTo ( b < Double.PositiveInfinity )
      )

Is it possible to express this in breeze to find optimize solution?

1

There are 1 answers

0
dlwh On

The Breeze LinearProgram solver supports only linear programs so it can't help with this problem. (It's actually mostly just a wrapper about the Apache Commons Math SimplexSolver, which also can't solve nonlinear problems.)

We have a general gradient optimizer LBFGS that will work but you'll need to provide the gradient yourself.