. , , ,

,,,

. "", — ,

堠 " " 󠠠 . . -1-95.

: . .

1.     

1.1    

1.2    

2.     

2.1   

2.2   

2.3   

2.4    .

2.5    .

2.6    .

2.7   

3.      :

3.1    

3.2    

3.3    

3.4    

4.     

4.1     20.09

4.2     01.10

4.3     15.10

4.4     1.11

4.5     1.12

4.6     10.12

4.7     15.12

4.8     2.09

.. /________________/

򠠠 .. /________________/

ࠠ -1-95


充..3

1. "" 3

2. , ..3

3. ....6

4. .7

5. .9

6. ....9

7. 셅.12

充..12

( ) ...14

.30


. , .

, , , , .

, . , .

.

1.

. , . , , , , , , . .

, ( ) , -. - , .

2. ,

. .

, . , , : , , , , , . , , , , .

:

-

, $

1

-3

1000

0.33

6

2

30

22

8

3

15

51

10

4

70

20

7

5

-50

1000

2

18

6

-35

120

20

6

7

-22

500

3

10

8

Vertex

1000

4

14

9

Sunpride

800

0.4

10

10

Hausbauer

1000

11

7

11

-28

40

350

20

12

1000

21

4

.

.

, $

1

2-

120

900

0.25

7

2

10

50

20

4

3

1

20

50

8

4

900

9000

1

11

5

30

100

15

9

6

900

9000

1

12

7

50

700

2

10

8

Vertex

1000

9000

3

11

9

10

200

15

6

10

2000

9000

0.3

4

11

Marlit

1000

8000

10

6

12

700

1200

0.9

8

13

7

20

65

3

14

Arkon

Interchemall

3000

9000

10

10

15

Worms

Nord Star

35

1000

300

18

.1. .2.


.

-

.


.1. ( ).


.

.


.2. ().

3.

(database) . , , ( Pascal C).

:

(N,F,T,P,M,X,C,D)

(N,F,T,P,K,C,D)

N - , F - -, T , P , M , X , , D , K . N, M, X, K, D , F, T, P , .

kurs1.dat, kurs2.dat.

4.

. , , , , , . : S=I , 1,2,,n , , ( ) , I.

( ), , ( ) . sup, . : Ki sup Kj, t Ki Kj, .. Kj Ki ( Ki Kj). , , isa. ki isa K , ki K.

. , , .

- , .

.3.

(database) :

sup(Ki,Kj)

Ki Kj .

web.dat.



5.

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

. , , (.. ).

, -50, 1000 2$ 18 :

. .

-

4

900

9000

1

11

6

900

9000

1

12

12

700

1200

0.9

8

, , , , . , .

6.

- . . , .

: , , , , , , , , _, :

1.      , :,

:, :,

:, : , :

2.     

3.      _, :_

4.     

1-4 :

1.      , (), .

2.     

3.     

4.     

f: A1A2An A1, A2,,An , B . A B. , B=T, T={1,0} , P: A1A2An P .

, . , . . , , , , .

.4, .5.

_

_


.4.



database. :

database

(, )

()

(N): (,), N=.

:

1<= 2.

7.

, . . , .. .

, , .

- , , .

.6.

, . Turbo Prolog 2.0.



/*==========================================================*/

/* " " */

/* "" */

/* : .., . -1-95 */

/*==========================================================*/

code=8850

domains

,,,Str=string

Int,N,,_,=integer

=real

/* */

database -

(integer,,,,,_,,)

database -

(N,,,,,,)

database - sup

sup(Str,Str)

database - contract

contract(integer,integer)

database - best

best(integer,integer,integer,integer)

database - best2

best2(integer,integer,integer,integer)

database - flag

flag(Int)

predicates

start

view(Int)

autoload

working(Int)

main_menu

correct(Int)

interact(integer)

warning(integer)

form_best(integer,integer,integer,integer)

form_best2(integer)

f_b2(integer,integer,integer,integer)

