0

I am facing a problem and I would be grateful to anyone that could help. The problem is the following:

Consider that we have a vector D = [D1;D2;D3;...;DN] and a set of time instances TI = {t1,t2,t3,...,tM}. Each element of vector D, Di, corresponds to a subset of TI. For example D1 could correspond to time instances {t1,t2,t3} and D2 to {t2,t4,t5}.

I would like to find the combination of elements of D that corresponds to all elements of TI, without any of these being taken into account more than once, and at the same time minimizes the cost function sum(Dj). Dj are elements of vector D and each one corresponds to a set of time instances.

Let me give an example. Let us consider a vector

D = [15;10;5;2;35;15;25;25;25;30;45;5;1;40] 

and a set

TI={5,10,15,20,25,30} 

Each of D elements corresponds to

{[5 15];[5 20];[5 25];[5 30];[5 15 20];[5 20 25];[5 15 30];[5 20 25 30];[10 15];[10 20];[10 25];[10 15 20];[10 15 20 25];[10 30]} 

respectively, e.g. D(1)=15 corresponds to time instance [5 15].

The solution that the procedure has to come up with is that the combination of D(4) and D(12), i.e. 2 and 1 respectively, has the minimum sum and correspond to all time instances.

I have to mention that the procedure has to be able to work with large vectors.

Thanks for every attempt to help!

Shai
  • 111,146
  • 38
  • 238
  • 371
ToLos Mil
  • 63
  • 1
  • 6
  • My approach is the following: I start using combntns function and I'm trying several combinations of the elements of D. After that i check for which combinations all time instances are considered and none is taken into account twice. Then i take as the solution the combination with the minimum sum. My problem is that my approach is really slow and i'm looking for different approaches that could make the procedure faster. – ToLos Mil Mar 04 '13 at 16:40
  • 1
    use matlab's `bintprog` – Shai Mar 04 '13 at 16:50
  • I just got through. Please correct me if I'm wrong, but this is what I think: you have a set of time instances. Then you have a set of some of its subsets, and each subset has a weight. And you would then like to reconstruct the whole set with minimal cost? – Dedek Mraz Mar 04 '13 at 16:51
  • @DedekMraz And the weight should be binary. – Min Lin Mar 04 '13 at 16:56
  • @Shai Could you elaborate because the implementation of bintprog is not that clear to me. Thanks. – ToLos Mil Mar 04 '13 at 17:03
  • @ApostolosMilioudis - see @MinLin's [answer](http://stackoverflow.com/a/15207017/1714410) on how to use `bintprog` – Shai Mar 04 '13 at 18:25
  • @Shai Consider that you called bintprog and the solution corresponds to the minimum but is not exactly what you want. Can you recall bintprog and say that it should not take into account the solution x that gave earlier? – ToLos Mil Apr 10 '13 at 13:57
  • @ToLosMil - consider adding a constraint that exclude the previous solution. – Shai Apr 10 '13 at 14:59
  • @Shai I thought about it but I couldn't come up with a way to do that. Do you have you any idea? – ToLos Mil Apr 11 '13 at 10:08
  • @ToLosMil - open another question about it. – Shai Apr 11 '13 at 10:46
  • @Shai This is the [link](http://stackoverflow.com/q/15947453/2067480) of the new question – ToLos Mil Apr 11 '13 at 11:23

1 Answers1

1

The binary weight vector x places a weight on each D_i.

Let f=[D1;D2;...;DN].

Column j of A, A_j is a binary vector.

A_jk is 1 if D_j corresponds to Tk, else is zero.

The problem is:

min f^T*x  s.t.  A*x=1;

Then use bintprog to solve.

x = bintprog(f,[],[],A,ones(M,1))
Min Lin
  • 3,177
  • 2
  • 19
  • 32
  • Thank you very much for your effort and help! – ToLos Mil Mar 05 '13 at 07:13
  • Consider that you called bintprog and the solution corresponds to the minimum but is not exactly what you want. Can you recall bintprog and say that it should not take into account the solution x that gave earlier? – ToLos Mil Apr 10 '13 at 13:57
  • integer programming cannot garantee global optimal. It is possible that you have a solution that is better than what intprog produce. – Min Lin Apr 10 '13 at 14:37