What to use for customized minimization of the sum of a function

4 views (last 30 days)
Assuming I have a set of employees (ex: 5) to assign to a set of offices (ex: 3).(This is not my real problem but I simplified it to understand the concept then apply it to my problem)
What I want at the end is to have a matrix of this kind
Assignment =[1 2
3 0
4 5]
The rows correspond to the offices. In each row, I have the employees assigned to each office. I made the computation of the costs for each employee and I want to minimize the TotalCost which is like the sum of all the employees costs
minimize TotalCost=sum(Costs)
I have written a function to get me a starting feasible assignment
Assignment0=[1 2
0 0
3 4 5]
and I want to get as result the assignment with the minimum TotalCost. I have a constraint on the offices (each office has a limited capacity so it can't have more employee assigned to it than this capacity) Besides, the cost for each employee picking an office depends partially of the numbers of other employees who picked the same office.
I have other another constraint on which office an employee can choose (each employee can not necessarily pick anyone of all offices).
What I did is that for unauthorized offices (which an employee can't have), I did put a big value=Inf so that such office is not picked.
So what should I use to get Assignment as result which minimizes the FinalCost
I am actually trying to implement an algorithm which looks like this to solve the problem
  1. Get a starting feasible assignment
  2. Compute the CurrentCost for each employee (with the selected office)
  3. Compute the possible costs for each employee(if he changes his office)
  4. Get the minimum possible cost (MinPossibleCost=min(PossibleCosts)) for each employee
  5. FinalCost=CurrentCost-MinPossibleCost
  6. Minimize sum(FinalCost)
I computed the matrices/vectors for all lines from 1 to 5 What I am stuck at is what to use to solve the last line and get the assignment.

Accepted Answer

Matt J
Matt J on 7 Jun 2016
This sounds like a linear integer programming problem and therefore intlinprog is the appropriate tool here, not fmincon.
I would set it up like this. Let X be a 3x5 matrix of binary variables such that X(i,j)=1 means you assign employee j to room i. Let f(i,j) be the cost of doing so. You want to choose X to minimize the linear objective f(:).'*X(:) subject to certain constraints. For example, one constraint is obviously that an employee is not assigned to multiple rooms, so sum(X,1)<=1. This constraint can be put in the matrix-vector form A*X(:)<=1 required by intlinprog by constructing A as
A=kron(eye(5),ones(1,3))
  5 Comments
etudiant_is
etudiant_is on 7 Jun 2016
I added the constraints. I can't solve the problems from each employee's side because their choices impact each other.
Matt J
Matt J on 7 Jun 2016
Edited: Matt J on 7 Jun 2016
the cost for each employee picking an office depends partially of the numbers of other employees who picked the same office.
Based on that, it appears that the cost function is non-linear. You will therefore have to use ga() as discussed here. Other than that, though, you would still set up the problem as I said, with binary decision variables X(i,j) to represent the room assignments and constraint matrices defined as I proposed to express any linear constraints.

Sign in to comment.

More Answers (0)

Categories

Find more on Linear Programming and Mixed-Integer Linear Programming in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!