fb1(integer,integer,integer,integer)

fb2(integer,integer,integer,integer)

del(Int)

del_sup(string)

ins_sup(string)

view_sup(string)

sve

save_bd

ask

error

io_error

ok

repeat

checkcontr(integer)

all_contract

print_contract

cmp_name(string,string)

find_web(Str,Str)

prn(integer,string)

goal

start.

clauses

/* */

start:-

makewindow(1,26,94," ",0,0,25,80),

clearwindow,

autoload,

main_menu.

/* */

autoload:-

retractall(_,),

existfile("kurs1.dat"),

consult("kurs1.dat",),

retractall(_,),

existfile("kurs2.dat"),

consult("kurs2.dat",),

retractall(_,sup),

existfile("web.dat"),

consult("web.dat",sup),

cursor(21,30),

write("* *").

autoload:-

makewindow(2,74,79,"",6,18,8,40),

cursor(2,10),

write(" "),

sound(70,294),

removewindow,

!.

/* */

main_menu:-

repeat,

cursor(7,0),

write(" 0 - ... "),nl,

write(" 1 - "),nl,

write(" 2 - "),nl,

write(" 3 - "),nl,

write(" 4 - "),nl,

write(" 5 - "),nl,

write(" 6 - "),nl,

write(" =>"),

readint(C),

clearwindow,

working(C),

clearwindow,

C = 6,

retractall(_),

removewindow.

/* */

working(0):-

makewindow(3,27,30," ...",0,0,25,80),

nl,nl,

write(" p-p "),

nl,nl,

write(" ꠠ "),

nl,nl,nl,nl,

write(" "),

nl,

write(" TURBO-PROLOG v.2.0."),

nl,nl,nl,

write(" p: .."),

nl,nl,

write(" , p.-1-95 () 1997 . "),

nl,

sound(5,220),

cursor(22,26),

write(" "),

readchar(_),

removewindow,!.

/* */

working(1):-

makewindow(4,26,48,"pp ",0,0,25,80),

sound(5,220),

repeat,

nl,

nl,

cursor(9,0),

write(" 1 - "),nl,

write(" 2 - "),nl,

write(" 3 - "),nl,

write(" 4 - "),nl,

write(" 5 - " ),nl,

write(" =>"),

readint(X),

clearwindow,

X>0,X<=5,

correct(X),

clearwindow,

X=5,!,

removewindow.

/* */

working(2):-

makewindow(5,48,107," ",0,0,25,80),

sound(5,220),

repeat,

cursor(7,0),

write(" 1 - "),nl,

write(" 2 - "),nl,

write(" 3 - "),nl,

write(" 4 - "),nl,

write(" => "),

readint(I),

clearwindow,

I>0,I<=4,

del(I),

clearwindow,

I=4,!,

removewindow.

/* */

working(3):-

makewindow(6,30,26,"p ",0,0,25,80),

sound(5,220),

repeat,

nl,

nl,

cursor(7,0),

write(" 1 - "),nl,

write(" 2 - "),nl,

write(" 3 - "),nl,

write(" 4 - " ),nl,

write(" =>"),

readint(X),

clearwindow,

X>0,X<=4,

view(X),

clearwindow,

X=4,!,

removewindow.

/* , */

working(4):- retractall(_,best),

retractall(_,best2),

all_contract,!.

/* */

working(5):-

makewindow(4,26,48," ",0,0,25,80),

sound(5,220),

repeat,

nl,

nl,

cursor(9,0),

write(" 1 - "),nl,

write(" 2 - "),nl,

write(" 3 - "),nl,

write(" =>"),

readint(X),

clearwindow,

X>0,X<=3,

interact(X),

clearwindow,

X=3,!,

removewindow.

/* */

working(6):-flag(1),retract(flag(1)),save_bd,!.

working(6).

working(_):-

makewindow(16,74,79," ",6,18,8,40),

nl,

write(" 0 6,"),nl,

write(" "),nl,nl,nl,

write(" "),

sound(20,494),

