#### Wallstyouth

##### Vice President

*distribution. So I must settle for some best distribution X = {xij}. My goal is to find X such that I minimize the error from the*

*ideal**distribution given the constraints on each items partitioning.*

*ideal*Here’s how I set it up for MATLAB’s fmincon:

Objective: min f(x) = sum(sqrt(( X / F – 1)^2)

Such that,

Constraint 1 (c(x) <= 0):

c(x) = - X*Q + A, where A = [a1, a2, …,am] and ai < qi for all I (in my problem A is each securities’ minimum tradable lot)

Constraint 2 (ceq(x) = 0):

ceq(x) = mod(X*Q, L), where L = [l1, l2, …lm] and li | ai for all I (in my problem L is each securities’ minimum tradable increment)

Constraint 3 (Aeq*X = beq): to ensure column sum of xij = 1 for all j.

Aeq(x) = ones(m, m*n) (m*n columns since MATLAB treats guess R x C matrix x0 as (R*C x 1) vector.

beq(x) = ones(1, m)

Boundaries:

lb = zeros (no short allocations)

ub = ones (max allocation is 100%)

I keep getting the MaxFunEvals error. I’ve tried kicking up the count but it doesn’t help. I think the problem is: set up wrong, poorly conditioned, getting bogged down on “flat spot” of f(x), I’m sure others… Can anyone suggest how to make this better or a better way of doing this? Thanks in advance.