Home > Software engineering >  Programming for help
Programming for help

Time:10-04

I according to the program block diagram of a run is not appropriate, entitled: f (x)=(x1-2) ^ 2 + (x2-1) ^ 2, constraint conditions: g1 (x)=x1 ^ 2 - x2 ^ 2 & lt;=0
G2 (x)=x1 + x2-2 & lt;=0, initial point x=f (x0) (3, 3)=5 optimal solution x=(1, 1) f (x)=1
Block diagram
Programming is as follows:

 Private Sub Command1_Click () 
As Single Dim r1 (8) and r2 (8) As Single
As Single Dim e1 (8), e2 (8) As Single
As Single Dim x1 (8), x2 (8) As Single
As Single Dim g1 (8), g2 (8) As Single
As Single Dim f (8)
X01=3: x02=3: t0=0.1: c=0.01
Fx0=5
F0=fx0
Fl=fx0
M1: t=t0
For j=1 To 8
Randomize
R1 (j)=2 * Rnd - 1
R2 (j)=2 * Rnd - 1
E1 (j)=r1 (j)/(Sqr (Abs (r1 + r2 (j) (j))))
E2 (j)=r2 (j)/(Sqr (Abs (r1 + r2 (j) (j))))
The x1 (j)=x01 + t * e1 (j)
X2 (j)=x01 + t * e2 (j)
If g1 (j)=x1 (j) ^ 2 - x2 (j) & lt;=0 And g2 (j)=x1 x2 (j) - (j) + 2 & lt;=0 Then
F (j)=(x1 (j) - 2) ^ 2 + (x2 (j) - 1) ^ 2
If f (j) & lt; Fl Then
Fl=f (j)
D1=e1 (j)
D2=e2 (j)
Xl1=x1 (j)
Xl2=x2 (j)
End the If
End the If
Next j
A=xl1
B=xl2
M2: t=1.3 * t
A=a + t * d1
B=b + t * d2
If (a ^ 2 - b) & lt;=0 And (a + b - 2) & lt;=0 Then
Y=(a - 2) ^ 2 + b (1) ^ 2
If y & lt; Fl Then
Fl=y
GoTo m2
End the If

M3: a=a - t * d1
B=b - t * d2
T=0.7 * t
A=a + t * d1
B=b + t * d2
If (a ^ 2 - b) & lt;=0 And (a + b - 2) & lt;=0 Then
Y=(a - 2) ^ 2 + b (1) ^ 2
If y & lt; Fl Then
If Abs ((f0 - y)/f0) & lt; Then c
Print a, b
Print y
The Else
F0=y
Fl=y
GoTo m1
End the If
The Else
GoTo m3
End the If
The Else
GoTo m3
End the If
The Else: GoTo m3
End the If
End Sub

Response after the run, and not to the results

CodePudding user response:

Debugging, this should be algorithm design problem, this code is the original, should first before you ask to know the meaning of this flow chart

CodePudding user response:

CodePudding user response:

This is not going to let me help you write,
Debug program when trapped in the M3, and you won't come in that may have a problem
  • Related