sound(30,392),

readchar(_),

removewindow.

/* */

view(1):-

makewindow(16,31,26,"p ",0,0,25,80),

write("|=================================================================|"),nl,

write("| Ƞ |"),nl,

write("|=================================================================|"),nl,

write("| | | | | . | | | |"),nl,

write("|No| ࠠ | || | - |||"),nl,

write("|=================================================================|"),nl,

(N,Firm,Tov,Proizv,Min,Kol,Price,Srok),

cursor(Z,_),

cursor(Z,1),write(N),

cursor(Z,3),write("",Firm),

cursor(Z,16),write("",Tov),

cursor(Z,36),write("",Proizv),

cursor(Z,50),write("",Min),

cursor(Z,59),write("",Kol),

cursor(Z,68),write("",Price),

cursor(Z,73),write("",Srok),

cursor(Z,0),write(""),

cursor(Z,76),write(""),

nl,

fail.

view(1):-

write("|==================================================================|"),

nl,

cursor(22,26),

write(" "),

readchar(_),

removewindow.

view(2):-

makewindow(16,31,26,"p ",0,0,25,80),

write("|=================================================================|"),nl,

write("| Ƞ |"),nl,

write("|=================================================================|"),nl,

write("| | | | | | | |"),nl,

write("|No| ࠠ | || |ࠠ ||"),nl,

write("|=================================================================|"),nl,

(N,Firm,Tov,Proizv,Part,Price,Srok),

cursor(Z,_),

cursor(Z,1),write(N),

cursor(Z,4),write("",Firm),

cursor(Z,20),write("",Tov),

cursor(Z,42),write("",Proizv),

cursor(Z,57),write("",Part),

cursor(Z,67),write("",Price),

cursor(Z,72),write("",Srok),

cursor(Z,0),write(""),

cursor(Z,76),write(""),

nl,

fail.

view(2):-

write("|==================================================================|"),

nl,

cursor(22,26),

write(" "),

readchar(_),

removewindow.

view(3):-

makewindow(16,31,26,"p ",0,0,25,80),

nl,nl,

view_sup(""),

cursor(21,26),

write(" "),nl,

cursor(22,26),

write(" "),

readchar(_),

removewindow,!.

view(_).

/* */

correct(1):-

makewindow(4,26,48," ",0,0,25,80),

nl,

write(" : "),readint(X),nl,

(X,Firm,Tov,Proizv,Min,Kol,Price,Srok),

clearwindow,nl,

write(" : "),write(X),nl,

write(" ࠠ : "),write(Firm),nl,

write(" 𠠠 : "),write(Tov),nl,

write(" : "),write(Proizv),nl,

write(" : "),write(Min),nl,

write(" 堠 : "),write(Kol),nl,

write(" ࠠ : "),write(Price),nl,

write(" 蠠 : "),write(Srok),nl,

nl,nl,nl,

write(" : "),readln(Firm1),

write(" ࠠ : "),readln(Tov1),

write(" : "),readln(Proizv1),

write(" : "),readInt(Min1),

write(" 堠 : "),readInt(Kol1),

write(" ࠠ : "),readreal(Price1),

write(" 蠠 : "),readInt(Srok1),nl,

X1=X,

retract((X,Firm,Tov,Proizv,Min,Kol,Price,Srok)),

assertz((X1,Firm1,Tov1,Proizv1,Min1,Kol1,Price1,Srok1)),

!,

ins_sup(Proizv1),

assert(flag(1)),

removewindow.

correct(2):-

makewindow(4,26,48," ",0,0,25,80),

nl,

write(" : "),readint(X),nl,

(X,Firm,Tov,Proizv,Part,Price,Srok),

clearwindow,nl,

write(" : "),write(X),nl,

write(" ࠠ : "),write(Firm),nl,

write(" 𠠠 : "),write(Tov),nl,

write(" : "),write(Proizv),nl,

write(" : "),write(Part),nl,

write(" ࠠ : "),write(Price),nl,

