СПИСОК ВИКОРИСТАНОЇ ЛІТЕРАТУРИ
Поможем в ✍️ написании учебной работы
Поможем с курсовой, контрольной, дипломной, рефератом, отчетом по практике, научно-исследовательской и любой другой работой

 

1. Ахо, Альфред, В., Хопкрофт, Джон, Ульман, Джеффи, Д. Структуры данных и алгоритмы.: Пер. с англ.:Уч. пос. – М.: Издательский дом «Вильямс», 2000. – 384 с.: ил. – Парал. тит. англ.

2. Брехов А. М., Волков В. В. Организация судостроительного производства в условиях рынка. – СПб.: Судостроение, 1992. – 224 с., ил.

3. Колде Я. К. Практикум по теории вероятностей и математической статистике: Учеб. пособие для техникумов. – М.: Высш. шк., 1991. – 157 с.: ил.

4. Полковников А.В., Корпоративная система управления проектами, Электронный офис, 1997, Октябрь

5. Полковников А.В., Линия на которой побеждают время, Электронный офис, 1997, Октябрь

 



Додаток А – Текст программи

 

using System;

using System.Drawing;

using System.Drawing.Drawing2D;

using System.Collections;

using System.ComponentModel;

using System.Windows.Forms;

using System.Data;

using System.IO;

using System.Diagnostics;

namespace WindowsApplication1

{

  public class Form1 : System.Windows.Forms.Form

  {

        private const int mx=5;

        private const int ht=8;

        private const int zz=130;

        private int n,m,k,v;

        static int /*nij,*/n_ij;

        private double Mx,S2x,Sx,X_2;

        private double L_kp_min,L_kp_max,L_kp_avg;

        private double L_kp_mat,L_kp_dsp,L_kp_otk;

        private System.Windows.Forms.MainMenu mainMenu1;

        private System.Windows.Forms.MenuItem menuItem1;

        private System.Windows.Forms.MenuItem menuItem2;

        private System.Windows.Forms.OpenFileDialog openFileDialog1;

        private ArrayList codi,codj,naim,mint,maxt;

        private double []tp_min; private double []tp_max; private double []tp_avg;

        private double []tn_min; private double []tn_max; private double []tn_avg;

        private double []R_min; private double []R_max; private double []R_avg;

        private double []r_min; private double []r_max; private double []r_avg;

        private double [,]tpn_min; private double [,]tpn_max;

private double [,]tpn_avg;

        private double [,]tnn_min; private double [,]tnn_max;

private double [,]tnn_avg;

        private double [,]tpo_min; private double [,]tpo_max;

private double [,]tpo_avg;

        private double [,]tno_min; private double [,]tno_max;

private double [,]tno_avg;

        private double [,]Rn_min; private double [,]Rn_max;

private double [,]Rn_avg;

        private double [,]Rcb_min; private double [,]Rcb_max;

private double [,]Rcb_avg;

        private double [,]C_min; private double [,]C_max; private double [,]C_avg;

        private int [,]P_min; private int [,]P_max; private int [,]P_avg;

        private double [,]C_rev_min; private double [,]C_rev_max;

private double [,]C_rev_avg;

        private int [,]P_rev_min; private int [,]P_rev_max;

private int [,]P_rev_avg;

        private System.Windows.Forms.TabControl tabControl1;

        private System.Windows.Forms.TabPage tabPage1;

        private System.Windows.Forms.TabPage tabPage2;

        private System.Windows.Forms.TabControl tabControl2;

        private System.Windows.Forms.TabPage tabPage3;

        private System.Windows.Forms.TabPage tabPage4;

        private System.Windows.Forms.TabPage tabPage5;

        private System.Windows.Forms.TabControl tabControl3;

        private System.Windows.Forms.TabPage tabPage6;

        private System.Windows.Forms.TabPage tabPage7;

        private System.Windows.Forms.TabPage tabPage8;

        private System.Windows.Forms.TabControl tabControl4;

        private System.Windows.Forms.TabPage tabPage9;

