using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication17
{
class Program
{
static void Main(string[] args)
{
int n = 5;
int k = 250;
int c = 2;
int h = 1;
int[] demand=new int []{0,220,280,360,140,270};
int[,] Dmd=new int[6,6];
int[,] x=new int[6 ,6 ] ;
int[,] inv = new int[6, 6];
inv[0, 0] = 0;
int[,] setup=new int [6,6];
int[,] cost = new int[6, 6];
int[,] cost_trans = new int[6, 6];
int[][] cost_copy = new int[6][];
int[,] cost_min = new int[6, 6];
int[,] cost_p = new int[6, 6];
int[,] cost_v = new int[6, 6];
int[,] Cost_v = new int[6, 6];
int[,] cost2 = new int[6, 6];
int[] min_cost = new int[6];
//upper triangle Dmd
for (int i =1; i <= n;i++ )
{
for (int j = i; j <= n;j++ )
{
Dmd[i,j]=Dmd[i,j-1]+demand[j];
Console.WriteLine("Dmd [{0},{1}],{2}",i,j, Dmd[i, j]);
Console.WriteLine("......");
}
}
//cost_p
for (int i = 1; i <= n; i++)
{
for (int j = i; j <= n; j++)
{
cost_p[i,j]=k+c*Dmd[i, j] ;
Console.WriteLine(" cost_p [{0},{1}],{2}", i, j, cost_p[i, j]);
Console.WriteLine("......");
}
}
//inventory upper triangle cost_v
for (int i = 2; i <= n; i++)
{
for (int j = 1; j <= n; j++)
{
inv[i-1, j] = Dmd[i,j];
cost_v[i - 1,j] = h * inv[i - 1, j];
Console.WriteLine("inv: [{0},{1}],{2},cost_inv: [{0},{1}],{3}", i - 1, j, inv[i - 1, j], cost_v[i - 1, j]);
Console.WriteLine("......");
}
Console.WriteLine("......");
}
// Cost_v
for (int i = 1; i <= n-1; i++)
{
for (int j = 1; j <= n; j++)
{
for (int q =i; q <= n; q++){
Cost_v[i, j] += cost_v[q, j];
}
Console.WriteLine("Cost_v: [{0},{1}],{2},cost_v: [{0},{1}],{3}", i, j, Cost_v[i, j], cost_v[i , j]);
}
}
//cost
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= n; j++)
{
cost[i, j] += Cost_v[i, j]+cost_p[i,j];
Console.WriteLine("cost: [{0},{1}],{2},", i, j,cost[i, j]);
}
}
//cost_copy
for (int i = 1; i <= n; i++)
{
cost_copy[i - 1] = new int[i];
for (int j = 1; j <= i; j++)
{
if (j== 1)
{
cost_copy[i-1][j-1] = cost[j, i];
}
else
{
cost_copy[i - 1][j - 1] = cost_copy[j - 2].Min() + cost[j, i];
}
Console.WriteLine(" cost_copy: [{0}][{1}],{2} ", i, j, cost_copy[i - 1][j - 1]);
}
}
//cost_min
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= i; j++)
{
cost_trans[i, j] = cost_copy[i-1][ j-1];
Console.WriteLine(" cost_trans[{0}][{1}] {2} ", i, j, cost_trans[i, j] );
}
}
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= n; j++)
{
cost_min[i, j] = cost_trans[j,i];
Console.WriteLine(" cost_min[{0}][{1}] {2} ", i, j, cost_min[i, j]);
}
}
Console.Read();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication17
{
class Program
{
static void Main(string[] args)
{
int n = 5;
int k = 250;
int c = 2;
int h = 1;
int[] demand=new int []{0,220,280,360,140,270};
int[,] Dmd=new int[6,6];
int[,] x=new int[6 ,6 ] ;
int[,] inv = new int[6, 6];
inv[0, 0] = 0;
int[,] setup=new int [6,6];
int[,] cost = new int[6, 6];
int[,] cost_trans = new int[6, 6];
int[][] cost_copy = new int[6][];
int[,] cost_min = new int[6, 6];
int[,] cost_p = new int[6, 6];
int[,] cost_v = new int[6, 6];
int[,] Cost_v = new int[6, 6];
int[,] cost2 = new int[6, 6];
int[] min_cost = new int[6];
//upper triangle Dmd
for (int i =1; i <= n;i++ )
{
for (int j = i; j <= n;j++ )
{
Dmd[i,j]=Dmd[i,j-1]+demand[j];
Console.WriteLine("Dmd [{0},{1}],{2}",i,j, Dmd[i, j]);
Console.WriteLine("......");
}
}
//cost_p
for (int i = 1; i <= n; i++)
{
for (int j = i; j <= n; j++)
{
cost_p[i,j]=k+c*Dmd[i, j] ;
Console.WriteLine(" cost_p [{0},{1}],{2}", i, j, cost_p[i, j]);
Console.WriteLine("......");
}
}
//inventory upper triangle cost_v
for (int i = 2; i <= n; i++)
{
for (int j = 1; j <= n; j++)
{
inv[i-1, j] = Dmd[i,j];
cost_v[i - 1,j] = h * inv[i - 1, j];
Console.WriteLine("inv: [{0},{1}],{2},cost_inv: [{0},{1}],{3}", i - 1, j, inv[i - 1, j], cost_v[i - 1, j]);
Console.WriteLine("......");
}
Console.WriteLine("......");
}
// Cost_v
for (int i = 1; i <= n-1; i++)
{
for (int j = 1; j <= n; j++)
{
for (int q =i; q <= n; q++){
Cost_v[i, j] += cost_v[q, j];
}
Console.WriteLine("Cost_v: [{0},{1}],{2},cost_v: [{0},{1}],{3}", i, j, Cost_v[i, j], cost_v[i , j]);
}
}
//cost
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= n; j++)
{
cost[i, j] += Cost_v[i, j]+cost_p[i,j];
Console.WriteLine("cost: [{0},{1}],{2},", i, j,cost[i, j]);
}
}
//cost_copy
for (int i = 1; i <= n; i++)
{
cost_copy[i - 1] = new int[i];
for (int j = 1; j <= i; j++)
{
if (j== 1)
{
cost_copy[i-1][j-1] = cost[j, i];
}
else
{
cost_copy[i - 1][j - 1] = cost_copy[j - 2].Min() + cost[j, i];
}
Console.WriteLine(" cost_copy: [{0}][{1}],{2} ", i, j, cost_copy[i - 1][j - 1]);
}
}
//cost_min
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= i; j++)
{
cost_trans[i, j] = cost_copy[i-1][ j-1];
Console.WriteLine(" cost_trans[{0}][{1}] {2} ", i, j, cost_trans[i, j] );
}
}
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= n; j++)
{
cost_min[i, j] = cost_trans[j,i];
Console.WriteLine(" cost_min[{0}][{1}] {2} ", i, j, cost_min[i, j]);
}
}
Console.Read();
}
}
}