Click here to Skip to main content
15,898,035 members
Home / Discussions / Algorithms
   

Algorithms

 
GeneralRe: AI ? Pin
Mohammad Dayyan31-Mar-09 0:30
Mohammad Dayyan31-Mar-09 0:30 
QuestionDividing rectangle in specified proportional pieces [modified] Pin
skelet0n19-Mar-09 20:39
skelet0n19-Mar-09 20:39 
AnswerRe: Dividing rectangle in specified proportional pieces Pin
CPallini20-Mar-09 6:00
mveCPallini20-Mar-09 6:00 
GeneralRe: Dividing rectangle in specified proportional pieces Pin
Ravadre21-Mar-09 6:24
Ravadre21-Mar-09 6:24 
GeneralRe: Dividing rectangle in specified proportional pieces Pin
skelet0n23-Mar-09 18:48
skelet0n23-Mar-09 18:48 
GeneralRe: Dividing rectangle in specified proportional pieces Pin
CPallini23-Mar-09 22:21
mveCPallini23-Mar-09 22:21 
GeneralRe: Dividing rectangle in specified proportional pieces Pin
skelet0n23-Mar-09 23:10
skelet0n23-Mar-09 23:10 
GeneralRe: Dividing rectangle in specified proportional pieces Pin
CPallini24-Mar-09 0:24
mveCPallini24-Mar-09 0:24 
A hint on the procedure.
You should maximize the sum of the rectangle areas with some constraint (hence the use of Lagrange multipliers).
You requirements give the following constants (supposing all rectangles have the same size):
  • N the total number of rectangles
  • w and h, giving the ratio of each rectangle, i.e. ratio w:h
  • W and H, the width and the height of the bounding rectangle


and the following variables
  • r the number of rows of the rectangle grid
  • c the number of columns of the rectangle grid
  • x defined so that x*w = rectangle width and x*h =rectangle height


You should maximize the total area, i.e. N*h*w*x, while obeying to the following constraints:

  • N = r*c
  • W >= c * w * x
  • H >= r * h * x


Using (generalized ?) Lagrange multipliers you may write the function L:
L(x,r,c,j,k,l) = N*h*w*x - (r*c - N)*j - (c*w*x - W)*l - (r*h*x -H)*k

where j,l,k are the Lagrange multipliers.

Now you've to find an extreme of it (i.e. all first derivatives with respect the parameters x,r,c,j,k,l should be zero) and verify it's a solution for your problem.
I hope I didn't make silly mistakes.
Good luck.

If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.

This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke

[My articles]

GeneralRe: Dividing rectangle in specified proportional pieces Pin
73Zeppelin24-Mar-09 1:32
73Zeppelin24-Mar-09 1:32 
GeneralRe: Dividing rectangle in specified proportional pieces Pin
CPallini24-Mar-09 3:20
mveCPallini24-Mar-09 3:20 
GeneralRe: Dividing rectangle in specified proportional pieces Pin
73Zeppelin25-Mar-09 2:23
73Zeppelin25-Mar-09 2:23 
GeneralRe: Dividing rectangle in specified proportional pieces Pin
supercat924-Mar-09 12:32
supercat924-Mar-09 12:32 
GeneralRe: Dividing rectangle in specified proportional pieces Pin
CPallini24-Mar-09 13:31
mveCPallini24-Mar-09 13:31 
GeneralRe: Dividing rectangle in specified proportional pieces Pin
supercat931-Mar-09 19:24
supercat931-Mar-09 19:24 
QuestionParsing Algorithm to extract results from popular search engines Pin
SaravananXSC18-Mar-09 20:50
SaravananXSC18-Mar-09 20:50 
AnswerRe: Parsing Algorithm to extract results from popular search engines Pin
Yusuf18-Mar-09 23:57
Yusuf18-Mar-09 23:57 
QuestionRe: Parsing Algorithm to extract results from popular search engines Pin
Eddy Vluggen20-Mar-09 1:35
professionalEddy Vluggen20-Mar-09 1:35 
AnswerRe: Parsing Algorithm to extract results from popular search engines Pin
SaravananXSC25-Mar-09 7:44
SaravananXSC25-Mar-09 7:44 
AnswerRe: Parsing Algorithm to extract results from popular search engines Pin
Eddy Vluggen25-Mar-09 9:02
professionalEddy Vluggen25-Mar-09 9:02 
GeneralRe: Parsing Algorithm to extract results from popular search engines Pin
Pete O'Hanlon20-Mar-09 2:56
mvePete O'Hanlon20-Mar-09 2:56 
AnswerRe: Parsing Algorithm to extract results from popular search engines Pin
Ravadre21-Mar-09 6:31
Ravadre21-Mar-09 6:31 
GeneralRe: Parsing Algorithm to extract results from popular search engines Pin
SaravananXSC25-Mar-09 8:00
SaravananXSC25-Mar-09 8:00 
AnswerRe: Parsing Algorithm to extract results from popular search engines Pin
Mohammad Dayyan21-Mar-09 10:14
Mohammad Dayyan21-Mar-09 10:14 
QuestionJustification is requested. please help me resolve this problem. Phd and Prof Pin
Cryptogrpahy18-Mar-09 14:18
Cryptogrpahy18-Mar-09 14:18 
AnswerRe: Justification is requested. please help me resolve this problem. Phd and Prof Pin
Mark Churchill18-Mar-09 16:10
Mark Churchill18-Mar-09 16:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.