        private System.Windows.Forms.TabPage tabPage10;

        private System.Windows.Forms.DataGrid dataGrid1;

        private System.Windows.Forms.DataGrid dataGrid2;

        private System.Windows.Forms.PictureBox pictureBox1;

        private System.Windows.Forms.DataGrid dataGrid3;

        private System.Windows.Forms.PictureBox pictureBox2;

        private System.Windows.Forms.DataGrid dataGrid4;

        private System.Windows.Forms.PictureBox pictureBox3;

        private System.Windows.Forms.Label label1;

        private System.Windows.Forms.Label label2;

        private System.Windows.Forms.Label label3;

        private System.Windows.Forms.MenuItem menuItem3;

        private System.Windows.Forms.MenuItem menuItem4;

        private System.Windows.Forms.Label label4;

        private System.Windows.Forms.Label label5;

        private System.Windows.Forms.Label label6;

        private System.Windows.Forms.TabPage tabPage11;

        private System.Windows.Forms.Label label7;

        private System.Windows.Forms.Label label8;

        private System.Windows.Forms.Label label9;

        private System.Windows.Forms.PictureBox pictureBox4;

        private System.Windows.Forms.Label label10;

        private System.Windows.Forms.Button button1;

        private System.ComponentModel.Container components = null;

 

        public Form1()

        {

               InitializeComponent();

        }

        protected override void Dispose( bool disposing )

        {

               if( disposing )

               {

                      if (components != null)

                      {

                             components.Dispose();

                      }

               }

               base.Dispose( disposing );

        }

        [STAThread]

        static void Main()

        {

               Application.Run(new Form1());

        }

 

        static void Read_Data(string FileName,ArrayList codi,ArrayList codj,

ArrayList naim,ArrayList mint,ArrayList maxt)

        {

               FileStream f = new FileStream(FileName,FileMode.Open);

               StreamReader r = new StreamReader(f);

                                 

               string delimStr = "\t";

               char [] delimiter = delimStr.ToCharArray();

               string s;

               string [] split = null;

                   

               codi.Add(0);

               codj.Add(0);

               naim.Add(0);

               mint.Add(0);

               maxt.Add(0);

               while((s = r.ReadLine())!= null)

               {

                      split = s.Split(delimiter,5);    

                      codi.Add(split[0]);

                      codj.Add(split[1]);

                      naim.Add(split[2]);

                      mint.Add(split[3]);

                      maxt.Add(split[4]);

                          

               }

                   

               r.Close();

               f.Close();

        }

            

        private void ShowGrid1(DataGrid grid,ArrayList codi, ArrayList codj,

ArrayList naim, ArrayList mint, ArrayList maxt)

        {

               DataTable tab = new DataTable("tabl");

               DataColumn c0 = new DataColumn("Код работы i");

               DataColumn c1 = new DataColumn("Код работы j");

               DataColumn c2 = new DataColumn("Наименование работы");

          DataColumn c3 = new DataColumn("Минимальное время t");

               DataColumn c4 = new DataColumn("Максимальное время t");

                   

               tab.Columns.Add(c0);

               tab.Columns.Add(c1);

               tab.Columns.Add(c2);

               tab.Columns.Add(c3);

               tab.Columns.Add(c4);

               for(int i=1; i<codi.Count; i++)

               {

                      DataRow row = tab.NewRow();

                      row["Код работы i"] = codi[i];

                      row["Код работы j"] = codj[i];

                      row["Наименование работы"] = naim[i];

                      row["Минимальное время t"] = mint[i];

                      row["Максимальное время t"] = maxt[i];

                                                

                      tab.Rows.Add(row);

               }

                   

               grid.DataSource = tab;

 

        }

 

        private void ShowGrid2(DataGrid grid,double [,]C, double [,]tpn,

double [,]tpo, double [,]tnn, double [,]tno, double [,]Rn, double [,]Rcb)

