forum.alglib.net

ALGLIB forum
It is currently Thu Apr 25, 2024 11:38 am

All times are UTC


Forum rules


1. This forum can be used for discussion of both ALGLIB-related and general numerical analysis questions
2. This forum is English-only - postings in other languages will be removed.



Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Optimizations: Are aggregated bound constraints possible?
PostPosted: Thu May 19, 2011 2:43 pm 
Offline

Joined: Tue Jan 11, 2011 10:44 am
Posts: 9
Actually, I am using the minBleic optimizer, where I can nicely set 1:1 boundary conditions.

Example: w1, w2, w3

w1 between 23 and 37% works
w2 between 15 and 85% works
w3 between 2 and 99% works
w1+w2+w3 = 100% works

But, in another example:

Is something like w1 + w2 between 7 and 21% possible with no other contraints at the single w-level?
Is it possible to have incomplete boundary limitation sets?

Thanks.


Top
 Profile  
 
 Post subject: Re: Optimizations: Are aggregated bound constraints possible
PostPosted: Fri May 20, 2011 5:00 am 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 906
You can achieve such result with linear constraints. In particular, 7%<=w1+w2<=21% can be rewritten as combination of two linear constraints:
w1+w2>=7%
w1+w2<=21%

You can set arbitrary combination of boundary and linear constraints, and you can use arbitrary numner of linear constraints (you can even have more constraints than variables). Does it solve your problem?


Top
 Profile  
 
 Post subject: Re: Optimizations: Are aggregated bound constraints possible
PostPosted: Fri May 20, 2011 6:41 am 
Offline

Joined: Tue Jan 11, 2011 10:44 am
Posts: 9
I am happy that it's possible, but I don't see how to solve my concrete problem:

Having ten weights w1 ... w10, I would like to define the following:

C1) w1 between 0 and 11%
C2) w2 between 29% and 79%
C3) sum of (w3, w4, w5, w6) between 8 and 21%, no constraints otherwise on w3 ... w6
C4) w7 between 6 and 18%
C5) sum of (w8 and w9) between 7 and 21%, no constraints otherwise on w8 ... w9
C6) w10 between 7 and 21%
C7) sum of all weights must be 100%
C8) All weights must be positive
C9) sum of (w2, w3, w4, w5, w7) <= 45%
C10) sum of (w9, w7, w6, w8) <= 58%

Without sum constraints, I just defined a combination of minbleic.setbc minbleic.setlc methods using all weights and that works fine, but how would the syntax look like for constraints of the C3 or C5 type, then?


Top
 Profile  
 
 Post subject: Re: Optimizations: Are aggregated bound constraints possible
PostPosted: Fri May 20, 2011 7:56 am 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 906
Maybe I don't understand something, but you can reformulate C3 as combination of two linear inequality constraints, which can be set by minbleic.setlc, as I told in my previous post. It will become

w3+w4+w5+w6>=8%
w3+w4+w5+w6<=21%

Such pair of linear constraints won't influence individual weights (w3...w6) - just their sum will be constrained. minbleic.setlc supports both equality and inequality constraints. And there is no problem in passing mix of equality/inequality constraints to minbleic.setlc Thus your constraints can be formulated as follows:

C1) boundary one
C2) boundary one
C3) two linear inequality ones
C4) boundary one
C5) two linear inequality ones
C6) boundary one
C7) linear equality one
C8) All weights must be positive
C9) linear inequality one
C10) linear inequality one


Top
 Profile  
 
 Post subject: Re: Optimizations: Are aggregated bound constraints possible
PostPosted: Fri May 20, 2011 8:17 am 
Offline

Joined: Tue Jan 11, 2011 10:44 am
Posts: 9
Actually, splitting the thing is not the problem. That's well understood.

My question addresses the syntax of partial constraint vectors.
Up to now, I have always used constraints specifications where all weights had their own limitations, there were no "holes".

Let's assume I have one constraint, which only considers the sum of the weights e.g. w1, w2 and w6 between 2 and 15%.

I can split it in two constraints like you said.

But still:
How does the actual code like for this particular example?
What values do I have to set for those weights that are not part of the constraint? Just a comma like in VBA?
Assuming that only the position in the vector matters to define which weight should be constrained. Must I define a placeholder for w3, w4 and w5 in the definition in this particular example?


Top
 Profile  
 
 Post subject: Re: Optimizations: Are aggregated bound constraints possible
PostPosted: Fri May 20, 2011 8:35 am 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 906
You should just set corresponding entries of the constraints matrix to zeros. Pair of constraints above will have zeros in the first two and last four columns. See http://www.alglib.net/translator/man/ma ... nbleic_d_2 for example - zero in the "[1,0,2]" denotes variable which is not present in the sum.


Top
 Profile  
 
 Post subject: Re: Optimizations: Are aggregated bound constraints possible
PostPosted: Fri May 20, 2011 8:37 am 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 906
In particular, your matrix of constraints will look like:

0 0 1 1 1 1 0 0 0 0 0.08
0 0 1 1 1 1 0 0 0 0 0.21
0 0 0 0 0 0 0 0 1 1 0.07
0 0 0 0 0 0 0 0 1 1 0.21
1 1 1 1 1 1 1 1 1 1 1.00
0 1 1 1 1 0 1 0 0 0 0.45
0 0 0 0 0 1 1 1 1 0 0.58


Top
 Profile  
 
 Post subject: Re: Optimizations: Are aggregated bound constraints possible
PostPosted: Fri May 20, 2011 9:10 am 
Offline

Joined: Tue Jan 11, 2011 10:44 am
Posts: 9
Got it!

Thank you!!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 78 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group