o o o i i cc coio ooi (49349)

IICCO OCI I

io ic

o coio io









CO OO

:

o o o i i

c c coio ooi



o:

c c-07-1

oo O..

i:

o

o coio io o ..






2008


IC


IC

C

OI 1. I I I O

1.1 oco i

1.2 i

1.3 i c c

OI 2. OC

OI 3. OO O

3.1 i ooo co

3.2 oo ic

3.3 oo ooo o

CO

CCO OC

O



C


i i ooo cc i o (), o oio i i , o, o, ooi i cci (o, i, c) ci o (i, , co). i oi io oc cii, o ooi o oco o oo i. i ioii i i c ioci i, , i -oo .

i o ii oi cc o ooo ic oi oi oco oi i.

i o, o cic i, i coc oi i, o ioii. iic i oo ooo o io ii o ci, i io cococ o oo o cio icoci o ioioci oo . [1]

Ic ii o cii i. o c o o, c i, oi ci .

1. i o oo oci, o o oo o ii i oci ci.

2. i o oci, o ioi oi c ii i ci, iooci o oiic ci ici. o i ci o oc ( oo) o oi oi .

3. i o coo oci o , o io oiic o ci ii ii.

4. i o oci, o c oi ioi oo io.

iic i ic o o io i ic. o i c, o i ioo oc o, i - . o, oi i oi oi c ic oo oooioo io o i . o, o oco co oi oii oco i i oc. oci oi ci i, o ci o oc oi , i i ocooo i c o ().

i , o ooi io, i ocii oci cc. C o ci oic oi ococ i. o oi i c oi ci i, ocoi c i. i , Ci, i i c o i io i o oi i.

i c c o o o cii ci ii i.

i c c ' o ci, i c i, ci o:

  • oiic o c Vj io i i c;

  • i oo oc cio

  • iic ii;

  • occ c ii. [2]

ooc i i i coi ooi.


OI 1

I I I O


1.1 oco i


oo o o o o o i i c c. i co oo ooi. oci oci c, o oc o o i.


1.2 i i


i i - i, o oco, o i (), i, o o, o o c o o i i.

c i o oo ioi c iic c ci, i c i. ci c ci i Ci, i i, i o-io, i , ioioci i: iic i, i c c, i o- oio ioi, i o o icc i oi (o), co i c c iic.

i i o oco o i, o ic oc c io ii ooc oi o i oco i. o oo, o-, o ci ii ' o i i, o-, oc c'oo . [2]

ci i i.

1) iic i

2) i Ci

3) i c c

4) o iic i

5) i oi

6) i

7) i i

8) Co i c c iic


1.3 i c-c


O i io c i i c i c c. i c c o o o cii ci ii i:



ioi o o o i o: i [Wij] ooc o co, o ic oi ooo i. c o i, oo o i Wij oo co.

i c c ' o ci, i c i, ci o:

  • oiic o c Vj io i i c;

  • i oo oc cio

  • iic ii;

  • occ c ii.

i c c o cococ i o , o ioi oioci ii o. [3]

o ci o coi o ooi, oo i io .

o ococ oc io cc, iic oi ic ioco oo oio c, oi oi co ii o o o co iii, c oco ii , o ooii ci, i oci o co oo co i.

o oiic o oi o ii c i i o i oi, o i c i ocio oi ooic coi oo.

coi ooi:





co 1 i coioo o ooi



o o ooi i o , ic o oo, co c o , c i oo i. [4]


OI 2

OC


1:

oo i 6 i 8 o c.

o i U(x,s) ci i p(x,s) oioc, oi i 1 i i 2 ioio:


1 i U(x,s)


s1

s2

s3

s4

s5

s6

s7

s8

x1

1

2

-2

0

4

6

7

-4

x2

0

0

-1

0

5

6

1

2

x3

4

1

1

2

1

0

2

3

x4

-6

7

5

5

2

2

0

3

X5

-1

-1

0

4

2

3

4

5

x6

-2

-1

-2

2

1

0

3

4


2 i (x,s)


s1

s2

s3

s4

s5

s6

s7

s8

x1

0

0

0

0.5

0

0.5

0

0

x2

0

0

0

0

0.2

0

0

0.8

x3

0.1

0.2

0

0

0

0

0

0.7

x4

0

0

0

1

0

0

0

0

X5

1

0

0

0

0

0

0

0

x6

0

0.4

0

0

0.6

0

0

0


oi oo c c o o o o i:


O, o {x4}.


2:

oo i c oc, , - ic i, c .

oc:


3 ooi i i


, o oioci ci ioi, coc o o c c:



Oc coc o c c:

1) oiic ci ioi i o oci io ii o;

2) i o o oi cc c i ic co;

3) i o oo i o o co cii.

, i. 1 oo co oiic ci

O, oi



o c c ococ oi i o. [5]


OI 3

