# Constrained Opt. with Non-linear Obj and Constraints

#### Wallstyouth

##### Vice President
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.

#### Tsotne

##### Well-Known Member
could we put this into a code editor? We might get a solution.

#### Andy Nguyen

##### Member
Fixed that for you. Copy and paste directly from Word is a pain.

#### Tsotne

##### Well-Known Member
I evaluated it and I think first of all you have a logic error.

Aeq(x) = ones(m, m*n)

Why don't split the matrix into n row vectors, (or m column vectors but its harder) and it'll make your vector easier to manipulate.

I keep getting the MaxFunEvals error.

I think you have defined the matrix boundaries incorrectly (not sure though) . You can divide the matrix into n rows and remove irrelevant rows if they all contain elements all equal to 0. BTW, is this the only method you want to evaluate the problem with? There are many optimization algorithms I am aware. Not this one. Take simplex, dual-simplex, modified simplexes(can also be converted for nonlinear optimizations), Newton - Raphson, Karmarkar... depending on whether the problem is linear or nonlinear.

Replies
3
Views
2K
Replies
0
Views
590
Replies
9
Views
3K
Replies
2
Views
31K
Replies
0
Views
825