Re: [ojAlgo-user] ExpressionsBasedModel and absolute constraints
Mathematics, linear algebra and optimisation
Brought to you by:
apete
From: Anthony E. <ant...@al...> - 2015-02-16 13:30:25
|
Hi Anders. Thanks for that - it certainly is really a 'how do I do this with ojalgo' and in particular will benefit anyone using ojalgo for long/short portfolio optimisation problems where they wish to constrain the limits on the degree of long/short bias that the portfolio can have. I guess that its a case of adding an Expression to the ExpressionBasedModel that encapsulates this 'sum of absolute values' modelling formulation. I have looked at the very flexible setLinearFactor methods for the Expression class and am wondering if i need to somehow use the setLinearFactors(List<Variable>, Access1D) or possibly create a variable that is the absolute value of the existing variable (the weights of the portfolio in this specific case) and then use the setLinearFactor(Variable, Number) method of the Expression class. If I can understand how to code this withing the ojalgo framework I'm sure it will benefit the community as I've looked into this for a while and I must be missing something. Thanks - appreciate your time and help with this. Tony On 16/02/15 13:11, Anders Peterson wrote: > This is a modelling question not directly related to ojAlgo, Strictly speaking you're off topic for this mailing list, but I'm leaning towards allowing it if the discussion context is "how do I do this with ojAlgo". I will however only participate if the discussion leads to more concrete questions regarding ojAlgo. > > /Anders > > > >> On 16 feb 2015, at 13:01, Anthony Edwards <ant...@al...> wrote: >> >> Hi >> >> I am using an expressions based model (for a portfolio optimisation >> problem) and can add a constraint such that the sum of the weights in >> the portfolio is equals to 1 as follows: >> >> Expression balanceExpr = model.addExpression("Balance"); >> for (int i=0; i<ers.length; i++) >> balanceExpr.setLinearFactor(i, BigMath.ONE); >> balanceExpr.lower(BigMath.ONE); >> balanceExpr.upper(BigMath.ONE); >> >> What I would like to do is add another constrains such that the sum of >> the absolute values of the weights is less than 2. Any idea how I can >> do this? There is no setAbsoluteValueLinearFactor function or any way >> of doing this as far as I can see. >> >> Any pointers would be gratefully appreciated! >> >> Thanks >> >> Tony >> >> ------------------------------------------------------------------------------ >> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server >> from Actuate! Instantly Supercharge Your Business Reports and Dashboards >> with Interactivity, Sharing, Native Excel Exports, App Integration & more >> Get technology previously reserved for billion-dollar corporations, FREE >> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk >> _______________________________________________ >> ojAlgo-user mailing list >> ojA...@li... >> https://lists.sourceforge.net/lists/listinfo/ojalgo-user >> >> > > ------------------------------------------------------------------------------ > Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server > from Actuate! Instantly Supercharge Your Business Reports and Dashboards > with Interactivity, Sharing, Native Excel Exports, App Integration & more > Get technology previously reserved for billion-dollar corporations, FREE > http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk > _______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user |