Difference between revisions of "Assessment SET08112 2011 Hard"

From Progzoo
Jump to: navigation, search
(Question 07)
(Question 08)
Line 242: Line 242:
 
</question>
 
</question>
  
==Question 08==
+
==Question 13==
<question className='Q08' copyFile='product.txt cluster.txt Cluster.class Address.class Location.class Product.class Tray.class'>
+
<question className='Q13' copyFile='product.txt cluster.txt Cluster.class Address.class Location.class Product.class Tray.class'>
List those items that are in one tower only.
+
Give a location that can be cleared by moving the products to one or more, partially full locations. Give details of the location to be cleared and a list of the destinations.
 
<prog><![CDATA[
 
<prog><![CDATA[
 
import java.util.HashMap;
 
import java.util.HashMap;
 +
import java.util.ArrayList;
 
/*
 
/*
  * Question 8 Single Tower Report
+
  * Question 13 Consolidation Move
 
  */
 
  */
public class Q08 {
+
public class Q13 {
  
 
   public static void main(String[] args) throws Exception{
 
   public static void main(String[] args) throws Exception{
 
     Cluster c = new Cluster("product.txt","cluster.txt");
 
     Cluster c = new Cluster("product.txt","cluster.txt");
     //Map product to tower map
+
     //Map product to location list
     HashMap<String,HashMap<Integer,Boolean>> tm = new HashMap<String,HashMap<Integer,Boolean>>();
+
     HashMap<String,ArrayList<Location>> tm = new HashMap<String,ArrayList<Location>>();
 +
    boolean done = false;
 
     for (Location loc : c.towers)
 
     for (Location loc : c.towers)
 
     {
 
     {
       if (loc.product!=null)
+
       if (loc.product==null)
 +
        continue;
 +
      if (!tm.containsKey(loc.product))
 +
        tm.put(loc.product, new ArrayList<Location>());
 +
      tm.get(loc.product).add(loc);
 +
    }
 +
    for (String p : tm.keySet())
 +
    {
 +
      ArrayList<Location> l = tm.get(p);
 +
      int freeSpace = 0;
 +
      for (Location loc : l)
 +
      {
 +
        freeSpace += c.products.get(p).ppl-loc.quantity;
 +
      }
 +
      for (Location loc : l)
 
       {
 
       {
         if (!tm.containsKey(loc.product))
+
        int ppl = c.products.get(loc.product).ppl;
           tm.put(loc.product, new HashMap<Integer,Boolean>());
+
         if (loc.quantity<freeSpace-(ppl-loc.quantity))
        tm.get(loc.product).put(loc.addr.tower, true);
+
        {
 +
           int toBeRelocated = loc.quantity;
 +
          System.out.printf("relocating from loc: %s to relocate: %d\n",
 +
              loc.addr.toString(),
 +
              toBeRelocated);
 +
          int i = 0;
 +
          while (toBeRelocated>0)
 +
          {
 +
            Location frm = l.get(i);
 +
            if (frm != loc && frm.quantity<ppl)
 +
            {
 +
              int j = ppl-frm.quantity;
 +
              j = Math.min(j, toBeRelocated);
 +
              System.out.printf("%s add %d\n",frm.addr,j);
 +
              toBeRelocated -= j;
 +
            }
 +
            i++;
 +
          }
 +
          done = true;
 +
          break;
 +
        }
 
       }
 
       }
 +
      if (done) break;
 
     }
 
     }
    for (String p : tm.keySet())
+
  }
      if (tm.get(p).size()==1)
+
 
        System.out.printf("%s\n", p);
+
  public static String trayId(Location l)
 +
  {
 +
    return String.format("%d-%02d", l.addr.tower, l.addr.tray);
 
   }
 
   }
 
}
 
}
Line 273: Line 312:
 
<answer><![CDATA[
 
<answer><![CDATA[
 
import java.util.HashMap;
 
import java.util.HashMap;
 +
import java.util.ArrayList;
 
/*
 
/*
  * Question 8 Single Tower Report
+
  * Question 13 Consolidation Move
 
  */
 
  */
public class Q08 {
+
public class Q13 {
  
 
   public static void main(String[] args) throws Exception{
 
   public static void main(String[] args) throws Exception{
 
     Cluster c = new Cluster("product.txt","cluster.txt");
 
     Cluster c = new Cluster("product.txt","cluster.txt");
     //Map product to tower map
+
     //Map product to location list
     HashMap<String,HashMap<Integer,Boolean>> tm = new HashMap<String,HashMap<Integer,Boolean>>();
+
     HashMap<String,ArrayList<Location>> tm = new HashMap<String,ArrayList<Location>>();
 +
    boolean done = false;
 
     for (Location loc : c.towers)
 
     for (Location loc : c.towers)
 
     {
 
     {
       if (loc.product!=null)
+
       if (loc.product==null)
 +
        continue;
 +
      if (!tm.containsKey(loc.product))
 +
        tm.put(loc.product, new ArrayList<Location>());
 +
      tm.get(loc.product).add(loc);
 +
    }
 +
    for (String p : tm.keySet())
 +
    {
 +
      ArrayList<Location> l = tm.get(p);
 +
      int freeSpace = 0;
 +
      for (Location loc : l)
 +
      {
 +
        freeSpace += c.products.get(p).ppl-loc.quantity;
 +
      }
 +
      for (Location loc : l)
 
       {
 
       {
         if (!tm.containsKey(loc.product))
+
        int ppl = c.products.get(loc.product).ppl;
           tm.put(loc.product, new HashMap<Integer,Boolean>());
+
         if (loc.quantity<freeSpace-(ppl-loc.quantity))
        tm.get(loc.product).put(loc.addr.tower, true);
+
        {
 +
           int toBeRelocated = loc.quantity;
 +
          System.out.printf("relocating from loc: %s to relocate: %d\n",
 +
              loc.addr.toString(),
 +
              toBeRelocated);
 +
          int i = 0;
 +
          while (toBeRelocated>0)
 +
          {
 +
            Location frm = l.get(i);
 +
            if (frm != loc && frm.quantity<ppl)
 +
            {
 +
              int j = ppl-frm.quantity;
 +
              j = Math.min(j, toBeRelocated);
 +
              System.out.printf("%s add %d\n",frm.addr,j);
 +
              toBeRelocated -= j;
 +
            }
 +
            i++;
 +
          }
 +
          done = true;
 +
          break;
 +
        }
 
       }
 
       }
 +
      if (done) break;
 
     }
 
     }
    for (String p : tm.keySet())
 
      if (tm.get(p).size()==1)
 
        System.out.printf("%s\n", p);
 
 
   }
 
   }
 +
 +
  public static String trayId(Location l)
 +
  {
 +
    return String.format("%d-%02d", l.addr.tower, l.addr.tray);
 +
  }
 +
}
 
}]]></answer>
 
}]]></answer>
 
</question>
 
</question>

Revision as of 00:06, 4 March 2011

For picking and replenishment you should observe the following constraints:

  1. Minimise the number of locations used.

£Maximise the distribution of products across towers.

  1. Minimise the amount of movement move as few trays as possible.
  2. Use low trays.
  3. Use the edges. Put the weight at the outside edges. Avoid the centre of the tray.
  4. Balance trays. There should not be excessive weight on either the left or the right.

Question 11

No tray should weight more than 100kg. List the trays that are overloaded.


[Font] [Default] [Show] [Resize] [History] [Profile]

Question 12

List the trays where the centre of gravity is off centre by more than 10%.

  • To calculate the centre of gravity of a tray you divide the sum of the moments by the total mass on the tray.
  • The moment of a location is the mass of the location multiplied by its distance from the left edge.



[Font] [Default] [Show] [Resize] [History] [Profile]

Question 13

Give a location that can be cleared by moving the products to one or more, partially full locations. Give details of the location to be cleared and a list of the destinations.


[Font] [Default] [Show] [Resize] [History] [Profile]

Question 09

List the trays by order of weight. Show the heaviest trays first.


[Font] [Default] [Show] [Resize] [History] [Profile]

Question 10

No tower should contain more than 100 of a particular product. List those products that are in excess in a tower. Give the product code, the tower and the number of products.


[Font] [Default] [Show] [Resize] [History] [Profile]