        {

               int nn = (int)Math.Sqrt(C_avg.Length)-1;

               DataTable tab2 = new DataTable("tabl2");

               DataColumn c0 = new DataColumn("Код i,j");

               DataColumn c1 = new DataColumn("t(i,j)");

               DataColumn c2 = new DataColumn("tpn(i,j)");

               DataColumn c3 = new DataColumn("tpo(i,j)");

               DataColumn c4 = new DataColumn("tnn(i,j)");

               DataColumn c5 = new DataColumn("tno(i,j)");

               DataColumn c6 = new DataColumn("Rn(i,j)");

               DataColumn c7 = new DataColumn("Rcb(i,j)");

                   

               tab2.Columns.Add(c0);

               tab2.Columns.Add(c1);

               tab2.Columns.Add(c2);

               tab2.Columns.Add(c3);

               tab2.Columns.Add(c4);

               tab2.Columns.Add(c5);

               tab2.Columns.Add(c6);

               tab2.Columns.Add(c7);

                   

               string str;

               n_ij=0;

               for(int i=1; i<=nn; i++)

                      for(int j=1; j<=nn; j++)

                             if(C[i,j]>=0)

                             {

                               DataRow row = tab2.NewRow();

                                                           

                                   row["Код i,j"] = i.ToString()+"-"+j.ToString();

                                   str = String.Format("{0:F2}",C[i,j]);

                                   row["t(i,j)"] = str;

                                   str = String.Format("{0:F2}",tpn[i,j]);

                                   row["tpn(i,j)"] = str;

                                   str = String.Format("{0:F2}",tpo[i,j]);

                                   row["tpo(i,j)"] = str;

                                   str = String.Format("{0:F2}",tnn[i,j]);

                                   row["tnn(i,j)"] = str;

                                   str = String.Format("{0:F2}",tno[i,j]);

                                   row["tno(i,j)"] = str;

                                   str = String.Format("{0:F2}",Rn[i,j]);

                                   row["Rn(i,j)"] = str;

                                   str = String.Format("{0:F2}",Rcb[i,j]);

                                   row["Rcb(i,j)"] = str;

                                                                  

                                   tab2.Rows.Add(row);   n_ij++;

                             }

               grid.DataSource = tab2;

 

        }

 

        private void AlgorithmFloyda(double [,]C, int [,]P)

        {

               int i,j,k;

               int nn = (int)Math.Sqrt(C.Length)-1;

               double [,]A = new double[nn+1,nn+1];

               for(i=1; i<=nn; i++)

                      for(j=1; j<=nn; j++)

                      {

                             A[i,j] = C[i,j];

                             P[i,j] = 0;

                      }

               for(i=1; i<=nn; i++)

                      A[i,i] = 0;

               for(k=1; k<=nn; k++)

                      for(i=1; i<=nn; i++)

                             for(j=1; j<=nn; j++)

                                   if(A[i,k] + A[k,j] >A[i,j])

                                   {

                                          A[i,j]=A[i,k]+A[k,j];

                                          P[i,j]=k;

                                   }

 

        }

 

        private void Path(int [,]P, double [,]C, int i, int j, ref double l,

ref int sec)

        {

               int k;

               k=P[i,j];

               if(k!=0)

               {

                      sec=k;

                      Path(P,C,i, k, ref l, ref sec);

                      l=l+C[k,j];

                      Path(P,C,k, j, ref l, ref sec);

               }

        }

 

        private double MaxPath(double [,]C, int [,]P, int i, int j)

        {

               double l;int sec_v;

                   

               l=0;

               sec_v=0;

               Path(P,C,i, j,ref l, ref sec_v);

               if(sec_v!=0) return l+C[i,sec_v];//между ними min одна вершина –

вторая

               else return C[i,j];

        }

 

        private double GetMat(double tmin,double tmax,double tver)

        {

               double avg;

               avg = (tmin+4*tver+tmax)/6;

               return avg;

        }

 

        private double GetDsp(double tmin,double tmax)

        {

               double Ds;

               Ds = 0.4*Math.Pow(tmax-tmin, 2);

               return Ds;

        }

 

        private double GetOtk(double tmin,double tmax)