OO O


3.1 i ooo co


o ic o co o oic co o, oo oo ooo o i oc co ioo o Visual Studio 2008.

Visual Studio 2008 co ioo o, co ci o i o o, ocoo C#. Visual Studio 2008 o i i i co. Visual Studio 2008 oci, o , co co o oi. ooi oo coi Visual Studio 2008 c i oᒺo-oioo ioo o. I oᒺo-oiooo o o ici (oᒺ) i coi o (oi) , oᒺ. Co ioo o Visual Studio 2008 i oo ooo, co o o i oᒺ, c ooo. oi o occ ooci oc oo o i ooi i i oo coci, oc i o ooo o.

co o oic oco ii oo. oc i ooi oic oco c o oᒺi i coci i i i io. i coc oᒺ ococ . iii coci, i oo oc oᒺ i ococ i i oᒺ.

i i o o , o oci oo co o c ci o o ooo ioio cc:

  • oco ic oci ooo ioio cco;

  • ic ocoi;

  • cc co oo o oi;

  • oic co ooo o oi;

  • c i oi, i o o;

  • i o cooo i;

  • i ioi o o;

  • co oo ci oo oo i ico o.

i ci c o o o C#, oc c o.

C# o'o-oio o o o cco ii o .NET. oo co co, Coo io io o i io Microsoft Research ( ii Microsoft).

cooi C# o co oo ooi Microsoft, o o oi oco oi ooci .NET. o o, o i ic, i , o coi o oo oc .NET.

C# ooc o o oo i CLR i, , , c, i ooc co CLR. cocc, c, cc i C#. cic o icic o i ocooc o c , o o o ocoic co ioii oci CLR. , oo CLR i ci 1.1 o 2.0 o c i c C#; oio oi ci i i. (o ooiic o oo C# 3.0, o o o, o cc o o .NET.) CLR C#, i ci i .NET-oio o, o ooc, oi ci o o. , i ci io co C#, ooc CLR o, c C# oo , i oc o VB.NET, J# oo.

oo C# c oic o oi, oio o-o, oo o, c i o, o coi oi. o o i o oc oi .NET, .NET c oi o cicoci o (oo i , i o). [6]


3.2 oo ic


oi oico i i (DataGrid1 i DataGrid2). i i o oc i io .

co 2 o


i oi oico i (tChart1), i io o i oioc.


co 3 o io


oi oico co o (textBox1), o i o:


co 4 o co o


i o co i, oo i o (button), o oi:


co 5 o oo


oi oco o o :


co 6 o


3.3 oo ooo o


io oco i o o o c:

1) Co o ooi i oco i:

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

{

bl.lambda = Convert.ToDouble(numericUpDown1.Value);

}


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

{

bl.delta = Convert.ToDouble(numericUpDown2.Value);

}


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

{

bl.I = Convert.ToInt32(numericUpDown3.Value);

}


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

{

bl.J = Convert.ToInt32(numericUpDown4.Value);

}

2) i o o o o i (DataGrid1) o coi oo ooi ( ci). oo ococ i:

public CL_Simple_BL()

{

c = 0;

I = J = 10;

lambda = 1.0;

delta = 0.001;

r = new Random(DateTime.Now.Millisecond);

format = "{0:F2}";

}


public double Find_d()

{

d = 1 - S + delta;

return d;

}

// o oo

public double Find_X()

{

//X = Math.Sqrt(Math.Log(d)/a);

X = (Math.Log(delta))/(-lambda);

return X;

}

//

public double Find_P(double dx)

{

//P = 1 - Math.Exp(-0.5*Math.Pow(dx/lambda, 2));

P = 1 - Math.Pow(Math.E, (-lambda*dx));

return P;

}


public double Find_F(double dx)

{

//F = (dx*Math.Exp((-2*Math.Pow(dx,2))/(2*Math.Pow(lambda, 2))))/Math.Pow(lambda, 2);

F = lambda*(Math.Pow(Math.E,(-lambda*dx)));

return F;

}

3) i o o o o i (DataGrid2) o coi oo ooi ( oioc). o, o c oioc 1. oo ocoo i:

public void Find_v()

{

calc = "";

for (int i = 0; i < I; i++)

{

v[i] = 0;

calc += "v(x"+(i+1).ToString()+") = ";

for (int j = 0; j < J; j++)

{

v[i] += (x[i, j]*y[i, j]);

calc += String.Format(format,x[i, j]) + " * " + String.Format(format,y[i, j]);

if (j < J-1)

{

calc += " + ";

}

}

calc += " = " + String.Format(format,v[i]) + ";\r\n";

}

}


public void Find_max_v()

