optimatika / ojAlgo

oj! Algorithms
http://ojalgo.org
MIT License
463 stars 208 forks source link

ERC Portfolio optimization #16

Closed jeanr84 closed 8 years ago

jeanr84 commented 8 years ago

Hi,

I am currently trying to use this library to solve ERC portfolio optimization but I am not sure that this library is able to do that.

The function I have to minimize is on the top of the page 7 at http://thierry-roncalli.com/download/erc.pdf.

Could you please tell me if ojAlgo is able to resolve this quadratic optimization problem ?

Thanks for your help.

apete commented 8 years ago

I won't do your homework for you. What have you done, and what problems did you encounter?

jeanr84 commented 8 years ago

I have written my constraints : 0 <= y_i <= 1 with i = 1...N and y a vector of size N AND sum(y_i) >= C

But my problem is that I don't know what Expression to add in order to change the objective function and match my objective function which use the term (y_i * (X y)_i - y_j * (X \ y)_j)^2 with X a squared matrix of size N

I tried to develop this term and found some terms like C * y_i^2 * y_j^2

But the problem is that I don't understand how to implement these kind of term. I understood that I can implement : C * x^2 or C * x * y with myVar.set(x, x, C) or myVar.set(x, y, C)

But I don't know how to handle more complex expressions.

I will be very happy to hear some explanation from you.

apete commented 8 years ago

The ojAlgo models and solvers can only handle linear and/or quadratic terms.

One way to handle terms of higher degree is Sequential Quadratic Programming.

https://en.wikipedia.org/wiki/Sequential_quadratic_programming

With ojAlgo you have to do that part yourself. It shouldn't be too hard, and I know it’s been done before.

You have two main options:

1) Write a master algorithm that iteratively modifies, and solves, an ExpressionsBasedModel

2) Don’t use ExpressionsBasedModel, but implement a new solver in the org.ojalgo.optimisation.convex package (utilising what is already there)

If you do this and it turns out well you may consider contributing the results back to ojAlgo. The org.ojalgo.finance.portfolio package could get an ERC portfolio, and org.ojalgo.optimisation.convex package could get an SQP solver.

/Anders

On 31 mars 2016, at 23:50, jeanr84 notifications@github.com wrote:

I have written my constraints : 0 <= y_i <= 1 with i = 1...N and y a vector of size N AND sum(y_i) >= C

But my problem is that I don't know what Expression to add in order to change the objective function and match my objective function which use the term (y_i * (X y)_i - y_j * (X \ y)_j)^2 with X a squared matrix of size N

I tried to develop this term and found some terms like C * y_i^2 * y_j^2

But the problem is that I don't understand how to implement these kind of term. I understood that I can implement : C * x^2 or C * x * y with myVar.set(x, x, C) or myVar.set(x, y, C)

But I don't know how to handle more complex expressions.

I will be very happy to hear some explanation from you.

— You are receiving this because you commented. Reply to this email directly or view it on GitHub