        {

               double ot;

               ot = (tmax-tmin)/6;

               return ot;

        }

 

        private void GetPar(double [,]C, double []tp,double []tn, double [,]tpn,

double [,]tpo, double [,]tno, double [,]tnn, double [,]Rn, double [,]Rcb)

        {

                          

               for(int i=1; i<=n; i++)

                      for(int j=1; j<=n; j++)

                             if(C[i,j]>=0)

                             {

                   

                                   //ранние сроки начала и окончания работы

                                   tpn[i,j]=tp[i]; tpo[i,j]=tpn[i,j]+C[i,j];

                                   //поздние сроки начала и окончания работы

                                   tno[i,j]=tn[j]; tnn[i,j]=tno[i,j]-C[i,j];

                                   //полный резерв времени работы

                                   Rn[i,j]=tno[i,j]-tpo[i,j];

                                   //свободный резерв времени работы

                                   Rcb[i,j]=tp[j]-tpo[i,j];

                             }

                   

        }

 

        private double GetNorm(Random r)

        {

               double U1,U2,V1,V2,S,X1,Norm;

               l1:

               U1 = r.NextDouble();

               U2 = r.NextDouble();

               V1 = 2*U1-1;

               V2 = 2*U2-1;

               S = V1*V1+V2*V2;

               if(S>=1) goto l1;

               X1 = V1*Math.Sqrt(-2*Math.Log(S,Math.E)/S);

                   

               Norm = X1;

               return Norm;

        }

            

        private double GetCC(Random r,double mint,double maxt,ref double Norm)

        {

                   

               double C;

               Norm = GetNorm(r);

               C = mint+Norm*(maxt-mint);

               return C;

        }

            

        private int GetMax(ArrayList codjj)

        {

               int Max;

               Max=0;

               for(int i=1; i<codi.Count; i++)

                      Max=Math.Max(Max,Convert.ToInt32(codjj[i]));

               return Max;

        }

 

        private double GetMax(double [,]C)

        {

               double Max;

               Max=0;

               int nn = (int)Math.Sqrt(C.Length)-1;

               for(int i=1; i<=nn; i++)

                      for(int j=1; j<=nn; j++)

                             if(C[i,j]>=0)

                                   Max=Math.Max(Max,C[i,j]);

               return Max;

        }

            

private void menuItem2_Click(object sender, System.EventArgs e)

        {

               int i,j;

               openFileDialog1.FileName="test.txt";

               openFileDialog1.ShowDialog();

                   

               codi = new ArrayList();

               codj = new ArrayList();

               naim = new ArrayList();

               mint = new ArrayList();

               maxt = new ArrayList();

                   

                   

               Read_Data(openFileDialog1.FileName,codi,codj,naim,mint,maxt);

                   

               ShowGrid1(dataGrid1,codi,codj,naim,mint,maxt);

                   

            

               n=GetMax(codj);

                   

            

               C_min = new double[n+1,n+1]; C_max = new double[n+1,n+1];

C_avg = new double[n+1,n+1];

               P_min = new int[n+1,n+1]; P_max = new int[n+1,n+1];

P_avg = new int[n+1,n+1];

C_rev_min = new double[n+1,n+1]; C_rev_max = new double[n+1,n+1]; C_rev_avg = new double[n+1,n+1];

               P_rev_min = new int[n+1,n+1]; P_rev_max = new int[n+1,n+1];

P_rev_avg = new int[n+1,n+1];

            

               ArrayList Li = new ArrayList();

               for(int c=0; c<zz; c++)

               {

                      for(i=1; i<=n; i++)

                             for(j=1; j<=n; j++)

                             {

                                   C_min[i,j]=-1000;

                                   C_max[i,j]=-1000;

                                   C_avg[i,j]=-1000;

                             }

                      Random r = new Random();

                      m=codi.Count;

                   

                      double nrm=0;

                          

                      for(i=1; i<m; i++)

                      {

                            C_min[Convert.ToInt32(codi[i]),

Convert.ToInt32(codj[i])]=Convert.ToDouble(mint[i]);

                             C_max[Convert.ToInt32(codi[i]),

Convert.ToInt32(codj[i])]=Convert.ToDouble(maxt[i]);

                                 

C_avg[Convert.ToInt32(codi[i]),

Convert.ToInt32(codj[i])]=GetCC(r,C_min[Convert.ToInt32(codi[i]),Convert.ToInt32(codj[i])],C_max[Convert.ToInt32(codi[i]),Convert.ToInt32(codj[i])],ref nrm);

                                 

                      }

                      for(i=1; i<=n; i++)

                             for(j=1; j<=n; j++)

                             {

                                   C_rev_min[n-j+1,n-i+1]=C_min[i,j];

                                   C_rev_max[n-j+1,n-i+1]=C_max[i,j];

                                   C_rev_avg[n-j+1,n-i+1] = C_avg[i,j];

//GetMat(C_rev_min[n-j+1,n-i+1],C_rev_max[n-j+1,

n-i+1]);

                             }

 

