1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
|
public class Projet {
public static void main(String[] args) {
int CoutStockage[] = {0, 0, 0, 2, 3, 5, 7};
int Demandei[] = {0, 9, 17, 14, 18, 11, 17};
int CoutFabrication[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 22, 25, 30, 33, 37, 40};
int p = 6;
int Xmax=16;
int Xmin=10;
int Sinit=3;
int Smin=3;
int Smax=6;
int Resultat[][] = new int[p+1][Smax+1];
int Kmin = 0, Kmax = 0;
int M, N, C;
// periode 1
for (int i=1;i<2;i++){
System.out.println("\n periode : "+i);
//Pour l de SMin à SMax faire
for (int l=Smin;l<=Smax;l++){
System.out.println("\n l de : "+l);
M = Demandei[i]+l-Xmax;
N = Demandei[i]+l-Xmin;
// Calculer Kmax
if(M > Sinit){
System.out.println("\n Kmin est : "+M);
}
else {
Kmin = Sinit;
System.out.println("\n Kmin est : "+Kmin);
}
// Calculer Kmin
if(N < Sinit){
System.out.println("\n Kmax est : "+N);
}
else {
Kmax = Sinit;
System.out.println("\n Kmax est : "+Kmax);
}
if(Kmax < Kmin){
System.out.println("\n\tCout(V"+(+i+","+l)+ ") = Ce cout ne peut pas etre calculer, Il est jusqu'à l'infinis ");
}
else if(Kmax > Kmin){
System.out.println("\n\tCout(V"+(+i+","+l)+ ") = Ce cout ne peut pas etre calculer, Il est jusqu'à l'infinis");
}
else{
C = CoutStockage[l]+CoutFabrication[l+Demandei[i]-Sinit];
Resultat[i][l] = C;
System.out.println("\n\tCout(V"+(+i+","+l)+ ") = "+Resultat[i][l]) ;
}
}
}
// periode 2
for (int i=2;i<=p;i++){
System.out.println("\n periode : "+i);
//Pour l de SMin à SMax faire
for (int l=Smin;l<=Smax;l++){
System.out.println("\n l de : "+l);
M = Demandei[i]+l-Xmax;
N = Demandei[i]+l-Xmin;
// Calculer Kmax
if(M > Smin){
System.out.println("\n Kmin est : "+M);
}
else {
Kmin = Smin;
System.out.println("\n Kmin est : "+Kmin);
}
// Calculer Kmin
if(N < Smax){
System.out.println("\n Kmax est : "+N);
}
else {
Kmax = Smax;
System.out.println("\n Kmax est : "+Kmax);
}
if(Kmax > Kmin){
for(int k =Kmin; k<=Kmax;k++){
C = CoutStockage[l]+ CoutFabrication[l+Demandei[i]-k]+Resultat[i-1][k];
Resultat[i][l] = C;
System.out.println("\n\tCout(V"+(+i+","+l)+ ") = "+Resultat[i][l]) ;
}
}
else if(Kmax == Kmin){
for(int k =Kmin; k<=Kmax;k++){
C = CoutStockage[l]+CoutFabrication[l+Demandei[i]-k]+Resultat[i-1][k];
Resultat[i][l] = C;
System.out.println("\n\tCout(V"+(+i+","+l)+ ") = "+Resultat[i][l]) ;
}
}
else{
System.out.println("\n\tCout(V"+(+i+","+l)+ ") = Ce cout ne peut pas etre calculer, Il est jusqu'à l'infinis ");
}
}
}
}
} |
Partager