{

c = 0;

string s = "";

double max = 0;

for (int i = 0; i < I; i++)

{

if (v[i]>=max)

{

max = v[i];

}

}

calc += "\r\nXopt {";

s += "Xopt {";

for (int i = 0; i < I; i++)

{

if(v[i] == max)

{

if (c > 0)

{

calc += ", ";

}

max_v[c] = i;

calc += "x" + (i + 1).ToString();

s += "x" + (i + 1).ToString();

c++;


}

}

calc += "};";

s += "};";

MessageBox.Show(s, "");

}


public void Init()

{

S = 1.0;

//Find_a();

Find_d();

Find_X();

}


public void Fill()

{

double t = 0, q = 0;

for (int i = 0; i < I; i++)

{

Init();

int j = 0;

while (j < J-1)

{

Find_d();

Find_X();

if (j == J-1)

{

t = 1;

}

else

{

t = r.NextDouble();

}

t = X*t;

q = Find_P(t);

if (S - q >= 0)

{

S = S - q;

x[i, j] = t;

y[i, j] = q;

j++;

}

}

}

}

4) oi oo i i i o coi oo ooi. o o :

DataTable dt = new DataTable("X_S");

DataSet ds = new DataSet("X");

DataTable dt1 = new DataTable("S");

for (int i = 1; i <= bl.J; i++)

{

dt.Columns.Add(i.ToString());

dt1.Columns.Add(i.ToString());

}

string[] s = new string[bl.J];

string[] s1 = new string[bl.J];

for (int i = 0; i < bl.I; i++)

{

for (int j = 0; j < bl.J; j++)

{

s[j] = String.Format(bl.format,bl.x[i,j]);

s1[j] = String.Format(bl.format,bl.y[i,j]);

}

dt.Rows.Add(s);

dt1.Rows.Add(s1);

}

ds.Tables.Add(dt);

dataGrid1.DataSource = ds.Tables[0];

dataGrid1.Expand(-1);

dataGrid1.SelectionBackColor = Color.SeaShell;

dataGrid1.SelectionBackColor = Color.Green;

dataGrid1.Select(bl.max_v[0]);


ds.Tables.Add(dt1);

dataGrid2.DataSource = ds.Tables[1];

dataGrid2.Expand(-1);

dataGrid2.SelectionBackColor = Color.SeaShell;

dataGrid2.SelectionBackColor = Color.Green;

dataGrid2.Select(bl.max_v[0]);

5) i o o o co i i. o :

tChart1.Series[0].Clear();

tChart1.Series[1].Clear();

for (int i = 0; i < bl.I; i++)

{

for (int j = 0; j < bl.J; j++)

{

tChart1.Series[0].Add(bl.x[i,j], bl.y[i,j]);

tChart1.Series[1].Add(bl.x[i,j], bl.Find_F(bl.x[i,j]));

}

textBox1.Text += "\r\n";

}

o i o. ci i oo o, oo, i o ooc ci i.

oo ooo o:


co 7 oo o


CO


i c o o coo oo oo o o o o o i i c c o i oioc ii o coi oo ooi.


CCO OC


1. .., .. oc : . .: , 1982. 143 c.

2. .., .C., o .., Oo .. o . o oco . 1. o: -o . oc. . -, 2003. 80 c.

3. ., . o c . .: , 1990. 208 c.

4. http://en.wikipedia.org/

5. http://window.edu.ru/

6. http://works.tarefer.ru/



O


c Form1.cs:

using System;

using System.Drawing;

using System.Collections;

using System.ComponentModel;

using System.Windows.Forms;

using System.Data;


namespace BL