                      AlgorithmFloyda(C_min,P_min);

                      AlgorithmFloyda(C_rev_min,P_rev_min);

                   

                      AlgorithmFloyda(C_max,P_max);

                      AlgorithmFloyda(C_rev_max,P_rev_max);

 

                      AlgorithmFloyda(C_avg,P_avg);

                      AlgorithmFloyda(C_rev_avg,P_rev_avg);

 

                      tp_min = new double[n+1]; tp_max = new double[n+1];

tp_avg = new double[n+1];

                      tn_min = new double[n+1]; tn_max = new double[n+1];

tn_avg = new double[n+1];

                      R_min = new double[n+1]; R_max = new double[n+1];

R_avg = new double[n+1];

                      r_min = new double[n+1]; r_max = new double[n+1];

r_avg = new double[n+1];

            

      

 

                      tp_min[1]=0; tp_max[1]=0; tp_avg[1]=0;

                      for(i=2; i<=n; i++)

                      {

                             tp_min[i]=MaxPath(C_min,P_min,1,i);

                             tp_max[i]=MaxPath(C_max,P_max,1,i);

                             tp_avg[i]=MaxPath(C_avg,P_avg,1,i);

                      }

 

                   

                      L_kp_min=tp_min[n]; L_kp_max=tp_max[n]; L_kp_avg = tp_avg[n];

Li.Add(L_kp_avg);

               }

               label1.Text = "L_kp = "+String.Format("{0:F2}",L_kp_min);

               label2.Text = "L_kp = "+String.Format("{0:F2}",L_kp_max);

               label3.Text = "L_kp = "+String.Format("{0:F2}",L_kp_avg);

 

               L_kp_mat = GetMat(L_kp_min,L_kp_max,L_kp_avg); L_kp_otk =

GetOtk(L_kp_min,L_kp_max);

               L_kp_dsp = Math.Pow(L_kp_otk,2);

               tn_min[n]=L_kp_min; tn_max[n]=L_kp_max; tn_avg[n]=L_kp_avg;

                   

               for(i=2; i<=n; i++)

               {

                      tn_min[n-i+1]=L_kp_min-MaxPath(C_rev_min, P_rev_min, 1, i);

                      tn_max[n-i+1]=L_kp_max-MaxPath(C_rev_max, P_rev_max, 1, i);

                      tn_avg[n-i+1]=L_kp_avg-MaxPath(C_rev_avg, P_rev_avg, 1, i);

               }

 

               label4.Text="На критическом пути расположены следующие вершины: ";

               label5.Text="На критическом пути расположены следующие вершины: ";

               label6.Text="На критическом пути расположены следующие вершины: ";

               for(i=1; i<=n; i++)

               {

                      R_min[i]=tn_min[i]-tp_min[i];

                      R_max[i]=tn_max[i]-tp_max[i];

                      R_avg[i]=tn_avg[i]-tp_avg[i];

                          

                      if(R_min[i]==0)

                             label4.Text+=i.ToString()+" ";

                      if(R_max[i]==0)

                             label5.Text+=i.ToString()+" ";

                      if(R_avg[i]==0)

                             label6.Text+=i.ToString()+" ";

                          

               }

                   

                   

                   

