public void OptimizeTestCaseOne()
        {
            Supplier[] suppliers = new Supplier[3];
            Consumer[] consumers = new Consumer[4];

            suppliers[0] = new Supplier(new int[4] { 2, 3, 2, 4 }, 30);
            suppliers[1] = new Supplier(new int[4] { 3, 2, 5, 1 }, 40);
            suppliers[2] = new Supplier(new int[4] { 4, 3, 2, 6 }, 20);

            consumers[0] = new Consumer(20);
            consumers[1] = new Consumer(30);
            consumers[2] = new Consumer(30);
            consumers[3] = new Consumer(10);

            NorthwestCornerMethod ncMethod = new NorthwestCornerMethod(suppliers, consumers);

            Table solution = ncMethod.GetSolution();

            PotentialsMethod potentialsMethod = new PotentialsMethod(solution);

            while (!potentialsMethod.IsOptimal())
            {
                potentialsMethod.Otimize();
            }

            Assert.AreEqual(solution.GetTotalTransportationsPrice(), 170);
        }
Exemple #2
0
        public Table(Supplier[] suppliers, Consumer[] consumers)
        {
            _rows = new TableRow[suppliers.Length];
            _columns = new TableColumn[consumers.Length];

            CreateRows(suppliers);
            CreateColumns(consumers);
        }
