:

:

̲Ͳ ²Ƞ

Ͳ Ͳ

5142 蠠 ..

1) : C ࠠ .

2) 1.

3) - :

a) ;

b) ;

c) (, , );

d) ;

e) ;

f) ;

g) ( 1);

1)    ( 2, 3);

i) ;

j)  ;

k) .

4) ___ 2006

5) 蠠 ____ 2006

. .

򠠠


1 -

6
1-2 ϳ 1 1.5
2-5 1 (79-134 .) 13 14
2-3 75-79 . 4 4.3
3-6 , 75-79 . 20 21
3-4 71-75 . 5 5.1
5-8 1 8.7 8,8
6-12 (, ) 75-79 . 16 16.6
6-7 0
4-7 , 71-75 . 15 16
4-10 67-71 . 5 5.8
7-12 71-75 . 13 14
7-11 0
10-11 , 67-71 . 18 19
10-13 63-67 . 7 8
11-12 67-71 . 17 18
11-14 0
12-20 67-79 . 6 7
13-16 59-63 . 9 10
13-14 , 63-67 . 15 16
14-19 63-67 . 15 17
14-17 0
16-17 , 59-63 . 20 25
17-19 59-63 . 20 23
8-22 79 . 30 35
20-22 67-79 . 4 7
19-21 59-67 . 8 12
21-22 59-67 . 2 8

() .

, :

1)      , ;

2)      .

41 , 5 , 3 , 1 .

.

ֲ

() .

:

1)   , , ;

2)   , .

41 , 5 , 3 , 1 .

.

ANOTATION

The shipbuilding net graph modeling was done in the term work. Its introduced with the purpose of reception of the maximal profit from work of some enterprise.

The work is done on 41 pages of the printed text, contains 5 illustrations. The work also has 1 appendices, which contain the text and results of performance of the program. For creation of this work were used three sources of information.

The work is done in the Ukrainian language.


̲

...................................................................................................... 4

............................................................................................................................................. 6

1.    ............................................................... 6

1.1 .7

1.1.1    ᒺ ...7

1.1.2    ....8

1.1.3 ............................8

1.1.4 - ...........................9

1.1.5    .................................................................................9

1.1.6 х..10

1.2 腅..10

1.2.1 󅅅.11

1.2.2 12

1.3 ³ х...13

1.4 .16

2. 17

2.1 볅.....17

3. 19

3.1 ...19

3.2 ..23

3.3 ⅅ...24

..29
...30

- ..31


˲

:

1.   

2.   

3.   

4.    CPM Critical Path Method

5.    PERT Program Evolution and Review Technique

6.   


. . , - (). .

. .

:

              ;

              , ;

             
;

              ,

;

             
;

              .


1 ί Ҳ

1.1

1.1.1

(I) I () , , .

(I) ", (I) ( ):

, Æ ;

n - : n ³ 2; ((I)) i, ;

,

, ; , n, m - i: n, m ³ 2;

ij,, , .

, . .

, (, ) ( -, ) , : , , , , ().

, . . , . .

, . .

() . .

, : , - , .

1.1.2   .

, .

, , , , , , , . .

, , .

.

䳿. , .

.

, . .

1.1.3 .

. ᒺ . :

² .

² .

² .

² (), .

² 106.

² .

² - .


1.1.4 - .

ᒺ, - . . - :

1)   ().

2)   , , .

3)   , .

4)   , . , .

5)   , .

6)   - , .

, , - . .

1.1.5 .

, . , .

:

²  , , . , , , , , .

²  , , . , , , , .

²  , , . , , , , , .

²  , , , , , , .

²  , .

1.1.6   .

³, , . , . , , , , , . , , , , .

, , , . 䳿 . .

, , . , , .

1.2

(), , : .

ij (. 1) , , , . : () ; .

1 - ij

. , .

:

- (Critical Path Method - CPM);

- (Program Evalution and Review Techique-PERT).

1.2.1

CPM - . ѳ - . . , ' , (). - -. : , , . ' , , , , , ; 䳿 , . , 䳿, , 䳿, . , , , , , . - .

- 䳿 . , , , . , , .

ѳ - , ' . , .

: t(L) - ; tp(i) - 䳿 i; tn(i) - 䳿 i; P(i) - 䳿; t..(ij) - (ij); t..(ij) - (ij); t..(ij) - (ij); t..(ij) - (ij); P(i) - (ij); P(i) - (ij).

䳿 - , , 䳿. , 䳿:

,

t(Lmax) - i .

ϳ 䳿 i - 䳿, 䳿. , 䳿 - , 䳺:

tn(i) = t(L) - t(Lmax),

t(Lmax) - , 䳿 i.

䳿 䳿:

P(i) = tn(i) - tp(i).

䳿 , 䳿 .

䳿 . , , .

(ij) 䳿 :

t..(ij) = tp(i)

t(ij), :

t..(ij) = tp.(ij) + t(ij).

