Formalizing an allocation problem

23 views
Skip to first unread message

Jack1

unread,
Mar 18, 2020, 8:12:36 PM3/18/20
to YALMIP
I have a set "S" of 20 elements --->  x_i where i in {1, ..., 20} 
I need to allocate each element to 5 locations  --->  j in {1, ..., 5} 
Define the cost of allocating element "x_i" to location "j" by: 
f_j (x_i)
then, I would like to minimize the total cost:
\sum_j \sum_i f_j (x_i)
subject to the constraint that each element x_i can be allocated to only one location j as well as other constraints on the cost function f_j.   

I would be appreciative of a way to formalize the constraints above and tractably solve the problem via yalmip given that the cost function is differentiable and cvx.  Thank you. 

Johan Löfberg

unread,
Mar 19, 2020, 6:26:58 AM3/19/20
to YALMIP
convex is impossible as it is a combinatorial and thus requires binary variables

If d_i encodes that x_i takes value S_i, then the sum simplifies to sum d_i*f(S_i)

See logic programming/implies/modeling if-else etc in the wiki

Jack1

unread,
Mar 19, 2020, 9:34:29 AM3/19/20
to YALMIP
thank you for getting back. I reviewed your post here https://yalmip.github.io/modellingif

if I did not have a functional representation for the costs f(S_i), but, these were empirical values, then, how do I separate my space into 5*20 cases? Do I have to find a functional representation or is there another way? 

Also, not sure how to impose the allocation of one element to one location mentioned above - would be much appreciative if you can kindly help with a simple case for me to get started. 

Johan Löfberg

unread,
Mar 19, 2020, 9:39:51 AM3/19/20
to YALMIP
empirical values is a function

if x = 3 then f = 5 else if x = 9 then f = -67 etc

is 
binary d1 d2
f = d1*5 + (-67*)*d2
model = implies(d1, x == 3) + implies(d2,x==9)

etc


Reply all
Reply to author
Forward
0 new messages