{

///

/// Summary description for Form1.

///

public class Form1 : System.Windows.Forms.Form

{

private System.Windows.Forms.Button button1;

private System.Windows.Forms.TextBox textBox1;

private System.Windows.Forms.NumericUpDown numericUpDown1;

private System.Windows.Forms.Label label1;

private System.Windows.Forms.Label label2;

private System.Windows.Forms.NumericUpDown numericUpDown2;

private System.Windows.Forms.Panel panel1;

private System.Windows.Forms.NumericUpDown numericUpDown3;

private System.Windows.Forms.NumericUpDown numericUpDown4;

private System.Windows.Forms.Label label3;

private System.Windows.Forms.Label label4;

///

/// Required designer variable.

///

private System.ComponentModel.Container components = null;

private DataGrid dataGrid1;

private DataGrid dataGrid2;

private Steema.TeeChart.Styles.FastLine fastLine2;

private Steema.TeeChart.Styles.Points points1;

private Steema.TeeChart.TChart tChart1;

private Label label5;

private Label label6;

private PictureBox pictureBox1;


CL_Simple_BL bl;


public Form1()

{

//

// Required for Windows Form Designer support

//

InitializeComponent();

bl = new CL_Simple_BL();


//

// TODO: Add any constructor code after InitializeComponent call

//

}


///

/// Clean up any resources being used.

///

protected override void Dispose( bool disposing )

{

if( disposing )

{

if (components != null)

{

components.Dispose();

}

}

base.Dispose( disposing );

}


#region Windows Form Designer generated code

///

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

///

private void InitializeComponent()

{

System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));

this.button1 = new System.Windows.Forms.Button();

this.textBox1 = new System.Windows.Forms.TextBox();

this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();

this.label1 = new System.Windows.Forms.Label();

this.label2 = new System.Windows.Forms.Label();

this.numericUpDown2 = new System.Windows.Forms.NumericUpDown();

this.panel1 = new System.Windows.Forms.Panel();

this.label4 = new System.Windows.Forms.Label();

this.label3 = new System.Windows.Forms.Label();

this.numericUpDown4 = new System.Windows.Forms.NumericUpDown();

this.numericUpDown3 = new System.Windows.Forms.NumericUpDown();

this.dataGrid1 = new System.Windows.Forms.DataGrid();

this.dataGrid2 = new System.Windows.Forms.DataGrid();

this.fastLine2 = new Steema.TeeChart.Styles.FastLine();

this.points1 = new Steema.TeeChart.Styles.Points();

this.tChart1 = new Steema.TeeChart.TChart();

this.label5 = new System.Windows.Forms.Label();

this.label6 = new System.Windows.Forms.Label();

this.pictureBox1 = new System.Windows.Forms.PictureBox();

((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();

((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();

this.panel1.SuspendLayout();

((System.ComponentModel.ISupportInitialize)(this.numericUpDown4)).BeginInit();

((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).BeginInit();

((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();

((System.ComponentModel.ISupportInitialize)(this.dataGrid2)).BeginInit();

((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();

this.SuspendLayout();

//

// button1

//

this.button1.Location = new System.Drawing.Point(414, 6);

this.button1.Name = "button1";

this.button1.Size = new System.Drawing.Size(400, 49);

this.button1.TabIndex = 1;

this.button1.Text = "OC";

this.button1.Click += new System.EventHandler(this.button1_Click);

//

// textBox1

//

this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));

this.textBox1.Location = new System.Drawing.Point(567, 266);

this.textBox1.Multiline = true;

this.textBox1.Name = "textBox1";

this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Both;

this.textBox1.Size = new System.Drawing.Size(483, 231);

this.textBox1.TabIndex = 2;

//

// numericUpDown1

//

this.numericUpDown1.DecimalPlaces = 2;

this.numericUpDown1.Increment = new decimal(new int[] {

1,

0,

0,

131072});

this.numericUpDown1.Location = new System.Drawing.Point(36, 24);

this.numericUpDown1.Minimum = new decimal(new int[] {

1,

0,

0,

131072});

this.numericUpDown1.Name = "numericUpDown1";

this.numericUpDown1.Size = new System.Drawing.Size(72, 20);

this.numericUpDown1.TabIndex = 2;

this.numericUpDown1.Value = new decimal(new int[] {

1,

0,

0,

65536});

this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);

this.numericUpDown1.Enter += new System.EventHandler(this.numericUpDown1_ValueChanged);

//

// label1

//

this.label1.Font = new System.Drawing.Font("Symbol", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));

this.label1.Location = new System.Drawing.Point(36, 8);

this.label1.Name = "label1";

this.label1.Size = new System.Drawing.Size(24, 16);

this.label1.TabIndex = 3;

this.label1.Text = "l";

//

// label2

//

this.label2.Font = new System.Drawing.Font("Symbol", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));

this.label2.Location = new System.Drawing.Point(959, 24);

this.label2.Name = "label2";

this.label2.Size = new System.Drawing.Size(24, 16);

this.label2.TabIndex = 4;

this.label2.Text = "D";

this.label2.Visible = false;

//

// numericUpDown2

//

this.numericUpDown2.DecimalPlaces = 3;

this.numericUpDown2.Increment = new decimal(new int[] {

1,

0,

0,

196608});

this.numericUpDown2.Location = new System.Drawing.Point(978, 24);

this.numericUpDown2.Maximum = new decimal(new int[] {

1,

0,

0,

65536});

this.numericUpDown2.Minimum = new decimal(new int[] {

1,

0,

0,

196608});

this.numericUpDown2.Name = "numericUpDown2";

this.numericUpDown2.Size = new System.Drawing.Size(72, 20);

this.numericUpDown2.TabIndex = 5;

this.numericUpDown2.Value = new decimal(new int[] {

1,

0,

0,

196608});

this.numericUpDown2.Visible = false;

this.numericUpDown2.ValueChanged += new System.EventHandler(this.numericUpDown2_ValueChanged);

this.numericUpDown2.Enter += new System.EventHandler(this.numericUpDown2_ValueChanged);

//

// panel1

//

this.panel1.Controls.Add(this.label4);

this.panel1.Controls.Add(this.label3);

this.panel1.Controls.Add(this.numericUpDown4);

this.panel1.Controls.Add(this.numericUpDown3);

this.panel1.Controls.Add(this.label1);

this.panel1.Controls.Add(this.numericUpDown1);

this.panel1.Controls.Add(this.numericUpDown2);

this.panel1.Controls.Add(this.label2);

this.panel1.Controls.Add(this.button1);

this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom;

this.panel1.Location = new System.Drawing.Point(0, 502);

this.panel1.Name = "panel1";

this.panel1.Size = new System.Drawing.Size(1062, 64);

this.panel1.TabIndex = 4;

//

// label4

//

this.label4.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));

this.label4.Location = new System.Drawing.Point(269, 8);

this.label4.Name = "label4";

this.label4.Size = new System.Drawing.Size(24, 16);

this.label4.TabIndex = 9;

this.label4.Text = "S";

//

// label3

//

this.label3.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));

this.label3.Location = new System.Drawing.Point(151, 8);

this.label3.Name = "label3";

this.label3.Size = new System.Drawing.Size(24, 16);

this.label3.TabIndex = 8;

this.label3.Text = "X";

//

// numericUpDown4

//

this.numericUpDown4.Location = new System.Drawing.Point(269, 24);

this.numericUpDown4.Minimum = new decimal(new int[] {

1,

0,

0,

0});

this.numericUpDown4.Name = "numericUpDown4";

this.numericUpDown4.Size = new System.Drawing.Size(72, 20);

this.numericUpDown4.TabIndex = 7;

this.numericUpDown4.Value = new decimal(new int[] {

5,

0,

0,

0});

this.numericUpDown4.ValueChanged += new System.EventHandler(this.numericUpDown4_ValueChanged);

this.numericUpDown4.Enter += new System.EventHandler(this.numericUpDown4_ValueChanged);

//

// numericUpDown3

//

this.numericUpDown3.Location = new System.Drawing.Point(151, 24);

this.numericUpDown3.Minimum = new decimal(new int[] {

1,

0,

0,

0});

this.numericUpDown3.Name = "numericUpDown3";

this.numericUpDown3.Size = new System.Drawing.Size(72, 20);

this.numericUpDown3.TabIndex = 6;

this.numericUpDown3.Value = new decimal(new int[] {

10,

0,

0,

0});

this.numericUpDown3.ValueChanged += new System.EventHandler(this.numericUpDown3_ValueChanged);

this.numericUpDown3.Enter += new System.EventHandler(this.numericUpDown3_ValueChanged);

//

// dataGrid1

//

this.dataGrid1.AllowNavigation = false;

this.dataGrid1.AllowSorting = false;

this.dataGrid1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)