write(" 蠠 : "),write(Srok),nl,

nl,nl,nl,

write(" : "),readln(Firm1),

write(" ࠠ : "),readln(Tov1),

write(" : "),readln(Proizv1),

write(" : "),readInt(Part1),

write(" ࠠ : "),readreal(Price1),

write(" 蠠 : "),readInt(Srok1),nl,

X1=X,

retract((X,Firm,Tov,Proizv,Part,Price,Srok)),

assertz((X1,Firm1,Tov1,Proizv1,Part1,Price1,Srok1)),

ins_sup(Proizv1),

!,

assert(flag(1)),

removewindow.

correct(3):-

makewindow(9,26,48," ",0,0,25,80),

repeat,

nl,

write(" : "),readint(K),nl,

write(" : "),readln(F),

write(" ࠠ : "),readln(T),

write(" : "),readln(P),

write(" : "),readInt(M),

write(" 堠 : "),readInt(Kl),

write(" ࠠ : "),readreal(Pr),

write(" 蠠 : "),readInt(S),nl,

N1=K,

Firm=F,Tov=T,Proizv=P,

Min=M,Kol=Kl,

Price=Pr,Srok=S,

assertz((N1,Firm,Tov,Proizv,Min,Kol,Price,Srok)),

ins_sup(Proizv),

ask,!,

assert(flag(1)),

removewindow.

correct(4):-

makewindow(9,26,48," ",0,0,25,80),

repeat,

nl,

write(" : "),readint(K),nl,

write(" : "),readln(F),

write(" ࠠ : "),readln(T),

write(" : "),readln(P),

write(" : "),readInt(M),

write(" ࠠ : "),readreal(Pr),

write(" 蠠 : "),readInt(S),nl,

N1=K,

Firm=F,Tov=T,Proizv=P,

Part=M,

Price=Pr,Srok=S,

assertz((N1,Firm,Tov,Proizv,Part,Price,Srok)),

ins_sup(Proizv),

ask,!,

assert(flag(1)),

removewindow.

correct(_).

/* */

del(1):-

makewindow(5,48,107," ",0,0,25,80),

nl,

write(" : "),readint(X),nl,

(X,Firm,Tov,Proizv,Min,Kol,Price,Srok),

retract((X,Firm,Tov,Proizv,Min,Kol,Price,Srok)),

assert(flag(1)),

ok,

!,

removewindow.

del(1):-

error,

removewindow,!.

del(2):-

makewindow(5,48,107," ",0,0,25,80),

nl,

write(" : "),readint(X),nl,

(X,Firm,Tov,Proizv,Part,Price,Srok),

retract((X,Firm,Tov,Proizv,Part,Price,Srok)),

assert(flag(1)),

ok,

!,

removewindow.

del(2):-

error,

removewindow,!.

del(3):- makewindow(5,48,107," ",0,0,25,80),

nl,

write(" / : "),readln(S),nl,

del_sup(S),

assert(flag(1)),

ok,

!,

removewindow.

del(3):-

error,

removewindow,!.

del(_).

/* correct(3) correct(3) */

ask:-

makewindow(10,43,120,"",6,18,8,40),nl,nl,

write(" ? "),nl,nl,

write(" []/[]"),

readchar(Ch),

removewindow,

clearwindow,

Ch='',!.

/* */

save_bd:-

makewindow(17,74,79," ",6,18,8,40),nl,

write(" "),nl,

write(" ?"),nl,nl,

write(" []/[]"),

sound(20,494),

sound(30,392),

readchar(Ch),

removewindow,

clearwindow,

Ch='',!,sve.

save_bd.

/* */

sve:-save("kurs1.dat",),

save("kurs2.dat",),

save("web.dat",sup),!.

sve:-io_error,removewindow.

/* */

error:-

makewindow(15,74,79,"",6,18,8,40),

cursor(2,16),

write(""),nl,nl,

write(" "),

sound(70,294),

readchar(_),

removewindow,

!.

io_error:-