ϳ (ij) 䳿 j, 䳿, :

t..(ij) = t.(j).

, :

t..(ij) = t.o.(ij) - t(ij).

- , , . ³ , :

Pn(ij) = tn(j) - tp(i) - t(ij).

³ - , , . ³

P(ij) = t(j) - tp(i) - t(ij).

1.2.2

- , , . PERT (Program Evaluation and Review Technique). 1956 - "". "" ", " "".

CPM , 䳿 , PERT - , : , , . 㳺 CPM, , .

CPM PERT . , : , , .

() , . , .

1.3 ³

, , , / , ('). , 䳿 , .

. ³ ' , , , , , , .., - , , , .

() (ʲ) , . ' . (') ' , , .

() ʲ . , . , , . , , , .

( . . ).

() . ( ) ( ) .

, , . ( - , , , ), , ' .

, - , . , . - , ' - .

, , , (') .

Spider Projects. , .

Microsoft Project, Symantec Time Line, Open Plan, Primavera. Microsoft Project.

, Gather, (. 2).

1 MS Project, Primavera Spider

Microsoft Project 2002 Professional

Primavera P3e

Spider Project

MS Office
1

""
(" 80- ")



( )


" ?"

/
OLAP-
-

(SQL Server)
Web-
Web-
Palm


-


-

/
" "

:
350 . .

1.4

, :

I. , , . :

1. ().

2. .

3. , , , .

4. .

5. .

II. . :

1. .

2. , .

III. .


2 ̲ί ˲ ѲΠ Բ ߠ

2.1

G =(V, E), vàw [v, w]. (v, w) v w, v w.

, (R. W. Floyd). , 1 n. nn, . [i, j]=C[i, j] i≠j. ià j , C[i, j]=-∞. 0.

n . ϳ k- A[i, j] i j, , k. , i j , k.

k- :

Ak[i, j] = min(Ak-1[i, j], Ak-1[i, k] + Ak-1[k, j]).

k k- , , n , .

Ak[i, j] Ak-1[i, j] ( i j k ) Ak-1[i, k] + Ak-1[k, j] ( i k k j). k , Ak-1[i, j], Ak[i, j] .

г Ak[i, k] = Ak-1[i, k] Ak[k, j] = Ak-1[k, j] , k- , k- k- , . ﳺ .

, P, P[i, j] k, A[i, j]. P[i, j] = 0, i j ià j.

, :

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;

}

}

. i- , - ( i- 䒺 ), . , , i- , -¥. 䳿 . : , vàw (v>w) . .

, .

/ , , 䳿/ 䳺.

, , , , , , I .

, .

- . : .

: , / ,

i j C_min C_max.


3 Ѳ Բ

3.1

, .

, -, - , .

. :

1.             򳺿 ;

2.             , , t.. t, t;

3.             :

              tmin, ;

              tmax, , , , , ;

4.             :

              ;

              ;

              .

:

              (L), ;

              , ;

              ' ;

              ;

              , ;

              ;

:

I.          , ;

II.         ( -).

:

              , 䳿 , ;

              , 䳿 , .

, 䳿, . , , .

- . - . , .

(. -) , .

, - ( , 䳿, - ). 40- . XX .

ϳ , , . :

1)             - , ;

2)             - `, ;

3)             - .

.

, . :

a, b, c . a=97, b=1113, c=131072.

, :

C = 2B , B- . 2B;

a - a = 1+4×k, k - ;

b - ( 1).


3 -

(. 3) , f(x) . :

              x ;

              - Y, ;

              , f(x) ( ) , X , - .

, . , ( ). .

L, , .

3.2

X , , :

1)             - ( );

2)             - () ;

3)             - .

, , . ᒺ . , .

, - .

. . g (, g=0,9; 0,95; 0,99; ...) , g , d>0,

(3.1)

(1)

(3.2)

г (2) , b (3.3)

³, , lg , .. ( ), . g lg , , lg .


4 -

lg (. 4) , b - . .

lg, g, .. .

. (3.4) (4): b , mx; .

, . t, .

L, .. ϳ.

, . . .

, ( ): (1,2), (2,3), ..., (m+1,m) n , (,+1). , 고 , , (,+1). ³, . 2, .

2 -

Ii

(1,2)

(2,3)

...

(k,k+1)

ni

n1

n2

...

nk

pi*

p1*

p2*

...

pk*

³ 1, 2, 3, ..., k, k+1, ... , m. [, +1] , *. , 1.


5 - ó

, . (. 5) , . , .

ϳ :

,

- , ; - ;

- .

- .

, , - .

3.2

, 2 . ϳ , , , T, t, t. ϳ . .

3.3

1 tmin

2 tmin

3 tmax

4 tmax

5 tavg

6 tavg

7 L_kp

8 T_kp

.


, , . , . , - , , .

, T . , . t i t , . , , t t, . . , . .


ί ˲

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");

}

}

}





2010