Wallstyouth
Vice President
- Joined
- 5/25/07
- Messages
- 116
- Points
- 28
I have a collection of m items T = [t1, t2, …tm] each of quantity Q = [q1, q2, …qm]. I need to distribute these m items to n people P = [p1, p2, …pn]. Ideally, the items would be distributed according to a fixed schedule, an m x n F = [fij], where fij = fkj for all j and any i,k in [1,m] and sum(F) = 1. Unfortunately there are restrictions on how each item may be partitioned that prevent this ideal 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.
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.
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.