| System.Windows.Forms.AnchorStyles.Right)));

this.dataGrid1.CaptionVisible = false;

this.dataGrid1.ColumnHeadersVisible = false;

this.dataGrid1.DataMember = "";

this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;

this.dataGrid1.Location = new System.Drawing.Point(0, 19);

this.dataGrid1.Name = "dataGrid1";

this.dataGrid1.ParentRowsVisible = false;

this.dataGrid1.ReadOnly = true;

this.dataGrid1.RowHeadersVisible = false;

this.dataGrid1.Size = new System.Drawing.Size(561, 230);

this.dataGrid1.TabIndex = 6;

//

// dataGrid2

//

this.dataGrid2.AllowNavigation = false;

this.dataGrid2.AllowSorting = false;

this.dataGrid2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)

| System.Windows.Forms.AnchorStyles.Right)));

this.dataGrid2.CaptionVisible = false;

this.dataGrid2.ColumnHeadersVisible = false;

this.dataGrid2.DataMember = "";

this.dataGrid2.HeaderForeColor = System.Drawing.SystemColors.ControlText;

this.dataGrid2.Location = new System.Drawing.Point(0, 266);

this.dataGrid2.Name = "dataGrid2";

this.dataGrid2.ParentRowsVisible = false;

this.dataGrid2.ReadOnly = true;

this.dataGrid2.RowHeadersVisible = false;

this.dataGrid2.Size = new System.Drawing.Size(561, 231);

this.dataGrid2.TabIndex = 7;

//

// fastLine2

//

//

//

//

this.fastLine2.LinePen.Color = System.Drawing.Color.Green;

this.fastLine2.Marks.Callout.ArrowHead = Steema.TeeChart.Styles.ArrowHeadStyles.None;

this.fastLine2.Marks.Callout.ArrowHeadSize = 8;

//

//

//

this.fastLine2.Marks.Callout.Brush.Color = System.Drawing.Color.Black;

this.fastLine2.Marks.Callout.Distance = 0;

this.fastLine2.Marks.Callout.Draw3D = false;

this.fastLine2.Marks.Callout.Length = 10;

this.fastLine2.Marks.Callout.Style = Steema.TeeChart.Styles.PointerStyles.Rectangle;

