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
| public void résoudre_Click_1(object sender, EventArgs e)
{
int nbr_con = Convert.ToInt32(txtcon.Text);
int nbr_var = Convert.ToInt32(txtvar.Text);
decimal[] Simpl = new decimal[(nbr_var + 2) * (nbr_con + 1)];
decimal[] sol = new decimal[nbr_var];
decimal[] Donnees = new decimal[(nbr_var + 2) * (nbr_con + 1)];
int i = 0;
while (i < nbr_var)
{
Simpl[Convert.ToInt16( (nbr_con * nbr_var )+ 2 + i)] =(this.Controls["CofonctiObjec" + i.ToString()] as NumericUpDown).Value;
i++;
}
i = 0;
while (i <nbr_con)
{
j = 0;
while (j < nbr_var)
{
Simpl[Convert.ToInt16( i * (nbr_var + 2) + j)] =(this.Controls["CofContrainte" + i.ToString()] as NumericUpDown).Value;
j++;
}
Simpl[Convert.ToInt16( i * (nbr_var + 2) + j + 1)] = -1;
try { Simpl[Convert.ToInt16(i * (nbr_var + 2) + j)] = (this.Controls["CofSecoMembre" + i.ToString()] as NumericUpDown).Value; }
catch(Exception ){}
i++;
}
Simplex S = new Simplex();
Resultat = S.Simplexe(Simpl, nbr_var, nbr_con, sol, z, mot);
mot += "\n\t*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-RESULTAT:*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\n";
if (Resultat != 0)
{
mot += "\nLe probleme admet une solution optimale :\t\n -Z =" + z[0] + "\n\n\tavec\t";
for (i = 0; i < nbr_var; i++)
mot += "\n\n X" + (i + 1) + "=\t" + (sol[Convert.ToInt16(i)]);
mot += "\n";
}
else
mot += "\n\"Le n'admet pas de solution!!!\"";
MessageBox.Show(mot, "DONNEES");
} |
Partager