makewindow(16,74,79,"",6,18,8,40),

cursor(2,7),

write(" /"),nl,nl,

write(" "),

sound(70,294),

readchar(_),

removewindow.

/* */

ok:-

makewindow(17,27,90,"",6,18,8,40),

cursor(2,7),

write(" "),nl,nl,

write(" "),

readchar(_),

removewindow.

/* repeat */

repeat.

repeat:- repeat.

/* */

cmp_name(Proizv,Proizv).

cmp_name(Proizv,Proizv1):-

find_web(Proizv,Proizv1).

find_web(X,Y):-sup(X,Y).

find_web(X,Y):-sup(X,Z),find_web(Z,Y).

/* */

all_contract:-

(N,_,Tov,Proizv,Part,Price,Srok),

(N1,_,Tov,Proizv1,Min1,Kol1,Price1,Srok1),

cmp_name(Proizv,Proizv1),

Part>=Min1,Part<=Kol1,Price>=Price1,Srok>=Srok1,

assertz(contract(N,N1)),

assert(best(N,0,0,0)),

assert(best2(N,0,0,1000)),

fail.

all_contract:-print_contract.

/* */

print_contract:-

makewindow(16,31,26," ",0,0,25,80),

nl,nl,

(N,Firm,_,_,_,_,_),

checkcontr(N),

prn(N,Firm),

fail.

print_contract:-

retractall(_,contract),

removewindow.

prn(N,Firm):-

cursor(1,1),

write(" : ",Firm),

nl,

write("|=================================================================|"),nl,

write("| | | | | . | | | |"),nl,

write("|No| ࠠ | || | - |||"),nl,

write("|=================================================================|"),nl,

contract(N,N1),

(N1,Firm1,Tov1,Proizv1,Min1,Kol1,Price1,Srok1),

cursor(Z,_),

cursor(Z,1),write(N1),

cursor(Z,3),write("",Firm1),

cursor(Z,16),write("",Tov1),

cursor(Z,36),write("",Proizv1),

cursor(Z,50),write("",Min1),

cursor(Z,59),write("",Kol1),

cursor(Z,68),write("",Price1),

cursor(Z,73),write("",Srok1),

cursor(Z,0),write(""),

cursor(Z,76),write(""),

nl,

(N,_,_,_,Part,_,_),

retract(contract(N,N1)),

Cs=Part*Price1,

form_best(N,N1,Cs,Srok1),

form_best2(N),

fail.

prn(N,_):-

write("|===================================================================|"),

nl,

best2(N,Np,_,_),

(Np,Firm,_,_,_,_,_,_),nl,

write(" "),nl,

write(" : ",Firm),nl,

cursor(22,26),

write(" "),

readchar(_),

clearwindow,!.

/* , */

checkcontr(N):-contract(N,_).

/* */

form_best(N,Np,S,Srok):- Na=N,

best(Na,Np1,S1,Srok1),S=S1,

assertz(best(Na,Np,S,Srok)),!.

form_best(N,Np,S,Srok):- Na=N,

best(Na,Np1,S1,Srok1),S>S1,fb1(Na,Np,S,Srok),

assertz(best(Na,Np,S,Srok)),!.

form_best(_,_,_,_).

fb1(N,_,_,_):-

retract(best(N,_,_,_)),fail.

fb1(_,_,_,_).

form_best2(N):-

best(N,Np,S,Srok),f_b2(N,Np,S,Srok),fail.

form_best2(_).

f_b2(N,Np,S,Srok):- Na=N,

best2(Na,Np1,_,Srok1),Srok1>Srok,

fb2(Na,Np,S,Srok),

assertz(best2(Na,Np,S,Srok)),!.

f_b2(_,_,_,_).

fb2(N,_,_,_):- retract(best2(N,_,_,_)),fail.

fb2(_,_,_,_).

/* */

interact(1):-

makewindow(9,26,48," ",0,0,25,80),

nl,

write(" : "),readln(F),