this.fastLine2.Marks.Font.Shadow.Visible = false;

this.fastLine2.Title = "iic ooi oioc";

//

//

//

this.fastLine2.XValues.DataMember = "X";

this.fastLine2.XValues.Order = Steema.TeeChart.Styles.ValueListOrder.Ascending;

//

//

//

this.fastLine2.YValues.DataMember = "Y";

//

// points1

this.points1.LinePen.Color = System.Drawing.Color.FromArgb(((int)(((byte)(153)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));

this.points1.Marks.Callout.ArrowHead = Steema.TeeChart.Styles.ArrowHeadStyles.None;

this.points1.Marks.Callout.ArrowHeadSize = 8;

//

//

//

this.points1.Marks.Callout.Brush.Color = System.Drawing.Color.Black;

this.points1.Marks.Callout.Distance = 0;

this.points1.Marks.Callout.Draw3D = false;

this.points1.Marks.Callout.Length = 0;

this.points1.Marks.Callout.Style = Steema.TeeChart.Styles.PointerStyles.Rectangle;

this.points1.Marks.Font.Shadow.Visible = false;

this.points1.Pointer.Brush.Color = System.Drawing.Color.Red;

this.points1.Pointer.HorizSize = 2;

this.points1.Pointer.Pen.Color = System.Drawing.Color.FromArgb(((int)(((byte)(153)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));

this.points1.Pointer.Style = Steema.TeeChart.Styles.PointerStyles.Circle;

this.points1.Pointer.VertSize = 2;

this.points1.Pointer.Visible = true;

this.points1.Title = " oioc";

this.points1.XValues.DataMember = "X";

this.points1.XValues.Order = Steema.TeeChart.Styles.ValueListOrder.Ascending;

//

//

//

this.points1.YValues.DataMember = "Y";

//

// tChart1

//

this.tChart1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));

this.tChart1.Aspect.ElevationFloat = 345;

this.tChart1.Aspect.RotationFloat = 345;

this.tChart1.Aspect.View3D = false;

this.tChart1.Axes.Bottom.Automatic = true;

this.tChart1.Axes.Bottom.Grid.ZPosition = 0;

this.tChart1.Axes.Bottom.Labels.Font.Shadow.Visible = false;

this.tChart1.Axes.Bottom.Labels.Shadow.Visible = false;

this.tChart1.Axes.Bottom.Title.Font.Shadow.Visible = false;

this.tChart1.Axes.Bottom.Title.Shadow.Visible = false;

//

//

//

this.tChart1.Axes.Depth.Automatic = true;

this.tChart1.Axes.Depth.Grid.ZPosition = 0;

this.tChart1.Axes.Depth.Labels.Font.Shadow.Visible = false;

//

//

//

this.tChart1.Axes.Depth.Labels.Shadow.Visible = false;

this.tChart1.Axes.Depth.Title.Font.Shadow.Visible = false;

this.tChart1.Axes.Depth.Title.Shadow.Visible = false;

this.tChart1.Axes.DepthTop.Automatic = true;

this.tChart1.Axes.DepthTop.Grid.ZPosition = 0;

this.tChart1.Axes.DepthTop.Labels.Font.Shadow.Visible = false;

this.tChart1.Axes.DepthTop.Labels.Shadow.Visible = false;

this.tChart1.Axes.DepthTop.Title.Font.Shadow.Visible = false;

this.tChart1.Axes.DepthTop.Title.Shadow.Visible = false;

this.tChart1.Axes.Left.Automatic = true;

this.tChart1.Axes.Left.Grid.ZPosition = 0;

this.tChart1.Axes.Left.Labels.Font.Shadow.Visible = false;

this.tChart1.Axes.Left.Labels.Shadow.Visible = false;

this.tChart1.Axes.Left.Title.Font.Shadow.Visible = false;

this.tChart1.Axes.Left.Title.Shadow.Visible = false;

this.tChart1.Axes.Right.Automatic = true;

this.tChart1.Axes.Right.Grid.ZPosition = 0;

this.tChart1.Axes.Right.Labels.Font.Shadow.Visible = false;

this.tChart1.Axes.Right.Labels.Shadow.Visible = false;

this.tChart1.Axes.Right.Title.Font.Shadow.Visible = false;

this.tChart1.Axes.Right.Title.Shadow.Visible = false;

this.tChart1.Axes.Top.Automatic = true;

this.tChart1.Axes.Top.Grid.ZPosition = 0;

this.tChart1.Axes.Top.Labels.Font.Shadow.Visible = false;

this.tChart1.Axes.Top.Labels.Shadow.Visible = false;

this.tChart1.Axes.Top.Title.Font.Shadow.Visible = false;

this.tChart1.Axes.Top.Title.Shadow.Visible = false;

this.tChart1.Cursor = System.Windows.Forms.Cursors.Default;

this.tChart1.Footer.Font.Shadow.Visible = false;

this.tChart1.Footer.Shadow.Visible = false;

//

this.tChart1.Header.Font.Shadow.Visible = false;

this.tChart1.Header.Lines = new string[] {

""};

this.tChart1.Header.Shadow.Visible = false;

this.tChart1.Legend.Font.Shadow.Visible = false;

this.tChart1.Legend.Title.Font.Bold = true;

this.tChart1.Legend.Title.Font.Shadow.Visible = false;

this.tChart1.Legend.Title.Pen.Visible = false;

this.tChart1.Legend.Title.Shadow.Visible = false;

this.tChart1.Location = new System.Drawing.Point(567, 15);

this.tChart1.Name = "tChart1";

this.tChart1.Panel.Bevel.Outer = Steema.TeeChart.Drawing.BevelStyles.None;

this.tChart1.Panel.ImageBevel.Width = 1;

this.tChart1.Panel.Shadow.Visible = false;

this.tChart1.Series.Add(this.points1);

this.tChart1.Series.Add(this.fastLine2);

this.tChart1.Size = new System.Drawing.Size(483, 230);

this.tChart1.SubFooter.Font.Shadow.Visible = false;

this.tChart1.SubFooter.Shadow.Visible = false;

this.tChart1.SubHeader.Font.Shadow.Visible = false;

this.tChart1.SubHeader.Shadow.Visible = false;

this.tChart1.TabIndex = 0;

this.tChart1.Walls.Back.AutoHide = false;

this.tChart1.Walls.Back.Shadow.Visible = false;

this.tChart1.Walls.Bottom.AutoHide = false;

this.tChart1.Walls.Bottom.Shadow.Visible = false;

this.tChart1.Walls.Left.AutoHide = false;

this.tChart1.Walls.Left.Shadow.Visible = false;

this.tChart1.Walls.Right.AutoHide = false;

this.tChart1.Walls.Right.Shadow.Visible = false;

//

// label5

//

this.label5.AutoSize = true;

this.label5.Location = new System.Drawing.Point(-1, 2);

this.label5.Name = "label5";

this.label5.Size = new System.Drawing.Size(61, 13);

this.label5.TabIndex = 8;

this.label5.Text = " ";

//

// label6

//

this.label6.AutoSize = true;

this.label6.Location = new System.Drawing.Point(-1, 249);

this.label6.Name = "label6";

this.label6.Size = new System.Drawing.Size(61, 13);

this.label6.TabIndex = 9;

this.label6.Text = " S";

//

// pictureBox1

//

this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));