               tpn_min = new double[n+1,n+1]; tpn_max = new double[n+1,n+1];

tpn_avg = new double[n+1,n+1];

               tnn_min = new double[n+1,n+1]; tnn_max = new double[n+1,n+1];

tnn_avg = new double[n+1,n+1];

           

tpo_min = new double[n+1,n+1]; tpo_max = new double[n+1,n+1];

tpo_avg = new double[n+1,n+1];

               tno_min = new double[n+1,n+1]; tno_max = new double[n+1,n+1];

tno_avg = new double[n+1,n+1];

               Rn_min = new double[n+1,n+1]; Rn_max = new double[n+1,n+1];

Rn_avg = new double[n+1,n+1];

               Rcb_min = new double[n+1,n+1]; Rcb_max = new double[n+1,n+1];

Rcb_avg = new double[n+1,n+1];

                   

               /*nij =

*/GetPar(C_min,tp_min,tn_min,tpn_min,tpo_min,tno_min,tnn_min,

Rn_min,Rcb_min);

                   

               ShowGrid2(dataGrid2,C_min,tpn_min, tpo_min, tnn_min, tno_min,

Rn_min, Rcb_min);

                                 

               /*nij =

*/GetPar(C_max,tp_max,tn_max,tpn_max,tpo_max,tno_max,tnn_max,

Rn_max,Rcb_max);

                   

               ShowGrid2(dataGrid3,C_max,tpn_max, tpo_max, tnn_max, tno_max,

Rn_max, Rcb_max);

GetPar(C_avg,tp_avg,tn_avg,tpn_avg,tpo_avg,tno_avg,tnn_avg,

Rn_avg,Rcb_avg);

                   

               ShowGrid2(dataGrid4,C_avg,tpn_avg, tpo_avg, tnn_avg, tno_avg,

Rn_avg, Rcb_avg);

                   

               k=(int)(1+3.32*Math.Log10(n));

                   

               MainStatistics(Li,out Mx,out S2x,out Sx,out X_2);

                   

               label7.Text="Матожидание T_kp="+String.Format("{0:F2}",Mx);

               label8.Text="Дисперсия T_kp = "+String.Format("{0:F2}",S2x);

               label9.Text="Ср. кв. от. T_kp="+String.Format("{0:F2}",Sx);

