Bonjour,

J'ai créé un code qui execute des boucles de recherche dans des tableaux de valeurs. Parrallelement a cela, j'ai créé un objet objPuissance qui possede des attributs. Lors de mes recherches, je transferts les valeurs acceptables dans un arraylist temporaire. Ensuite je le parcoure et pour chaque objet, je recherche d'atres parametres et je mets à jour les attibuts objet par objet puis je les transfert dans un autre arraylist.
Le probleme c'est que dans mon deuxieme array list, mes attributs sont mis a jour par paquet alors qu'ils sont uniques. Je me retrouve donc avec les valeurs de gorupe de 64 objets qui ont les meme attributs puis sa passe au suivant qui est identique poiur les 64 suivants.
La je seche si quelqu'un a une idée ?

Merci



Code c# : Sélectionner tout - Visualiser dans une fenêtre à part
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
 
namespace CalculCOP
{
 
    class ObjPuissance
    {
 
        private int config;
        private double pressionGroupe1, pressionGroupe2, pressionGroupe3,pFroidTotal;
        #region//
        public int Config
        {
            get { return config; }
            set { config = value; }
        }
        public double PressionGroupe1
        {
            get { return pressionGroupe1; }
            set { pressionGroupe1 = value; }
        }
        public double PressionGroupe2
        {
            get { return pressionGroupe2; }
            set { pressionGroupe2 = value; }
        }
        public double PressionGroupe3
        {
            get { return pressionGroupe3; }
            set { pressionGroupe3 = value; }
        }
        public double PFroidTotal
        {
            get { return pFroidTotal; }
            set { pFroidTotal = value; }
        }
        #endregion
        #region//Constructeur
        public ObjPuissance()
        {            
            Config = 0;
 
            PressionGroupe1 = 0.0 ;
            PressionGroupe2 = 0.0 ;
            PressionGroupe3 = 0.0;
 
        }
 
        #endregion
    }
    class Calcul
    {
        protected static double approcheCond1 = 0.7, approcheCond2 = 0.7, approcheCond3 = 0.0, approcheCond4 = 0.3, approcheCond5 = 0.0, approcheCond6 = 0.3;
        protected static double approcheTours = 3.0, coefHRDispo = 1.05 , rendementChaudiere = 0.935,prixGaz = 32,prixElec = 32;
        protected static ArrayList ArFinal = new ArrayList();
 
