+ Reply to Thread
Results 1 to 2 of 2

Generate costs between to matrix

  1. #1
    Registered User
    Join Date
    05-02-2015
    Location
    Norrköping
    MS-Off Ver
    MSWIN64
    Posts
    1

    Generate costs between to matrix

    Hello!

    I am working on a SPP(set partitioning problem). My problem is to give every each "set"(vector) a cost(aka distance traveled).

    To give you a quick briefing. There are eight customer and one depot. Every customer has a demand which needs to be served. Since there are eight customers there are 2^8=256 different combinations of sets. For instance one set could be the vector (1 0 0 0 0 0 1 0)^T. This vector means that in this set the truck is serving customer 1 and customer 8. So the traveling route of this truck is 0(depot)-1-8-0, which gives the distance 41+32+73=146. I need to do this to all 256 vectors, ergo give them a cost. When I have a cost on all different vectors I will use AMPL/CPLEX to generate the cheapest combination of vectors in order to serve all customers but my problem as I said at the moment is to give all of the 256 vectors a "price" (kilometers traveled).

    This is my distance matrix
    CUst 0 1 2 3 4 5 6 7 8
    0 0 41 9 31 56 61 26 48 73
    1 41 0 47 32 73 42 22 13 32
    2 9 47 0 30 49 61 34 56 79
    3 31 32 30 0 41 30 36 45 58
    4 56 73 49 41 0 54 74 86 96
    5 61 42 61 30 54 0 58 53 48
    6 26 22 34 36 74 58 0 24 52
    7 48 13 56 45 86 53 24 0 29
    8 73 32 76 58 96 48 58 29 0

    I think I managed to attach the whole Excel file. If you have any further questions please ask!!

    best rgds

    Will
    Attached Files Attached Files
    Last edited by arsenalwille; 05-02-2015 at 07:46 AM.

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Generate costs between to matrix

    try this user defined function

    Please Login or Register  to view this content.

    Open the VBA editor by hitting Alt F11.
    Insert a new module with Insert - Module
    Paste in the above function
    Go back to the sheet by hitting Alt F11.

    In E12, enter =GetCost(E3:E10,$H$28:$P$36)

    Remember to save the workbook as a macro enabled workbook .xlsm
    Martin

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 6
    Last Post: 06-19-2015, 04:49 AM
  2. Replies: 3
    Last Post: 07-28-2014, 08:57 PM
  3. [SOLVED] Generate list from matrix
    By Biffer in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-29-2014, 08:30 AM
  4. how to generate report based on adding costs of particular category
    By hoser in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 12-20-2007, 06:58 PM
  5. Generate specific matrix
    By jiyed, m in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 11-10-2005, 05:20 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1