               label10.Text="Хі квадрат ="+String.Format("{0:F2}",X_2)+

", число ступеней свободы v="+v.ToString();

                   

        }

            

        private void MainStatistics(ArrayList x,out double Mx,out double

S2x,out double Sx,out double X_2)

        {

               int i, j;

               double /*m2, m4,*/ x_max, x_min, h;

               FileStream f = new FileStream("test.xls",FileMode.Create);

               StreamWriter w = new StreamWriter(f);

                   

               int []n_ = new int[k+1];

               double []p_ = new double [k+1];

               double []x_cp = new double [k+1];

                   

               Mx=0; S2x=0; Sx=0;

               x_max=Convert.ToDouble(x[0]);

               x_min=Convert.ToDouble(x[0]);

                   

               for(i=0; i<x.Count; i++)

               {

                      if( x_max < Convert.ToDouble(x[i]))

x_max=Convert.ToDouble(x[i]);

                      if( x_min > Convert.ToDouble(x[i]))

x_min=Convert.ToDouble(x[i]);

               }

               h=(x_max-x_min)/k;

               for(j=1; j<=k; j++)

               {

                      p_[j]=0;

                      n_[j]=0;

                      x_cp[j]=x_min+h*(j-1)+h/2;

               }

               n_[1]=1;

               for(i=0; i<x.Count; i++)

                      for(j=1; j<=k; j++)

                             if ((Convert.ToDouble(x[i]) > x_min+(j-1)*h) &&

(Convert.ToDouble(x[i]) <= x_min+j*h) )

                             {

                             n_[j]++;

                             break;

                             }

               for(i=1; i<=k; i++)

                      Mx=Mx+x_cp[i]*n_[i];

               Mx=Mx/x.Count;

               for(i=1; i<=k; i++)

                      S2x=S2x+Math.Pow(x_cp[i]-Mx,2)*n_[i];

               S2x=S2x/(x.Count-1);

               Sx=Math.Sqrt(S2x);

               X_2=0;

               for(j=1; j<=k; j++)

               {

                      p_[j]=h*Math.Exp(-Math.Pow(x_cp[j]-Mx,2)/(2*S2x))/(

Math.Sqrt(2*Math.PI)*Sx);

                      w.WriteLine(x_cp[j].ToString()+"\t"+p_[j].ToString());

                      X_2=X_2+Math.Pow(n_[j]-p_[j]*x.Count,2)/(p_[j]*x.Count);

               }

               v = k-3;

               w.Close(); f.Close();

        }

            

        private void DrawGant(Graphics g,/*int n_ij,*/double [,]C,

double [,]tpn,double [,]tpo,double [,]tno,double [,]tnn)

        {

               int i,j;

               Pen pn = new Pen(Color.Black);

               Pen p = new Pen(Color.Black);

               Pen p1 = new Pen(Color.Green,ht);

               Pen p2 = new Pen(Color.Red,ht);

               Font fnt = new Font("Courier New",ht);

          SolidBrush sbr = new SolidBrush(Color.Black);

               int dy=17;

               float y0,y1,y2,x0,x1,x2,yn,xn;

               x0=10; y0=10;

               x1=x0; y1=y0;

               double max = GetMax(tno);

               double dx = max/ 10;

               double sx=0;

               xn=x0+(float)max*mx;

               yn=m-1+dy*n_ij;

               pn.EndCap = LineCap.ArrowAnchor;

            

               g.DrawLine(pn,x0,yn,xn,yn);

               g.DrawString("Работы",fnt,sbr,x0,y0-10);

               //g.DrawString(max.ToString(),fnt,sbr,x0+(float)max*mx,yn);

                                       

               for(i=0; i<=10; i++)

               {

                      if(i<10)g.DrawLine(p,x0+(float)sx*mx,yn-2,

x0+(float)sx*mx,yn+2);

                          

g.DrawString(String.Format("{0:F2}",sx),fnt,sbr,

x0+(float)sx*mx,yn);

                      sx+=dx;

               }

            

               g.DrawLine(pn,x0,yn,x0,y0);

               g.DrawString("Время",fnt,sbr,xn+(float)dx*mx,yn);

               for(i=1; i<=n; i++)

                      for(j=1; j<=n; j++)

                             if(C[i,j]>=0)

                             {

                                   x1=x0+(float)tpn[i,j]*mx;

                                   x2=x1+(float)C[i,j]*mx;

                                   y1+=dy; y2=y1;

                                   g.DrawLine(p1,x1,y1,x2,y2);

                                       

                                   if(tpo[i,j]!=tno[i,j])

                                   {

                                          x1=x2;

                                          x2=x1+(float)(tno[i,j]-tpo[i,j])*mx;

                                          g.DrawLine(p2,x1,y1,x2,y2);

                                   }

                                       

                                   g.DrawString(i.ToString()+"-

"+j.ToString(),fnt,sbr ,x2,y2-ht);

                                       

                             }

        }

      

        private void pictureBox1_Paint(object sender,

System.Windows.Forms.PaintEventArgs e)

        {

                   

               Graphics g = e.Graphics;

               DrawGant(g,/*nij,*/C_min,tpn_min,tpo_min,tno_min,tnn_min);

                   

        }

 

        private void pictureBox2_Paint(object sender,

System.Windows.Forms.PaintEventArgs e)

        {

                   

               Graphics g = e.Graphics;

               DrawGant(g,/*nij,*/C_max,tpn_max,tpo_max,tno_max,tnn_max);

              

        }

 

        private void pictureBox3_Paint(object sender,

System.Windows.Forms.PaintEventArgs e)

        {

               Graphics g = e.Graphics;

               DrawGant(g,/*nij,*/C_avg,tpn_avg,tpo_avg,tno_avg,tnn_avg);

        }

 

 

        private void button1_Click(object sender, System.EventArgs e)

        {

               Process.Start("test.xls");

        }

 

                   private void button2_Click(object sender, System.EventArgs e)

        {

               int n = (int)Math.Sqrt(C_avg.Length)-1;

               FileStream f =new FileStream("tavg.xls",FileMode.Create);

               StreamWriter w = new StreamWriter(f);

          w.WriteLine("Код i,j\tt(i,j)\ttpn(i,j)\ttpo(i,j)\ttnn(i,j)\ttno(i,j)\t

Rn(i,j)\tRcb(i,j)");

               for(int i=1; i<=n; i++)

                      for(int j=1; j<=n; j++)

                             if(C_avg[i,j]>=0)

                             {

                                   w.WriteLine(i.ToString()+"-

"+j.ToString()+"\t"+C_avg[i,j]+"\t"+tpn_avg[i,j]+"\t"+

tpo_avg[i,j]+"\t"+tnn_avg[i,j]+"\t"+tno_avg[i,j]+"\t"+

Rn_avg[i,j]+"\t"+Rcb_avg[i,j]);

                             }

               w.Close();

               f.Close();

 

               DialogResult result = MessageBox.Show(

"Просмотреть отчет?","",MessageBoxButtons.YesNo);

               if(result==DialogResult.Yes)

                      Process.Start("tavg.xls");

        }

 

        private void button3_Click(object sender, System.EventArgs e)

        {

               int n = (int)Math.Sqrt(C_min.Length)-1;

               FileStream f =new FileStream("tmin.xls",FileMode.Create);

          StreamWriter w = new StreamWriter(f);

               w.WriteLine("Код i,j\tt(i,j)\ttpn(i,j)\ttpo(i,j)\ttnn(i,j)\ttno(i,j)\t

Rn(i,j)\tRcb(i,j)");

               for(int i=1; i<=n; i++)

                      for(int j=1; j<=n; j++)

                             if(C_min[i,j]>=0)

                             {

                                   w.WriteLine(i.ToString()+"-"+j.ToString()+"\t"+

C_min[i,j]+"\t"+tpn_min[i,j]+"\t"+tpo_min[i,j]+"\t"+

tnn_min[i,j]+"\t"+tno_min[i,j]+"\t"+Rn_min[i,j]+"\t"+Rcb_min[i,j]);

                             }

               w.Close();

               f.Close();

 

               DialogResult result = MessageBox.Show(

"Просмотреть отчет?","",MessageBoxButtons.YesNo);

               if(result==DialogResult.Yes)

                      Process.Start("tmin.xls");

        }

 

        private void button4_Click(object sender, System.EventArgs e)

        {

               int n = (int)Math.Sqrt(C_max.Length)-1;

               FileStream f =new FileStream("tmax.xls",FileMode.Create);

               StreamWriter w = new StreamWriter(f);

               w.WriteLine("Код i,j\tt(i,j)\ttpn(i,j)\ttpo(i,j)\ttnn(i,j)\ttno(i,j)\t

Rn(i,j)\tRcb(i,j)");

               for(int i=1; i<=n; i++)

                      for(int j=1; j<=n; j++)

                             if(C_max[i,j]>=0)

                             {

                                   w.WriteLine(i.ToString()+"-"+j.ToString()+"\t"+

C_max[i,j]+"\t"+tpn_max[i,j]+"\t"+tpo_max[i,j]+"\t"+tnn_max[i,j]+"\t"+tno_max[i,j]+"\t"+Rn_max[i,j]+"\t"+Rcb_max[i,j]);

                             }

               w.Close();

               f.Close();

 

               DialogResult result = MessageBox.Show(

"Просмотреть отчет?","",MessageBoxButtons.YesNo);

               if(result==DialogResult.Yes)

                      Process.Start("tmax.xls");

        }

  }

}

 

Дата: 2019-07-24, просмотров: 177.