# forum.alglib.net

ALGLIB forum
 It is currently Fri Mar 01, 2024 9:37 pm

 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.

 Page 1 of 1 [ 8 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: Optimizations: Are aggregated bound constraints possible?Posted: Thu May 19, 2011 2:43 pm

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

 Post subject: Re: Optimizations: Are aggregated bound constraints possiblePosted: Fri May 20, 2011 5:00 am

Joined: Fri May 07, 2010 7:06 am
Posts: 902
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

 Post subject: Re: Optimizations: Are aggregated bound constraints possiblePosted: Fri May 20, 2011 6:41 am

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

 Post subject: Re: Optimizations: Are aggregated bound constraints possiblePosted: Fri May 20, 2011 7:56 am

Joined: Fri May 07, 2010 7:06 am
Posts: 902
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

 Post subject: Re: Optimizations: Are aggregated bound constraints possiblePosted: Fri May 20, 2011 8:17 am

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

 Post subject: Re: Optimizations: Are aggregated bound constraints possiblePosted: Fri May 20, 2011 8:35 am

Joined: Fri May 07, 2010 7:06 am
Posts: 902
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

 Post subject: Re: Optimizations: Are aggregated bound constraints possiblePosted: Fri May 20, 2011 8:37 am

Joined: Fri May 07, 2010 7:06 am
Posts: 902
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

 Post subject: Re: Optimizations: Are aggregated bound constraints possiblePosted: Fri May 20, 2011 9:10 am

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

Thank you!!

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 8 posts ]

 All times are UTC

#### Who is online

Users browsing this forum: No registered users and 4 guests

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

Search for: