Вы находитесь на странице: 1из 89

1

-

" "


.
. .
___________________________ 2011 .

220100

: . 6082/1

..

: ...,

..

-
2011 .

.86 , 5., . 7, 12, . 15, 3, . 3.



.
:
-
;
- ;
- ;
- .

.
.

, .
, ,
.
,
( )
.

()

- .
, ,
.

4
1. .......................................7
1.1. .................................................13
1.2. ........18
1.3. ....19
1.4. ........................21
........................................................................................................................................................................22
...................................................................................................................................................................22

.......................................................................................................................22

..................................................................................................................................22

...........................................................................................................................................22
.....................................................................................................................................22
...........................................................................................................................................................................22
..............................................................................................................................................................................22

2. ........................24
2.1. .............................................................................................................24
2.1.1. ...............................................................................25
2.1.2. .........................................................................26
2.1.3. ....................................................26
2.1.4. ........................................................27
2.1.5. .....................................................................................................27
2.2. ...................................................................................29
2.3. ..............................................................................................30
2.3.1. ............................................................................30
2.3.2. ....................31
2.4. ...................................................................31
2.5. - ....................33
3.
..............................................................................................................................35
3.1. .............................................36

3.2. .............................................38
3.3. ...........................................43
3.4. ....................................................................................46
4. - ................................50
4.1. ..............52
5. .................................................56
1......................................................................................................................................................................................59
2......................................................................................................................................................................................59
2......................................................................................................................................................................................59
1......................................................................................................................................................................................59
3......................................................................................................................................................................................59
1......................................................................................................................................................................................59
2......................................................................................................................................................................................59
2......................................................................................................................................................................................59
1,8...................................................................................................................................................................................59
1,82.................................................................................................................................................................................59
2......................................................................................................................................................................................59
1,6...................................................................................................................................................................................59
1,98.................................................................................................................................................................................59
2,17.................................................................................................................................................................................59
2,41.................................................................................................................................................................................59
1,19.................................................................................................................................................................................59
2,06.................................................................................................................................................................................59
1,82.................................................................................................................................................................................59
1,96.................................................................................................................................................................................59
1,77.................................................................................................................................................................................59
2,4...................................................................................................................................................................................59
1,58.................................................................................................................................................................................59
1,22.................................................................................................................................................................................59
3......................................................................................................................................................................................59
2,62.................................................................................................................................................................................59
1,99.................................................................................................................................................................................59
1,81.................................................................................................................................................................................59
1......................................................................................................................................................................................59
2......................................................................................................................................................................................59
2......................................................................................................................................................................................59
2......................................................................................................................................................................................59
3......................................................................................................................................................................................59
1......................................................................................................................................................................................59
1......................................................................................................................................................................................59
2......................................................................................................................................................................................59
2......................................................................................................................................................................................59
3......................................................................................................................................................................................59
1......................................................................................................................................................................................59
3......................................................................................................................................................................................59
2......................................................................................................................................................................................59
3......................................................................................................................................................................................59
1......................................................................................................................................................................................59
1......................................................................................................................................................................................59
3......................................................................................................................................................................................59
4......................................................................................................................................................................................59
2......................................................................................................................................................................................59
2......................................................................................................................................................................................59
2......................................................................................................................................................................................59
1......................................................................................................................................................................................59
1......................................................................................................................................................................................59
3......................................................................................................................................................................................59
1......................................................................................................................................................................................59
5......................................................................................................................................................................................59

5
2......................................................................................................................................................................................59
3......................................................................................................................................................................................59
1......................................................................................................................................................................................59
3......................................................................................................................................................................................59
1......................................................................................................................................................................................59
1......................................................................................................................................................................................59
1......................................................................................................................................................................................59
6......................................................................................................................................................................................59
2......................................................................................................................................................................................59
3......................................................................................................................................................................................59
1......................................................................................................................................................................................59
3......................................................................................................................................................................................59
2......................................................................................................................................................................................59
1......................................................................................................................................................................................59
1......................................................................................................................................................................................59
7......................................................................................................................................................................................59
1......................................................................................................................................................................................59
3......................................................................................................................................................................................59
3......................................................................................................................................................................................59
3......................................................................................................................................................................................59
3......................................................................................................................................................................................59
2......................................................................................................................................................................................59
1......................................................................................................................................................................................59
8......................................................................................................................................................................................59
1......................................................................................................................................................................................59
1......................................................................................................................................................................................59
1......................................................................................................................................................................................59
1......................................................................................................................................................................................59
2......................................................................................................................................................................................59
2......................................................................................................................................................................................59
2......................................................................................................................................................................................59
9......................................................................................................................................................................................59
2......................................................................................................................................................................................59
1......................................................................................................................................................................................59
3......................................................................................................................................................................................59
3......................................................................................................................................................................................59
1......................................................................................................................................................................................59
1......................................................................................................................................................................................59
1......................................................................................................................................................................................59
10....................................................................................................................................................................................59
2......................................................................................................................................................................................59
2......................................................................................................................................................................................59
3......................................................................................................................................................................................59
1......................................................................................................................................................................................59
1......................................................................................................................................................................................59
2......................................................................................................................................................................................59
1......................................................................................................................................................................................59
11....................................................................................................................................................................................59
1......................................................................................................................................................................................59
3......................................................................................................................................................................................59
2......................................................................................................................................................................................59
1......................................................................................................................................................................................59
3......................................................................................................................................................................................59
1......................................................................................................................................................................................59
2......................................................................................................................................................................................59
12....................................................................................................................................................................................59
1......................................................................................................................................................................................59
3......................................................................................................................................................................................59
2......................................................................................................................................................................................59
1......................................................................................................................................................................................59
2......................................................................................................................................................................................59
1......................................................................................................................................................................................59
2......................................................................................................................................................................................59
13....................................................................................................................................................................................59

6
3......................................................................................................................................................................................59
2......................................................................................................................................................................................59
3......................................................................................................................................................................................59
1......................................................................................................................................................................................59
3......................................................................................................................................................................................59
3......................................................................................................................................................................................59
1......................................................................................................................................................................................59
14....................................................................................................................................................................................59
1......................................................................................................................................................................................59
2......................................................................................................................................................................................59
1......................................................................................................................................................................................59
2......................................................................................................................................................................................59
2......................................................................................................................................................................................59
3......................................................................................................................................................................................59
2......................................................................................................................................................................................59
15....................................................................................................................................................................................59
1......................................................................................................................................................................................59
1......................................................................................................................................................................................59
2......................................................................................................................................................................................59
1......................................................................................................................................................................................59
1......................................................................................................................................................................................59
1......................................................................................................................................................................................59
2......................................................................................................................................................................................59
16....................................................................................................................................................................................59
3......................................................................................................................................................................................59
3......................................................................................................................................................................................59
3......................................................................................................................................................................................59
3......................................................................................................................................................................................59
3......................................................................................................................................................................................59
1......................................................................................................................................................................................59
3......................................................................................................................................................................................59
17....................................................................................................................................................................................59
2......................................................................................................................................................................................59
2......................................................................................................................................................................................59
3......................................................................................................................................................................................59
3......................................................................................................................................................................................59
3......................................................................................................................................................................................59
3......................................................................................................................................................................................59
2......................................................................................................................................................................................59
18....................................................................................................................................................................................59
2......................................................................................................................................................................................59
2......................................................................................................................................................................................59
1......................................................................................................................................................................................59
3......................................................................................................................................................................................59
2......................................................................................................................................................................................59
2......................................................................................................................................................................................59
3......................................................................................................................................................................................59
19....................................................................................................................................................................................59
1......................................................................................................................................................................................59
2......................................................................................................................................................................................59
3......................................................................................................................................................................................59
1......................................................................................................................................................................................59
2......................................................................................................................................................................................59
2......................................................................................................................................................................................59
3......................................................................................................................................................................................59
20....................................................................................................................................................................................59
1......................................................................................................................................................................................59
1......................................................................................................................................................................................59
1......................................................................................................................................................................................59
1......................................................................................................................................................................................59
1......................................................................................................................................................................................59
1......................................................................................................................................................................................59
1......................................................................................................................................................................................59

..............................................................................................................................73


-
.
:
-
;
- ;
- ;
- .
, ,
.
,
.

1.
,

, . ..

..
-
,
.



(). (),
.

.
,
.
, () , ,
. ,

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

, ,
.
,
. ,
. .
,
.

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

:
- ;

- ;
- .
,
()
(, , ), ,

( ). ()

),

() ( ).
1
, ,
,

, .
2
.
:
,
( ) .
,
, , ..
3
.

:
X, I, S, F , :
X ;
I ;
S () ;
F .

10

,
, . ()
,
, () ,

1 .

:
; :
,
; :
,
, (),

,
; :

(
)

( )
; ;
( )

: ,
, ;
: , , ,
,
, ; :
, ,

:
( , );
: ,

( ,
); : ,

; ;

;
;

; ;
( );

11

. ,
1 ,
, ,
, ,

2. .

;
, ();
,
;
( )
;
;
(); ;

;

( );
();
,

() ;
;

();
;

.. () ,
,

.
.
4
.

12

3.


( ,
)

(
,
)


(
); , ;

(
); (
, );
( )
;
;
; ()

; ;
( )
; ;

;
; ; ;
; ; ; ;
; ;

4. .

13

1.1.

.

.
:
1.

.
2.

.
3.

.
4.


.
5.

, .
,

( , ..). ,
.

()

.
,
.

14

X Y ( )
, (x,y), x X,
y Y. X Y (
) X Y.
X X X2 .

R

X2, .. R 2 (R X X).

R X2 (xi,xj) R ( (xi,xj) R xi R xj ),
xi X, xj X, :

xi

xj

(xi ,xj ) R:

x
, ,
.
, .. (xi,xj) R, xi X, xj
X, , xi
xj.
.
1. , (xi,xi) R xi X.
2. , xi R xj xi

xj.

3. , xi, xj X (xi,xj) R
(xj,xi) R.
4. ,

xi, xj X xi R xj

xj R xi.
5. ,

15

xi R xj xj R xi , .
, .
6. , xi, xj X
xi R xj xj R xi xi = xj.
7. , xi, xj, xk X ,
(xi,xj) R (xj,xk) R (xi,xk) R.
8. R , R
.
9.

, .
10. P ,
.
11. I ,
.
,
- .
.
.
,

,
.

() U(x)
:

U(xi) > U(xj),

(xi,xj) P;

U(xi) = U(xj), (xi,xj) I.

,
X. , X
, (,
X,
;

16


).
X (), R
X.

< X, R >,

.
xi

xj

R, xi R xj xi R xj, R R, .. xi R xj

(xi,xj) R.

,
x X
, x X \ x.

.. x

R X,

< X, R >.
x R x,

, X x.

xmax X

R X

( <X,R>), x R xmax xmax R x.


<X,R> MAX R X.
, , ,

, , .

X R: X MAX
= MAX R X.

X, R,
.

.
.

17

= ||aij||

ij i j
.

( ).
= ||ij||

n x n

ij ji , i
j .. i ~ j. i > j , ij > ji .
ij ,
ij ji.
.
.
5.

5.

1, i > j
aij =
0, i = j
0,5, i ~ j

aii = 0,5.
i j, aij 0 : ij + ji =
const
i j, aij > 0 : ij x ji = 1
i j :

ij + ji = 0

i j : 0 < aij < 1 ;

ij + ji = 1

18

.
ij .
ij - , i
j, onst - . i
j ij . i
j ij. ij
i j.

1.2.
,

x y,
. y = (x).

()

F: Y E, y = (x). x
f(y) = f ( (x) ).
F
. , F,
.
f

F,

:
F(x) max
x X

(1)

F(x)
. :
F(x)
X MAX = Arg max
xX

(2)

19

R
: (x 1,x 2 ) R , F (x 1) > F (x 2 ). F (x 1) = F
(x 2 ), x 1, x 2 R (x 1,x 2 ) R.
,

X.
..

F (x)

, ,

( 2). , F (x)
E . F
(x),

<X,R> ( 2).

R . ..
, .
,
, .

1.3.
,

x X

y Y, y = (x),
y f (y), .. fi : Y E,
. .. x
y = (x), (f1, f2, ..., fm ).

fi (x)

fi ( (x))

i = 1,...,m

x ,
F : X Em ,

F = (f1, ..., fm).

x1, x2 X. fi (x2)

fi (x1) i = 1, ..., m,

, , x1
x2.

x0

20

, x0
:

fi (x) max
xX ,

i = 1, ..., X

(3)

, PF
(X) P (X) ( )
F : X Em , F = (f1, ..., fm),
PF (X) X.
P (F) = F (P (X))
.

P (X).
x X,
fi (x).
x1 X ( 3 ),

fi (x2) > fi (x1),

x2 X,

i = 1, ..., m.

.. ,

,
fi (x), i = 1, ..., m.
SF (X) S (X),
P (X) S (X) ( S (F) = F (S (X)).
X,

: x1, x2 X
x1 R1 x2

fi (x1) > fi (x2),

i = 1, ..., m.

x1 R2 x2

fi (x1) fi (x2),

i = 1, ..., m,

(4)
fi (x1) fi (x2).

21

R1

R2

- .
SF (X), PF (X).

,
, (
) X. R1,R2
, .. R1, R2 X.

1.4.

, . ,

, .
. .
,
.

,
.
, :
- .
.

, ,
; - ,
. , ;
-

, ,
.

22


1.
(
) .


,
.

,
(,

. 1. .

. :
,
;
.

23

.
,
, .

. ,
.

.
,
,
.
:
- ,
, ,
;
- ,
.
:

z Z.

x.
: fi(x,Z) max
,
x X

i = 1, ..., m,

Z - .
x = x (Z).

Z x.

.
. ,
.
:
F (x) = min F (x,Z) max
x X

(5)

24

F (x) x
F (x,Z), .. Z.

2.
, ,
.
,
.

.
.

2.1.

.
,
(), (

).

.
,
.
:

.

.

25

. ,
.
,
,
.
(
),
.


.

2.1.1.
:
2

xi xi*
U =
,
*
x

i =1
i

(6)

xi* - i ,
xi i .

.
,
.

26

2.1.2.
6:
, ,
, , ..
,
.

6.

A1

AN


B1
B2

U11
U12

Bm
U1m

UN1

UNm

UN2

2.1.3.


.
:
1.

.
N

U = w i xi ,

(7)

i =1

wi i- , :
xi i .
N

wi

=1

(8)

i =1

. wi=1, xi
, .

27


.
2.

.
U =

i =N

w i f (xi )

(9)

i =1

f(xi)=xi.
,
.

2.1.4.
,
,
.
.

.

2.1.5.

. :
.

1,

2,

3,

: D1, D2, D3.


: p1, p2, p3.
:
3

U A = pi Di
i =1

(10)

28

.
.
,
.
SMART (.2).

, ,


( )


, ui i

. 2.
(SMART).

29

2.2.

,
MAUT ( ).
:
1.

( ).
2.

( ).
:
1.


, .
u, v, w U , u v
:
u=v, u>v, u<v;
u>v, v>w u>w.
2.

, . ..

()
:
u>v>w , u+(1+)v=w.
.
3.

. ,


.
) :
, ,
.

30

) : ,
,
.

:
U =

f i (xi ), xi i , fi
i =1

i .

2.3.
( )
, , ,
.

2.3.1.

, ,
( )
.
ki:
1.

P1(x1, y1), x1, y1 X,

Y ;
2.

X (

) x2 = x1 + ;
3.

y2 Y , P11(x2, y2)

P1 (x1, y1);
4.

31

,
(.3).
X

k1
k2 P2

P11(x2, y2)

k3
P1(x1, y1)
P3

. 3.

2.3.2.
,

.
(x1, x2, , xN), (y1, y2, , yN) x y N
. x , y ,
N

i [U i (xi ) U i (yi )] 0, Ui i ,
i =1

i , i
.

2.4.

.

32

,
, .
.
, ,
, , .

, ,
, .
.
,
,
,
.
.
, . ,
, .
..
,
.
. N ,
, p,
. a
b. I, N ,
:
I+(a, b) , a b;
I=(a, b) , a b;
I-(a, b) , b a.
a b:

33

cab =

pi

i I + , I =
N

(11)

pi
i =1

: I-(a,
b) dab b a.
a b, cab c1
dab d1 ( c1, d1 ).

.
.
S1S2S3.

, , ,
.

(.4).

2.5. -
, .
,
.

DRn, :
A x b x = (x1, x 2, , xn ) xi 0, 1 i n

34

N C1, C2, , CN,


C j (x ) =

cij xi
i =1

. 4. .

x*,

N
.
.

,
.
,
.

35

,
.

3.


.
:
1)


,
,
;

2)


,
,

;
3)


,
,
.
.

36

3.1.
: ,
,
. ( );

(, . ,
(

),

, .. :
,
1.
,
(..
, ,
) 2.
,
:
;
, , ,
.
= 1
.

37

:
, .

,
( ).
.
,
. :
1, i - l - ;
xil =
0 ;
vij j- i- ;
Vij j- l- ;
Ui i- .
I=1, 2, , ,
I

= {i I / j I , U j U i ,

l =1

x lj

xil }
l =1

,
.
:
K

O2 = xil max,

(12)

l =1 i =1

O1 = I

x
l =1 i =1

l
i

max,

vij xil Vil , j = 1, , P, l = 1, , K,


i =1

xil 1
l =1

(13)

38


:
;

,
.

3.2.
N ,
. (2+m): ( +
+ m) .
L .
, , (2+m)
.
:
, :

,
.
,
,
.

.

.
,
, , ,
.

39

. :
N ;
M ;
L ;
Ml l- , l = 1, L ;
pit t- i- ,
t = 1, 2, i = 1, N ;
sit t- i- ,
t = 1, m , i = 1, N ;
Pit t-
l- , t=1, 2, l = 1, L ;
Sit t-
l- , t = 1, m , l = 1, L ;
*t (>, <, , =) t-
,
t = 1, m ;
Cl l- ,
l = 1, L ;
Q ,
;
iq i- q- ,
i = 1, N , q = 1,Q .
:
1, i j l ;
xilj =
0, (i = 1, N ,l = 1, L , j = 1, M l ).

1, j l ;
yl j =
0, (l = 1, L , j = 1, M l ).

40

:
N

L Ml

xilj max
i =1 l =1 j =1

.
L Ml

Clj ylj min


l =1 j =1


, .
N

x
i =1

j
il

pit Pltj ylj , t = 1, 2, l = 1, L , j = 1, M l

, ,
.
s it xilj t Sltj ylj , t = 1, m , i = 1, N , l = 1, L , j = 1, M l

.
L

Ml

x
l =1 j =1

j
il

N,

i = 1, N

41

,
.
i1 = 1, N , i 2 = 1, N l1 = 1, L j1 = 1, M l ,
1

xijl = 1, l 2 = 1, L (l1 l 2 ), j e = 1, M l , xij l = 0, ui ui


1

1 1

2 2

.
xilj = 0 1,

ylj = 0 1,

i = 1, N , l = 1, L , j = 1, M l

.
,
,
, -.
:
N

L Ml

xilj max
i =1 l =1 j =1

x
i =1

j
il

pit Pltj ylj ,

t = 1, 2, l = 1, L , j = 1, M l

sit xilj t Sltj ylj , t = 1, m , i = 1, N , l = 1, L , j = 1, M l


L

Ml

x
l =1 j =1

j
il

N,

i = 1, N

42

i1 = 1, N , i 2 = 1, N l1 = 1, L j1 = 1, M l ,
1

xijl1
1 1

= 1, l 2 = 1, L

xilj = 0 1,

(l1 l 2 ), j e = 1, M l , xij l2
2 2

ylj = 0 1,

= 0, ui ui
1

i = 1, N , l = 1, L , j = 1, M l


, .
:
L Ml

Clj ylj min


l =1 j =1
N

x
i =1

j
il

t = 1, 2, l = 1, L , j = 1, M l

pit Pltj ylj ,

sit xilj t Sltj ylj , t = 1, m , i = 1, N , l = 1, L , j = 1, M l


L

Ml

x
l =1 j =1

j
il

N , i = 1, N

xilj = 0 1,

ylj = 0 1,

i = 1, N , l = 1, L , j = 1, M l


, 1,
.


. ,
.

43

3.3.


.
, 1- ,
,
.
. .
,
, .
NP-, ..,
.
:
- " ". -
.
. ,
, .
.
- " ".
. "
".
- " ". -
. "
", :

44

- " ".
" ",
.
,

.
:
,
, , ..

.
:
1.

" "

.
2.

, .
3.

.

,
" " ,
.
.

.
.
5.

45



,


?


0?

. 5.

46

3.4.

6.

. ,
(
).
1. .

:
P0 = {( xi , x j ) X X / k = 1, , N ;
y jp < y ip

y ik y kj p,

(14)

2. P0
.
..
. .
3. ,
.
, (i-1) , ,
i . ,
(i-1)- i-
i- (i+1)-
, , ,
. VI,
,
.
.

47

,
.

O1 O2.

. 6. .
IV V.
4. (i-1), i (i+1) , .. ,
, .
,
. , , ,

48

(.. ,
), ,
,
.

Y.
, P0.
5.
.


.
,
.
Y .

, 7.

49

. 7.
.

50

4. -

1. .
,
. ( ).
2. -
-
.
,
. , , ,
.
,
. -
. ,

.

, -
-
.

( ) (
).

51

, -,
- .
-
, :
-

- ();
-

()
().
-

:
-

,
;

- ;
-

,
;

- ;
- ;
- .
-
,
,
. -
. 4
:
- ;
- ;
- ;
- .
-

52

,
-.
:
- ;
- ;
- .

4.1.
.
Obj:
Class Obj {
public:
int nomer;
int weight, volume;
Obj() {nomer = 0;
weight = 0;
volume = 0;}
};
:
nomer ;
weight ;
volume .
,
.
, .
.
:
class Predmet : public Obj {
public :
int rate1, rate2, rate3, rate4, rate 5;

53

int mark;
double polza1, polza2;
Predmet(int num, int w, int v, int r1, int r2, int r3, int r4,int r5)
{
nomer = num;
weight = w;
volume = v;
rate1 = r1;
rate2 = r2;
rate3 = r3;
rate4 = r4;
rate5 = r5;
mark = 999;
polza1 = 0.45*r1 + 0.45*r2 + 0.034*r3 + 0.033*r4 + 0.033*r5;
polza2 = (double)(r1 + r2 + r3 + r4 + r5);
}//
Predmet() : Obj(){
rate1 = 0;
rate2 = 0;
rate3 = 0;
rate4 = 0;
rate5 = 0;
mark = 999;
polza1 = 0;
polza2 = 0;
}
};

54

Obj.
, (
) . :
rate1, rate2, rate3, rate5 ;
polza1, polza2 ( )
mark .

.
Obj,
.
,
Obj:
Class Konteiner : public Obj {
Konteiner(int num, int w, int v) {
nomer = num;
weight = w;
volume = v;
}
Konteiner() :Obj()
};
Predmet, Konteiner .
Obj , (
). ,
:
OBJ

PREDMET

KONTEINER

55

,
.
class Variant {
public :
int kol;
double polsa1, polsa2;
Variant() {
kol = 0;
polsa1 = 0;
polsa2 = 0;
}
};

, .
:
Predmet Obj1[20], Obj2[20], Obj_por[20], Obj_por1[20]; -
(
, Predmet mark (),
, ).
Konteiner

box[3];

.
Variant

var[40],

var1[40];

.

.
:
for(i = 0; i < 20; i++)
Obj1[i] = Predmet(i, random(15), random(10), random(5), random(5),
random(5), random(3), random(3));
box[0] = Konteiner(0,30,25);

56

box[1] = Konteiner(1,40,20);
box[2] = Konteiner(1,25,30);
,
, .
,
.

5.
:
20 .
, .
( 1 2) ,
. .
,
:
U =

w i xi
i =1

wi i- , :
xi i .
N- .
, :
N

wi

=1

i =1

1 2 ,

.
7.

57

7.

1
2
3
4
5

, wi
0,45
0,45
0,034
0,033
0,033

8 ,
() .

9.
,

, .. 1 2 .
(. 10)
, ..
.
. 11 1.

.
, 1 2
:
, i
1
2

, vi
0,6
0,4

:
Ua= O1v1+O2v2

(. 12). .

58


. ,
. 13. ,
.14 2. . 15
. .

. .

:
P0 = {( xi , x j ) X X / k =1, , N ;

y jp < y ip

y ik y kj p,

Q ,yi- I- .
P0
.
.. .
.
.
, .. P0.
, ..
, - ,
.

, . 3 ,
.

8.

K1

K2

K3

K4

K5

Ui

59

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

2
2
1
2
2
2
1
1
2
2
1
1
3
1
1
3
2
2
1
1

2
2
3
2
3
3
3
1
1
2
3
3
2
2
1
3
2
2
2
1

1
3
2
2
1
1
3
1
3
3
2
2
3
1
2
3
3
1
3
1

3
1
3
1
3
3
3
1
3
1
1
1
1
2
1
3
3
3
1
1

1
1
1
1
1
2
3
2
1
1
3
2
3
2
1
3
3
2
2
1

2
2
1
3
1
1
2
2
1
2
1
1
3
3
1
1
3
2
2
1

2
2
3
1
1
1
1
2
1
1
2
2
1
2
2
3
2
3
3
1

1,8
1,82
2
1,6
1,98
2,17
2,41
1,19
2,06
1,82
1,96
1,77
2,4
1,58
1,22
3
2,62
1,99
1,81
1

:
U1 = 2 * 0.2 + 2 * 0.18 + 0.22 + 3 * 0.21 +0.19 = 1.8

9.

60

, Wki
5

Vki
7

10. ,

61

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

16
17
7
13
6
9
3
18
5
11
2
10
19
1
12
4
14
15
8
20

3
2,62
2,41
2,4
2,17
2,06
2
1.99
1,98
1,96
1.82
1,82
1,81
1,8
1,77
1,6
1,58
1,22
1,19
1

11.

1
2
3
4
5
6
7

, 2

14
14
15
15
15
14
14

, 1
30,07
28,61
28,59
29,8
27,79
24,6
23,54

62

8
9
10
11
12
13
14
15
16
17
18
19
20

(1)

15
14
14
13
14
13
14
14
13
15
15
15
15

26,71
25,74
25,36
23,94
26,05
24,57
26,82
27,01
25,24
29,4
29,64
30,22
30,81

63

(2)

1.

12.

64

14
14
15
15
15
14
14
15
14
14
13
14
13
14
14
13
15
15

30,07
28,61
28,59
29,8
27,79
24,6
23,54
26,71
25,74
25,36
23,94
26,05
24,57
26,82
27,01
25,24
29,4
29,64

23,642
22,766
23,154
23,88
22,674
20,36
19,724
22,026
21,044
20,816
19,564
21,23
19,942
21,692
21,806
20,344
23,64
23,784

15

30,22

24,132

15

30,81

24,486

13.

4
3
13
16
14
18

, Wi
3
1
3
1
3
2

,Vi

1
3
1
3
2
3

1,6
2
2,4
3
1,58
1,99

65

17
19
1
2
7
8
10
11
6
15
5
12
9
20

3
2
2
2
2
2
2
1
2
1
1
1
1
1

2
3
2
2
1
2
1
2
1
2
1
2
1
1

2,62
1,81
1,8
1,82
2,41
1,19
1,82
1,96
2,17
1,22
1,98
1,77
2,06
1

14. ,


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

, 2

10
11
10
11
11
13
14
14
14
15
14
15
14
13
14
13

, 1
20,62
22,62
20,62
22
21,17
24,56
25,63
24,61
24,8
28,4
26,58
27,74
26,55
24,73
27,2
25,03

66

17
18
19
20

12
11
12
11

23,81
21,83
23,68
21,62

(1)

(2)
2. ( )

67

15. ( ).
, 2

, 1

10
11
10
11
11
13
14
14
14
15
14
15
14
13
14
13
12
11
12
11

20,62
22,62
20,62
22
21,17
24,56
25,63
24,61
24,8
28,4
26,58
27,74
26,55
24,73
27,2
25,03
23,81
21,83
23,68
21,62

16,372
17,972
16,372
17,6
17,102
19,936
20,978
20,366
20,48
23,04
21,548
22,644
21,53
20,038
21,92
20,218
19,086
17,498
19,008
17,372

68

.
.
, 5
, . . . :
1

1
2
3
4
5
6
7
8
9
1
0
1
1
1
2
13
1
4
1
5
1
6
1
7
1
8
19
2
0

1
1

1
2

13 1
4









1
5

1
6

1
7

1
8

19 20

1
0

69

- , , ,
.
.
.
. ,
16. 20 ,
. . .
:

1
2
3
4
5
6
7
8
9
1
0
1
1
1
2
13
1
4
1
5
1
6
1
7
1
8

1
1

1
2

13 1
4









1
5

1
6

1
7

1
8

19

1
0

70

19

: 15, 8, 1.
2

1
0

1
1

1 13 1
2
4







1
6

1
7

1 19
8







2
3
4
5
6
7
9
1
0
1
1
1
2
13
1
4
1
6
1
7
1
8
19

: 3, 4, 5, 9, 12, 14, 19.


2

1
0
-
-
-
-

2
6
7
1
0
1
1
13
1
6

1
1

13 1
6



1
7

18

71

1
7
1
8

: 2, 10, 11, 18.


6

: 6, 7,

13 1
6
6 -
7 -
13 -
1 6
1
7

17

13, 17.

16
1 6

16.
( , -
):
1
2
3
4
5
6

20
1
9
18
17
16
15
3
11
7
8
5
2
13
19
10
6
12
4
14
:
1 16, 17, 6;
2 7, 13;
3 19, 11, 9, 5;

72

4 2, 10, 3;
5 19, 12, 1.
1 = 31,61; 2 = 15; U = 24,966

(1)

(2)
3.

,
.

. . ,
,
. ,
.
,

,
,

73

( ), .
,
.
,
.
,
++. 1.
2. -
3.

( )
.
.

.

, .
, ,
.
,
, , ,
.
.
.

74

1. . . , . : , 2010. 115 .
2. . . . -:
, 2008. 220 .
3. .. : , , . .:
- , 1980. 208.
4. . -
. .: , 1997. 452.
5. .. . .: - ,
1979. 200.
6. .. . .: -
, 1987. 480.
7. .., .. Visual C++. .: - -,
2001. 304 .
8. 7.1-84 . .
. .: - , 1984. 76.
9. 2.105-95. . . .: , 1995. 147.
8. . / .. , .. .
.: - - , 1996. 208.
10. ++. / .. , .. . .:
, 2001. 1120.
11. . / ..
, .. . .: - , 1982. 256.
12.
. / .. , .. , .. , .. . .:
- , 1999. 287 .

75

76

1.
.

.
/

77

2.
++ -
.
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <fstream.h>
#include <math.h>
#include <conio.h>
#include <time.h>
using namespace std;
int random(int a) {
int r;
r = (int)((rand()/32767.)*a)+1;
return r;
// ""
class Predmet {
public:
int nomer;
int weight, volume;
int rate1, rate2, rate3, rate4, rate5;
int mark;
int polza;
Predmet(int num,int w,int v,int r1,int r2,int r3,int r4,int r5){
nomer = num;
weight = w;
volume = v;
rate1 = r1;
rate2 = r2;
rate3 = r3;
rate4 = r4;
rate5 = r5;

78

mark = 999;
polza = r1 + r2 + r3 + r4 + r5;
} //
Predmet(){
nomer = 0;
weight = 0;
volume = 0;
rate1 = 0;
rate2 = 0;
rate3 = 0;
rate4 = 0;
rate5 = 0;
mark = 999;
polza = 0;
} //
}; // End of ""
// ""
class Konteiner {
public:
int nomer;
int weight, volume;
Konteiner(int num, int w, int v) {
nomer = num;
weight = w;
volume = v;
} //
Konteiner() {
nomer = 0;
weight = 0;
volume = 0;
} //
}; // End of ""
class Variant {
public:
int kol;
int polsa;
Variant() {
kol = 0;

79

polsa = 0;
} //
}; // End of ""
char buffer[2];
//void clrscr(void);

//

int Menu() {
cout<<"\n\t Select Algorithm \n"
"\n\t 1 - Build order on set of alternatives"
"\n\t 2 - Algorithm with rejection at alternation"
"\n\t 0 - Exit \n";
cin.getline(buffer,255);
return buffer[0] - '0';
}

void main() {
ofstream out("my.txt",ios::out|ios::trunc);
srand(0); //(unsigned)time(NULL));
//
char f;
/*
cout<<"\n\t Select Algorithm \n"
"\n\t 1 - Build order on set of alternatives"
"\n\t 2 - Algorithm with rejection at alternation"
"\n\t 0 - Exit \n";
cin.getline(buffer,255);
int z = buffer[0] - '0';
*/
int i, j;
cout<<"\n";
int W_max_Ob, V_max_Ob, max_Pol;
int k;
Predmet Obj1[20], Obj2[20], Obj_por[20], Obj_por1[20], Ob;
Variant var[40], var1[40];
int var_polza, var_polza1;
int m, mm;

80

Konteiner box[2];
int number[20];
for(i = 0; i < 20; i++)
Obj1[i] = Predmet(i, random(15), random(10),
random(5), random(5), random(5),
random(3), random(3));
for(i = 0; i < 20; i++) Obj2[i] = Obj1[i];
for(i = 0; i < 20; i++) {
cout<<"Obj1 N "<<Obj1[i].nomer<<"\n";
cout<<"Weight = "<<Obj1[i].weight<<"\t";
cout<<"Volume = "<<Obj1[i].volume<<"\t";
cout<<"Rating = "<<Obj1[i].rate1<<"\t";
cout<<Obj1[i].rate2<<"\t";
cout<<Obj1[i].rate3<<"\t";
cout<<Obj1[i].rate4<<"\t";
cout<<Obj1[i].rate5<<"\t";
cout<<"Polza = "<<Obj1[i].polza<<"\n\n";
out<<"Obj1 N "<<Obj1[i].nomer<<"\n";
out<<"Weight = "<<Obj1[i].weight<<"\t";
out<<"Volume = "<<Obj1[i].volume<<"\t";
out<<"Rating = "<<Obj1[i].rate1<<"\t";
out<<Obj1[i].rate2<<"\t";
out<<Obj1[i].rate3<<"\t";
out<<Obj1[i].rate4<<"\t";
out<<Obj1[i].rate5<<"\t";
out<<"Polza = "<<Obj1[i].polza<<"\n\n";
}

while (1) {
switch (Menu()) {
case 1: {
cout<<"\n\n\n Porjadok \n";
out<<"\n\n\n Porjadok \n";
// ( )
/*
for(j = 0; j < 20; j = j+2) {
W_max_Ob = Obj2[0].polza;

81

V_max_Ob = Obj2[0].polza;
for(i = 0; i < 20; i++) {
if (Obj2[i].polza >= W_max_Ob) {
W_max_Ob = Obj2[i].polza;
}
} //for i
for(i = 0; i < 20; i++) {
if (Obj2[i].polza == W_max_Ob) k = i;
} // for i
Obj_por1[j] = Obj2[k];
Obj2[k] = Predmet();
Obj2[k].nomer = k;
for(i = 0; i < 20; i++) {
if (Obj2[i].polza >= V_max_Ob) {
V_max_Ob = Obj2[i].polza;
}
} //for i
for(i = 0; i < 20; i++) {
if (Obj2[i].polza == V_max_Ob) k = i;
} // for i
Obj_por1[j+1] = Obj2[k];
Obj2[k] = Predmet();
Obj2[k].nomer = k;
} // for j
*/
for(j = 0; j < 20; j++) {
max_Pol = Obj2[0].polza;
for(i = 0; i < 20; i++) {
if (Obj2[i].polza >= max_Pol) max_Pol =
Obj2[i].polza;
} //for i
for(i = 0; i < 20; i++) {
if (Obj2[i].polza == max_Pol) {
k = i;
break;
}
} //for i
Obj_por1[j] = Obj2[k];

82

Obj2[k] = Predmet();
Obj2[k].nomer = k;
} //for j
cout<<"\n\n";
out<<"\n\n";
for(i = 0; i < 20; i++) {
cout<<"Obj_por N "<<Obj_por1[i].nomer<<"\n";
cout<<"Weight = "<<Obj_por1[i].weight<<"\t";
cout<<"Volume = "<<Obj_por1[i].volume<<"\t";
cout<<"Rating = "<<Obj_por1[i].rate1<<"\t";
cout<<Obj_por1[i].rate2<<"\t";
cout<<Obj_por1[i].rate3<<"\t";
cout<<Obj_por1[i].rate4<<"\t";
cout<<Obj_por1[i].rate5<<"\t";
cout<<"Polza = "<<Obj_por1[i].polza<<"\n\n";
out<<"Obj_por N "<<Obj_por1[i].nomer<<"\n";
out<<"Weight = "<<Obj_por1[i].weight<<"\t";
out<<"Volume = "<<Obj_por1[i].volume<<"\t";
out<<"Rating = "<<Obj_por1[i].rate1<<"\t";
out<<Obj_por1[i].rate2<<"\t";
out<<Obj_por1[i].rate3<<"\t";
out<<Obj_por1[i].rate4<<"\t";
out<<Obj_por1[i].rate5<<"\t";
out<<"Polza = "<<Obj_por1[i].polza<<"\n\n";
}//for i
//
for(j = 0; j < 40; j++) {
for(i = 0; i < 20; i++) number[i] = 0;
box[0] = Konteiner(0,30,30);
box[1] = Konteiner(1,40,40);
var_polza1 = 0;
m = 0;
mm = 0;
Ob = Obj_por1[0];
for(i = 0; i < 19; i++) Obj_por1[i] = Obj_por1[i+1];
Obj_por1[19] = Ob;
for(i = 0; i < 20; i++) {
if ((Obj_por1[i].weight <= box[0].weight) &&

83

(Obj_por1[i].volume <=
box[0].volume)) {
box[0].weight = box[0].weight Obj_por1[i].weight;
box[0].volume = box[0].volume Obj_por1[i].volume;
m++;
var_polza1 = var_polza1 +
Obj_por1[i].polza;
Obj_por1[i].mark = 1;
}
else
if ((Obj_por1[i].weight <= box[1].weight) &&
(Obj_por1[i].volume <=
box[1].volume)) {
box[1].weight = box[1].weight Obj_por1[i].weight;
box[1].volume = box[1].volume Obj_por1[i].volume;
mm++;
var_polza1 = var_polza1 +
Obj_por1[i].polza;
Obj_por1[i].mark = 1;
}
else Obj_por1[i].mark = 999;
} // for i
var1[j].kol = m+mm;
var1[j].polsa = var_polza1;
cout<<"Variant N "<<j<<"\n";
cout<<"Number of Objects = "<<var1[j].kol<<"\t";
cout<<"Polza = "<<var1[j].polsa<<"\n";
cout<<"m = "<<m<<"\t";
cout<<"mm = "<<mm<<"\n";
out<<"Variant N "<<j<<"\n";
out<<"Number of Objects = "<<var1[j].kol<<"\t";
out<<"Polza = "<<var1[j].polsa<<"\n";
out<<"m = "<<m<<"\t";
out<<"mm = "<<mm<<"\n";
for(i = 0; i < 20; i++) {
if (Obj_por1[i].mark == 1) {
cout<<Obj_por1[i].nomer<<"\t";
out<<Obj_por1[i].nomer<<"\t";
}

84

else {
cout<<999<<"\t";
out<<999<<"\t";
}
}
// for i
cout<<"\n\n";
out<<"\n\n";
} // for j
break;
}
case 2: {
cout<<"\n\n\n AOCh \n";
out<<"\n\n\n AOCh \n";
// ()
for(j = 0; j < 20; j = j+2) {
W_max_Ob = Obj1[0].weight;
V_max_Ob = Obj1[0].volume;
for(i = 0; i < 20; i++) {
if (Obj1[i].weight >= W_max_Ob) {
W_max_Ob = Obj1[i].weight;
}
} //for i
for(i = 0; i < 20; i++) {
if (Obj1[i].weight == W_max_Ob) k = i;
} // for i
Obj_por[j] = Obj1[k];
Obj1[k] = Predmet();
Obj1[k].nomer = k;
for(i = 0; i < 20; i++) {
if (Obj1[i].volume >= V_max_Ob) {
V_max_Ob = Obj1[i].volume;
}
} //for i
for(i = 0; i < 20; i++) {
if (Obj1[i].volume == V_max_Ob) k = i;
} // for i
Obj_por[j+1] = Obj1[k];

85

Obj1[k] = Predmet();
Obj1[k].nomer = k;
} // for j
cout<<"\n\n";
out<<"\n\n";
for(i = 0; i < 20; i++) {
cout<<"Obj_por N "<<Obj_por[i].nomer<<"\n";
cout<<"Weight = "<<Obj_por[i].weight<<"\t";
cout<<"Volume = "<<Obj_por[i].volume<<"\t";
cout<<"Rating = "<<Obj_por[i].rate1<<"\t";
cout<<Obj_por[i].rate2<<"\t";
cout<<Obj_por[i].rate3<<"\t";
cout<<Obj_por[i].rate4<<"\t";
cout<<Obj_por[i].rate5<<"\t";
cout<<"Polza = "<<Obj_por[i].polza<<"\n\n";
out<<"Obj_por N "<<Obj_por[i].nomer<<"\n";
out<<"Weight = "<<Obj_por[i].weight<<"\t";
out<<"Volume = "<<Obj_por[i].volume<<"\t";
out<<"Rating = "<<Obj_por[i].rate1<<"\t";
out<<Obj_por[i].rate2<<"\t";
out<<Obj_por[i].rate3<<"\t";
out<<Obj_por[i].rate4<<"\t";
out<<Obj_por[i].rate5<<"\t";
out<<"Polza = "<<Obj_por[i].polza<<"\n\n";
} // for i
//
for(j = 0; j < 40; j++) {
for(i = 0; i < 20; i++) number[i] = 0;
box[0] = Konteiner(0,30,30);
box[1] = Konteiner(1,40,40);
var_polza = 0;
m = 0;
mm = 0;
Ob = Obj_por[0];
for(i =
0; i < 19; i++) Obj_por[i] = Obj_por[i+1];
Obj_por[19] = Ob;
for(i = 0; i < 20; i++) {
if ((Obj_por[i].weight <= box[0].weight) &&

86

(Obj_por[i].volume <= box[0].volume))


{
box[0].weight = box[0].weight Obj_por[i].weight;
box[0].volume = box[0].volume Obj_por[i].volume;
m++;
var_polza = var_polza +
Obj_por[i].polza;
Obj_por[i].mark = 1;
}
else
if ((Obj_por[i].weight <= box[1].weight) &&
(Obj_por[i].volume <= box[1].volume))
{
box[1].weight = box[1].weight Obj_por[i].weight;
box[1].volume = box[1].volume Obj_por[i].volume;
mm++;
var_polza = var_polza +
Obj_por[i].polza;
Obj_por[i].mark = 1;
}
else Obj_por[i].mark = 999;
} // for i
var[j].kol = m+mm;
var[j].polsa = var_polza;
cout<<"Variant N "<<j<<"\n";
cout<<"Number of Objects = "<<var[j].kol<<"\t";
cout<<"Polza = "<<var[j].polsa<<"\n";
cout<<"m = "<<m<<"\t";
cout<<"mm = "<<mm<<"\n";
out<<"Variant N "<<j<<"\n";
out<<"Number of Objects = "<<var[j].kol<<"\t";
out<<"Polza = "<<var[j].polsa<<"\n";
out<<"m = "<<m<<"\t";
out<<"mm = "<<mm<<"\n";
for(i = 0; i < 20; i++) {
if (Obj_por[i].mark == 1) {
cout<<Obj_por[i].nomer<<"\t";
out<<Obj_por[i].nomer<<"\t";

87

}
else {
cout<<999<<"\t";
out<<999<<"\t";
}
} // for i
cout<<"\n\n";
out<<"\n\n";
} // for j
break;
}
case 0: {
out<<"BRED";
cout<<"\n";
out.close();
return;
}
default:;
} // switch
} // while
} // main

88

3.
.

- .

20 , ( ),
5 .
.

89

,
( ),
, , ,

(999 , ).
0.

Вам также может понравиться