write(" ࠠ : "),readln(T),

write(" : "),readln(P),

write(" : "),readInt(M),

write(" ࠠ : "),readreal(Pr),

write(" 蠠 : "),readInt(S),nl,

N=0,

Firm=F,Tov=T,Proizv=P,

Part=M,

Price=Pr,Srok=S,

assertz((N,Firm,Tov,Proizv,Part,Price,Srok)),

removewindow,

(N1,_,Tov,Proizv1,Min1,Kol1,Price1,Srok1),

cmp_name(Proizv,Proizv1),

Part>=Min1,Part<=Kol1,Price>=Price1,Srok>=Srok1,

assert(flag(2)),

assertz(contract(N,N1)),

assert(best(N,0,0,0)),

fail.

interact(1):-flag(2),print_contract,

retract((0,Firm,Tov,Proizv,Part,Price,Srok)),

retract(flag(2)),!.

interact(1):-

warning(N),

(0,Firm,Tov,Proizv,Part,Price,Srok),

assertz((N,Firm,Tov,Proizv,Part,Price,Srok)),

ins_sup(Proizv),

retract((0,Firm,Tov,Proizv,Part,Price,Srok)),

assert(flag(1)),

!.

interact(1):- retract((0,Firm,Tov,Proizv,Part,Price,Srok)),!.

interact(2):-

makewindow(9,26,48," ",0,0,25,80),

nl,

write(" : "),readln(F),

write(" ࠠ : "),readln(T),

write(" : "),readln(P),

write(" : "),readInt(M),

write(" : "),readInt(I),

write(" ࠠ : "),readreal(Pr),

write(" 蠠 : "),readInt(S),nl,

N=0,

Firm=F,Tov=T,Proizv=P,Min=M,

Kol=I,

Price=Pr,Srok=S,

assertz((N,Firm,Tov,Proizv,Min,Kol,Price,Srok)),

removewindow,

(N1,_,Tov,Proizv1,Part1,Price1,Srok1),

cmp_name(Proizv1,Proizv),

Part1>=Min,Part1<=Kol,Price1>=Price,Srok1>=Srok,

assert(flag(2)),

assertz(contract(N1,N)),

assert(best(N1,0,0,0)),

fail.

interact(2):-flag(2),print_contract,

retract((0,Firm,Tov,Proizv,Min,Kol,Price,Srok)),

retract(flag(2)),!.

interact(2):-

warning(N),

(0,Firm,Tov,Proizv,Min,Kol,Price,Srok),

assertz((N,Firm,Tov,Proizv,Min,Kol,Price,Srok)),

ins_sup(Proizv),

retract((0,Firm,Tov,Proizv,Min,Kol,Price,Srok)),

assert(flag(1)),

!.

interact(2):- retract((0,Firm,Tov,Proizv,Min,Kol,Price,Srok)),!.

interact(_).

/* */

warning(N):-makewindow(7,49,113,"",5,10,12,60),

sound(5,220),nl,nl,

write(" "),nl,

write(" "),nl,

write(" ?"),nl,nl,

write(" []/[]"),nl,

readchar(Ch),

removewindow,

Ch='',

write(" : "),readInt(N),nl,

!.

/* */

%

del_sup(S):- sup(S,X), del_sup(X),fail.

%

del_sup(S):- sup(_,S), retract(sup(_,S)),fail.

del_sup(_).

/* */

/* */

ins_sup(S):-sup(_,S),!.

ins_sup(S):-sup("",S),!.

ins_sup(S):-

write(" _ ",S,"_ :"),

readln(M),nl,

assertz(sup(M,S)),assert(flag(1)),ins_sup(M),!.

/* */

view_sup(S):-

sup(S,M),write(S," -> ",M),write("; "),

view_sup(M),nl,fail.

view_sup(_):- readchar(_).


1.     

2.     

3.     

4.     

堠 " " 󠠠 . . -1-95. : . . 1. 1.1 1.2 2. 2.1

 

 

 

! , , , .
. , :