this.pictureBox1.Location = new System.Drawing.Point(817, 116);

this.pictureBox1.Name = "pictureBox1";

this.pictureBox1.Size = new System.Drawing.Size(196, 56);

this.pictureBox1.TabIndex = 10;

this.pictureBox1.TabStop = false;

//

// Form1

//

this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);

this.ClientSize = new System.Drawing.Size(1062, 566);

this.Controls.Add(this.pictureBox1);

this.Controls.Add(this.label6);

this.Controls.Add(this.label5);

this.Controls.Add(this.textBox1);

this.Controls.Add(this.tChart1);

this.Controls.Add(this.dataGrid2);

this.Controls.Add(this.dataGrid1);

this.Controls.Add(this.panel1);

this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;

this.MaximizeBox = false;

this.Name = "Form1";

this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;

this.Text = "i c c ( oc coi oo). co" +

" oo c c-07-1 oo O..";

((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();

((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit();

this.panel1.ResumeLayout(false);

((System.ComponentModel.ISupportInitialize)(this.numericUpDown4)).EndInit();

((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).EndInit();

((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();

((System.ComponentModel.ISupportInitialize)(this.dataGrid2)).EndInit();

((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();

this.ResumeLayout(false);

this.PerformLayout();


}

#endregion


///

/// The main entry point for the application.

///

[STAThread]

static void Main()

{

Application.Run(new Form1());

}


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

{

bl.lambda = Convert.ToDouble(numericUpDown1.Value);

//bl.delta = Convert.ToDouble(numericUpDown2.Value);

bl.I = Convert.ToInt32(numericUpDown3.Value);

bl.J = Convert.ToInt32(numericUpDown4.Value);


bl.Fill();

//MessageBox.Show("swsds");

bl.Find_v();

bl.Find_max_v();

textBox1.Text = bl.calc;

tChart1.Series[0].Clear();

tChart1.Series[1].Clear();

for (int i = 0; i < bl.I; i++)

{

for (int j = 0; j < bl.J; j++)

{

tChart1.Series[0].Add(bl.x[i,j], bl.y[i,j]);

tChart1.Series[1].Add(bl.x[i,j], bl.Find_F(bl.x[i,j]));

}

textBox1.Text += "\r\n";

}



DataTable dt = new DataTable("X_S");

DataSet ds = new DataSet("X");

DataTable dt1 = new DataTable("S");

for (int i = 1; i <= bl.J; i++)

{

dt.Columns.Add(i.ToString());

dt1.Columns.Add(i.ToString());

}

string[] s = new string[bl.J];

string[] s1 = new string[bl.J];

for (int i = 0; i < bl.I; i++)

{

for (int j = 0; j < bl.J; j++)

{

s[j] = String.Format(bl.format,bl.x[i,j]);

s1[j] = String.Format(bl.format,bl.y[i,j]);

}

dt.Rows.Add(s);

dt1.Rows.Add(s1);

}

ds.Tables.Add(dt);

dataGrid1.DataSource = ds.Tables[0];

dataGrid1.Expand(-1);

dataGrid1.SelectionBackColor = Color.SeaShell;

dataGrid1.SelectionBackColor = Color.Green;

dataGrid1.Select(bl.max_v[0]);


ds.Tables.Add(dt1);

dataGrid2.DataSource = ds.Tables[1];

dataGrid2.Expand(-1);

dataGrid2.SelectionBackColor = Color.SeaShell;

dataGrid2.SelectionBackColor = Color.Green;

dataGrid2.Select(bl.max_v[0]);



}


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

{

bl.lambda = Convert.ToDouble(numericUpDown1.Value);

}


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

{

bl.delta = Convert.ToDouble(numericUpDown2.Value);

}


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

{

bl.I = Convert.ToInt32(numericUpDown3.Value);

}


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

{

bl.J = Convert.ToInt32(numericUpDown4.Value);

}

}

}



c CL_Simple_BL.cs:

using System;

using System.Windows.Forms;


namespace BL

{

///

/// Summary description for CL_Simple_BL.

///

public class CL_Simple_BL

{

public const int N = 100;

public int I;

public int J;

public double[,] x = new double[N,N];

public double[,] y = new double[N,N];

public double[] v = new double[N];

public int[] max_v = new int[N];

public string calc;

public string format;

public int c;

public double lambda;

public double delta;

double d;

//double a;

double S;

double X;

double P;

double F;

Random r;


public CL_Simple_BL()

{

c = 0;

I = J = 10;

lambda = 1.0;

delta = 0.001;

r = new Random(DateTime.Now.Millisecond);

format = "{0:F2}";

}


/*public double Find_a()

{

a = - (1/(2*Math.Pow(lambda,2)));

return a;

}*/


public double Find_d()

{

d = 1 - S + delta;

return d;

}

// o oo

public double Find_X()

{

//X = Math.Sqrt(Math.Log(d)/a);

X = (Math.Log(delta))/(-lambda);

return X;

}

//

public double Find_P(double dx)

{

//P = 1 - Math.Exp(-0.5*Math.Pow(dx/lambda, 2));

P = 1 - Math.Pow(Math.E, (-lambda*dx));

return P;

}


public double Find_F(double dx)

{

//F = (dx*Math.Exp((-2*Math.Pow(dx,2))/(2*Math.Pow(lambda, 2))))/Math.Pow(lambda, 2);

F = lambda*(Math.Pow(Math.E,(-lambda*dx)));

return F;

}


public void Find_v()

{

calc = "";

for (int i = 0; i < I; i++)

{

v[i] = 0;

calc += "v(x"+(i+1).ToString()+") = ";

for (int j = 0; j < J; j++)

{

v[i] += (x[i, j]*y[i, j]);

calc += String.Format(format,x[i, j]) + " * " + String.Format(format,y[i, j]);

if (j < J-1)

{

calc += " + ";

}

}

calc += " = " + String.Format(format,v[i]) + ";\r\n";

}

}


public void Find_max_v()

{

c = 0;

string s = "";

double max = 0;

for (int i = 0; i < I; i++)

{

if (v[i]>=max)

{

max = v[i];

}

}

calc += "\r\nXopt {";

s += "Xopt {";

for (int i = 0; i < I; i++)

{

if(v[i] == max)

{

if (c > 0)

{

calc += ", ";

}

max_v[c] = i;

calc += "x" + (i + 1).ToString();

s += "x" + (i + 1).ToString();

c++;


}

}

calc += "};";

s += "};";

MessageBox.Show(s, "");

}


public void Init()

{

S = 1.0;

//Find_a();

Find_d();

Find_X();

}


public void Fill()

{

double t = 0, q = 0;

for (int i = 0; i < I; i++)

{

Init();

int j = 0;

while (j < J-1)

{

Find_d();

Find_X();

if (j == J-1)

{

t = 1;

}

else

{

t = r.NextDouble();

}

t = X*t;

q = Find_P(t);

if (S - q >= 0)

{

S = S - q;

x[i, j] = t;

y[i, j] = q;

j++;

}

}

}

}


}

}








- .
, VIP-.
. .