        #region//Constructeur
        public Calcul()
        {
            ArFinal.Clear();
        }
        #endregion
 
 
        public ArrayList RepartitionCharge(int NumCas, double TempBulbe,int PTotalSouhaite,double TempChaudRetour,double PChaudDemandee)
        {           
 
            ArrayList ArObj = new ArrayList();
            ArrayList ArTemp = new ArrayList();           
 
            #region//Creation du array des puissances
            double[,] tabPuiss = {
 
                {50,2800,2800,2800,2450,2800,2450},
                {52,2912,2912,2912,2548,2912,2548},
                {54,3024,3024,3024,2646,3024,2646},
                {56,3136,3136,3136,2744,3136,2744},
                {58,3248,3248,3248,2842,3248,2842},
                {60,3360,3360,3360,2940,3360,2940},
                {62,3472,3472,3472,3038,3472,3038},
                {64,3584,3584,3584,3136,3584,3136},
                {66,3696,3696,3696,3234,3696,3234},
                {68,3808,3808,3808,3332,3808,3332},
                {70,3920,3920,3920,3430,3920,3430},
                {72,4032,4032,4032,3528,4032,3528},
                {74,4144,4144,4144,3626,4144,3626},
                {76,4256,4256,4256,3724,4256,3724},
                {78,4368,4368,4368,3822,4368,3822},
                {80,4480,4480,4480,3920,4480,3920},
                {82,4592,4592,4592,4018,4592,4018},
                {84,4704,4704,4592,4116,4704,4116},
                {86,4816,4816,4816,4214,4816,4214},
                {88,4928,4928,4928,4312,4928,4312},
                {90,5040,5040,5040,4410,5040,4410},
                {92,5152,5152,5152,4508,5152,4508},
                {94,5264,5264,5264,4606,5264,4606},
                {96,5376,5376,5376,4704,5376,4704},
                {98,5488,5488,5488,4802,5488,4802},
                {100,5600,5600,5600,4900,5600,4900},
                {102,5712,5712,5377,4998,5712,4998},
                {104,5824,5824,5824,5096,5824,5096},
                {105,5880,5880,5880,5145,5880,5145},
                //29:Débit HR groupe                
                {-1,0,0,1020,0,910,0},
                //30:coef retour chaud
                {-1,0,0,5.2,0,4.7,0},
                //31:coef chaud
                {-1,0.8,0.92,0.78,0.92,0.78,0.92},
                //32:debit max tours
                {-1,750,950,960,850,960,910},
                //33:P Elec pompes
                {-1,45,45,45,30,45,30}
            };
 
            #endregion
            #region//Recherche des solutions probable pour atteindre la puissance froid souhaitée
            int Compteur = 0;
            for (int i = 1 ;i<=4 ; i++)
            {
                for (int j = 2; j <= 5; j++)
                { 
                    for (int k = 3; k <= 6; k++)
                    {                        
                        if(i<j == true && j<k == true)
                        {
                            Compteur++;
                            for( int m = 0;m <= 28 ; m++)
                            {
                                for (int n = 0; n <= 28; n++)
                                {
                                    for (int o = 0; o <= 28; o++)
                                    {                                        
                                        ObjPuissance objP = new ObjPuissance();
                                        objP.Config = Compteur;
                                        objP.PFroidTotal = Convert.ToInt32(tabPuiss[m, i]) + Convert.ToInt32(tabPuiss[n, j]) + Convert.ToInt32(tabPuiss[o, k]);
                                        if (Math.Abs(objP.PFroidTotal - PTotalSouhaite) < 50)
                                        {                                           
                                                    ArTemp.Add(objP);
 
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            #endregion
            #region//Creation du array des coef par pression
            double[,] tabCoef101 = {
 
                {6.2,-1.75638 * Math.Pow(10,-7),4.95145 * Math.Pow(10,-5),-0.005541,0.3198181,-2.177478},
                {6.4,-4.9612 * Math.Pow(10,-8),6.65328 * Math.Pow(10,-6),-0.000225,0.0369987,3.084201},
                {6.6,-1.43175 * Math.Pow(10,-8),-6.5623 * Math.Pow(10,-6),0.0015121,-0.0590748,4.8701949},
                {6.8,-2.11188 * Math.Pow(10,-7),5.40515 * Math.Pow(10,-5),-0.005331,0.27574846,-1.200688}
            };
            double[,] tabCoef102 = {
 
                {6.2, -4.32302 * Math.Pow(10,-8),1.02 * Math.Pow(10,-5),-0.001329,0.11826464,1.407564},
                {6.4, -5.49983 * Math.Pow(10,-8),-2.22 * Math.Pow(10,-5),0.002581,-0.0857001,5.160205},
                {6.6, 2.13445 * Math.Pow(10,-8),-1.115 * Math.Pow(10,-5),0.001401,-0.032115,4.182547},
                {6.8, 9.71452 * Math.Pow(10,-8),-3.85 * Math.Pow(10,-5),0.004914,-0.22725748,7.929132}
            };
            double[,] tabCoef103 = {
 
                {8, -2.18845 * Math.Pow(10,-7),6.31205 * Math.Pow(10,-5),-0.006834,0.347721873,-2.782213},
                {8.3, 2.03568 * Math.Pow(10,-8),-1.58218 * Math.Pow(10,-5),0.0026067,-0.1367737,6.124236},
                {8.6, 1.03649 * Math.Pow(10,-8),-1.14351 * Math.Pow(10,-5),0.0020072,-0.10597544,5.5252708},
                {8.9, 8.44408 * Math.Pow(10,-8),-3.5123 * Math.Pow(10,-5),0.0047143,-0.2375741,7.7355792}
            };
            double[,] tabCoef104 = {
 
               {6.2, -4.32302 * Math.Pow(10,-8),1.02 * Math.Pow(10,-5),-0.001329,0.11826464,0.407564},
                {6.4, -5.49983 * Math.Pow(10,-8),-2.22 * Math.Pow(10,-5),0.002581,-0.0857001,3.160205},
                {6.6, 2.13445 * Math.Pow(10,-8),-1.115 * Math.Pow(10,-5),0.001401,-0.032115,5.182547},
                {6.8, 9.71452 * Math.Pow(10,-8),-3.85 * Math.Pow(10,-5),0.004914,-0.22725748,2.929132}
            };
            double[,] tabCoef105 = {
 
                {8, -2.18845 * Math.Pow(10,-7),6.31205 * Math.Pow(10,-5),-0.006834,0.347721873,-1.782213},
                {8.3, 2.03568 * Math.Pow(10,-8),-1.58218 * Math.Pow(10,-5),0.0026067,-0.1367737,5.124236},
                {8.6, 1.03649 * Math.Pow(10,-8),-1.14351 * Math.Pow(10,-5),0.0020072,-0.10597544,4.5252708},
                {8.9, 8.44408 * Math.Pow(10,-8),-3.5123 * Math.Pow(10,-5),0.0047143,-0.2375741,6.7355792}
            };
            double[,] tabCoef106 = {
 
               {6.2, -4.32302 * Math.Pow(10,-8),1.02 * Math.Pow(10,-5),-0.001329,0.11826464,0.407564},
                {6.4, -5.49983 * Math.Pow(10,-8),-2.22 * Math.Pow(10,-5),0.002581,-0.0857001,6.160205},
                {6.6, 2.13445 * Math.Pow(10,-8),-1.115 * Math.Pow(10,-5),0.001401,-0.032115,5.182547},
                {6.8, 9.71452 * Math.Pow(10,-8),-3.85 * Math.Pow(10,-5),0.004914,-0.22725748,6.929132}
            };
 
            #endregion           
            #region//boucle calcul
                foreach (ObjPuissance oP in ArTemp)
            {
 
                //attribution t chaud
                //oP.TRetourChaud = TempChaudRetour;
                switch (oP.Config)
                {
                    case 1:
 
                        CalculCas(oP, PChaudDemandee, TempBulbe, tabCoef101, tabCoef102, tabCoef103);
                        break;
                 }
 
            }
 
 
 
            #endregion
 
 
 
            string toto = "";
            return ArFinal;
 
        }
        private void CalculCas(ObjPuissance oP1,double PChaudDemandee, double TempBulbe, double[,] tabCoef101, double[,] tabCoef102, double[,] tabCoef103)
        {
 
            #region//Calcus Cas
            for (int p = 0; p <= 3; p++)
            {
                for (int q = 0; q <= 3; q++)
                {
                    for (int r = 0; r <= 3; r++)
                    {
 
                        #region//Attribution valeurs pression groupe
                        oP1.PressionGroupe1 = tabCoef101[p, 0];
                        oP1.PressionGroupe2 = tabCoef102[q, 0];
                        oP1.PressionGroupe3 = tabCoef103[r, 0];
                        #endregion
 
 
 
                        ArFinal.Insert(0,oP1);
 
                    }
                }
            }
 
            #endregion
        }
 
 
    }
 
 
 
 
}