Exemple #3
0
        public TableRow(int index, Supplier supplier)
            : base(index)
        {
            _supplier = supplier;
            _stock = supplier.GetStock();

            Cells = new Cell[supplier.GetRates().Length];
            CreateCells();
        }
        public void TotalPriceTestCaseOne()
        {
            Supplier[] suppliers = new Supplier[3];
            Consumer[] consumers = new Consumer[3];

            suppliers[0] = new Supplier(new int[3]{2, 5, 2}, 180);
            suppliers[1] = new Supplier(new int[3] { 7, 7, 13 }, 300);
            suppliers[2] = new Supplier(new int[3] { 3, 6, 8 }, 120);

            consumers[0] = new Consumer(110);
            consumers[1] = new Consumer(350);
            consumers[2] = new Consumer(140);

            VogelsMethod method = new VogelsMethod(suppliers, consumers);

            Assert.AreEqual(2970, method.GetSolution().GetTotalTransportationsPrice());
        }
        public void TotalPriceTestCaseTwo()
        {
            Supplier[] suppliers = new Supplier[3];
            Consumer[] consumers = new Consumer[4];

            suppliers[0] = new Supplier(new int[4] { 5, 2, 1, 8 }, 10);
            suppliers[1] = new Supplier(new int[4] { 2, 1, 2, 3 }, 10);
            suppliers[2] = new Supplier(new int[4] { 4, 8, 1, 4 }, 20);

            consumers[0] = new Consumer(14);
            consumers[1] = new Consumer(15);
            consumers[2] = new Consumer(5);
            consumers[3] = new Consumer(6);

            VogelsMethod method = new VogelsMethod(suppliers, consumers);

            Assert.AreEqual(100, method.GetSolution().GetTotalTransportationsPrice());
        }
        public void TotalPriceTestCaseThree()
        {
            Supplier[] suppliers = new Supplier[3];
            Consumer[] consumers = new Consumer[4];

            suppliers[0] = new Supplier(new int[4] { 2, 3, 2, 4 }, 30);
            suppliers[1] = new Supplier(new int[4] { 3, 2, 5, 1 }, 40);
            suppliers[2] = new Supplier(new int[4] { 4, 3, 2, 6 }, 20);

            consumers[0] = new Consumer(20);
            consumers[1] = new Consumer(30);
            consumers[2] = new Consumer(30);
            consumers[3] = new Consumer(10);

            VogelsMethod method = new VogelsMethod(suppliers, consumers);

            Assert.AreEqual(170, method.GetSolution().GetTotalTransportationsPrice());
        }
        public void IsOptimalTestCaseTwo()
        {
            Supplier[] suppliers = new Supplier[3];
            Consumer[] consumers = new Consumer[4];

            suppliers[0] = new Supplier(new int[4] { 2, 3, 2, 4 }, 30);
            suppliers[1] = new Supplier(new int[4] { 3, 2, 5, 1 }, 40);
            suppliers[2] = new Supplier(new int[4] { 4, 3, 2, 6 }, 20);

            consumers[0] = new Consumer(20);
            consumers[1] = new Consumer(30);
            consumers[2] = new Consumer(30);
            consumers[3] = new Consumer(10);

            NorthwestCornerMethod ncMethod = new NorthwestCornerMethod(suppliers, consumers);

            Table solution = ncMethod.GetSolution();

            PotentialsMethod potentialsMethod = new PotentialsMethod(solution);

            Assert.False(potentialsMethod.IsOptimal());
        }
        public void IsOptimalTestCaseOne()
        {
            Supplier[] suppliers = new Supplier[3];
            Consumer[] consumers = new Consumer[4];

            suppliers[0] = new Supplier(new int[4] { 2, 3, 2, 4 }, 30);
            suppliers[1] = new Supplier(new int[4] { 3, 2, 5, 1 }, 40);
            suppliers[2] = new Supplier(new int[4] { 4, 3, 2, 6 }, 20);

            consumers[0] = new Consumer(20);
            consumers[1] = new Consumer(30);
            consumers[2] = new Consumer(30);
            consumers[3] = new Consumer(10);

            VogelsMethod vogelsMethod = new VogelsMethod(suppliers, consumers);

            Table solution = vogelsMethod.GetSolution();

            PotentialsMethod potentialsMethod = new PotentialsMethod(solution);

            Assert.True(potentialsMethod.IsOptimal());
        }
        public void OptimizeTestCaseThree()
        {
            Supplier[] suppliers = new Supplier[3];
            Consumer[] consumers = new Consumer[4];

            suppliers[0] = new Supplier(new int[4] { 5, 2, 1, 8 }, 10);
            suppliers[1] = new Supplier(new int[4] { 2, 1, 2, 3 }, 10);
            suppliers[2] = new Supplier(new int[4] { 4, 8, 1, 4 }, 20);

            consumers[0] = new Consumer(14);
            consumers[1] = new Consumer(15);
            consumers[2] = new Consumer(5);
            consumers[3] = new Consumer(6);

            NorthwestCornerMethod ncMethod = new NorthwestCornerMethod(suppliers, consumers);

            Table solution = ncMethod.GetSolution();

            PotentialsMethod potentialsMethod = new PotentialsMethod(solution);

            while (!potentialsMethod.IsOptimal())
            {
                potentialsMethod.Otimize();
            }

            Assert.AreEqual(solution.GetTotalTransportationsPrice(), 100);
        }
        public void OptimizeTestCaseTwo()
        {
            Supplier[] suppliers = new Supplier[4];
            Consumer[] consumers = new Consumer[5];

            suppliers[0] = new Supplier(new int[5] { 9, 5, 7, 10, 18 }, 78);
            suppliers[1] = new Supplier(new int[5] { 36, 29, 6, 38, 40 }, 94);
            suppliers[2] = new Supplier(new int[5] { 41, 20, 11, 25, 19 }, 29);
            suppliers[3] = new Supplier(new int[5] { 30, 28, 13, 39, 50 }, 86);

            consumers[0] = new Consumer(49);
            consumers[1] = new Consumer(60);
            consumers[2] = new Consumer(78);
            consumers[3] = new Consumer(50);
            consumers[4] = new Consumer(50);

            NorthwestCornerMethod ncMethod = new NorthwestCornerMethod(suppliers, consumers);

            Table solution = ncMethod.GetSolution();

            PotentialsMethod potentialsMethod = new PotentialsMethod(solution);

            while (!potentialsMethod.IsOptimal())
            {
                potentialsMethod.Otimize();
            }

            Assert.AreEqual(solution.GetTotalTransportationsPrice(), 4870);
        }
 protected FirstlySolutionMethod(Supplier[] suppliers, Consumer[] consumers)
 {
     _table = new Table.Table(suppliers, consumers);
 }
 public VogelsMethod(Supplier[] suppliers, Consumer[] consumers)
     : base(suppliers, consumers)
 {
 }
 public NorthwestCornerMethod(Supplier[] suppliers, Consumer[] consumers)
     : base(suppliers, consumers)
 {
 }
Exemple #14
0
 private void CreateRows(Supplier[] suppliers)
 {
     for(int i = 0; i < _rows.Length; i++)
     {
         _rows[i] = new TableRow(i, suppliers[i]);
     }
 }