,,,
:
:
IV-3
..
:
... .
..
2004
, , , , . , , . . , .
, , . :
-, , ;
-, . .
, . .. , , .
( ) . , .
: , . , , ( ), .
, : , . . , . , , . . , , .
:
( );
( ).
. . :
- , , , , ;
;
.
, , .
. , , , , , , , , , .
: ; , ; , -, , 50% ; .
/ . , .. .
, - , , , ..
, ( : , ). , , () .
:
1.
2. ( )
3.
4. -
5. ..
, , , .. , , , .
. , .. , - .
, , , .. , , ..
- , .. . : , , (, ). - , , ..
, , .. , , .
-. . , . .. . , () .
N .
Simplex 3.
QueryStock1 - 1
QueryStock2 - 2
QueryStock3 - 3
FirmStock -
ff - 1
ff2 - 2
ff3 - 3
balances [1..3] -
LOST_clients [1..3] - ,
criterian [1..9] [1..100] -
demand [1..3] - ,
EQUIPOISE - : EQUIPOISE = TRUE
, , Buyer , , .
# -
(tmp^):=fillClients(ARRAY criterian,100);
#include <iostream>
#include <stdlib.h>
#include <math.h>
#include <stdio.h>
#include "sys_struct.h"
#include "sys_extern.h"
#include "rts_func.h"
#include "c_macros.h"
using namespace std;
//
real exprasp(real m)
{
real r;
real exprasp_result;
do {
r=rand()%100;
r=r/100;
} while (!(r!=0));
exprasp_result=-m*log(r);
return exprasp_result;
}
//
real nrasp(real m,real stddev)
{
real r1,r2,radsqr;
real nrasp_result;
do {
r1=rand()%100;
r2=rand()%100;
r1=2*r1/100-1;
r2=2*r2/100-1;
radsqr=r1*r1+r2*r2;
} while (!((radsqr>0) && (radsqr<1)));
nrasp_result=r1*sqrt(-2*log(radsqr)/radsqr)*stddev+m;
return nrasp_result;
}
void fillClients(array a,integ r,integ *tmp)
{
int i,j;
srand(1);
for (j=1;j<=r;j++) {
InPara2(a,real,1,j) = rand()%200 + 10;
InPara2(a,real,2,j) = rand()%40 + 30;
InPara2(a,real,3,j) = rand()%2;
InPara2(a,real,4,j) = nrasp(25,5);
InPara2(a,real,5,j) = exprasp(50);
InPara2(a,real,6,j) = rand()&2+1;
InPara2(a,real,7,j) = nrasp(2.5,0.5);
InPara2(a,real,8,j) = exprasp(200);
InPara2(a,real,9,j) = nrasp(0.5,0.5);
}
}
BASIC COMPONENT buyer
MOBILE SUBCOMPONENT OF CLASS query
LOCAL DEFINITIONS
C_PROCEDURE fillClients (ARRAY[n][s] REAL,INTEGER --> INTEGER)
DECLARATION OF ELEMENTS
STATE VARIABLES
ARRAY[9][100] criterion (REAL):=0,
TNext(INTEGER):=0,
tmp(INTEGER):=0
DYNAMIC BEHAVIOUR
ON START DO
(tmp^):=fillClients(ARRAY criterion,100);
DISPLAY(" BUYERS ADDED.\n");
END
WHENEVER T>=TNext DO
IF TNext>47 DO
(tmp^):=fillClients(ARRAY criterion,100);
DISPLAY(" NEW BUYERS ADDED.\n");
END
TNext^:=TNext+1;
END
END OF buyer
. : Firm, Firm2, Firm3, .
BASIC COMPONENT Firm
MOBILE SUBCOMPONENT OF CLASS query
DECLARATION OF SUBFUNCTION
strategy(INTEGER:past_buy2,LOCATION FOR query:Stock,
ARRAY [l] LOGICAL:LOST_c,ARRAY [l] REAL:bal,INTEGER:ff1,
INTEGER:I,INTEGER:g,ARRAY[n]REAL:param1,INTEGER:cash,
ARRAY[l]REAL:dem-->ARRAY [n] REAL,INTEGER),
form(ARRAY [n] REAL:PP-->ARRAY [n] REAL)
DECLARATION OF ELEMENTS
STATE VARIABLES
ARRAY[2] past_buyers (INTEGER):=0, #
ARRAY[9]parameters1(REAL):=0, #
ARRAY[9]p1(REAL):=0,
TNext(INTEGER):=0,
count(INTEGER):=1,
past_b(INTEGER):=0,
past_b2(INTEGER):=0,
invest(INTEGER):=0 #
SENSOR VARIABLES
ff(INTEGER), #
ARRAY [3]balances(REAL), #
ARRAY [3]LOST_cl(LOGICAL), #
ARRAY [9]parameters2(REAL),
ARRAY [9]parameters3(REAL),
firm_leader(INTEGER),
g(INTEGER),
ARRAY [3]demand(REAL) #
RANDOM VARIABLES
PRI(REAL):UNIFORM(LowLimit:=200,UpLimit:=400), #
QUAN(INTEGER):IUNIFORM(LowLimit:=100,UpLimit:=200), #
SAL(REAL):UNIFORM(LowLimit:=0,UpLimit:=1), #
ADV(REAL):UNIFORM(LowLimit:=15,UpLimit:=35), #
QUAL(REAL):EXPO(Mean:=50), #
ASSORT(INTEGER):IUNIFORM(LowLimit:=1,UpLimit:=3), #
TRU(INTEGER):IUNIFORM(LowLimit:=2,UpLimit:=5), #
REMOT(REAL):EXPO(Mean:=150), #
DELIV(INTEGER):IUNIFORM(LowLimit:=1,UpLimit:=3), #
Inv(INTEGER):IUNIFORM(LowLimit:=1,UpLimit:=4) #
TRANSITIONS INDICATORS
print,
ffm,
ffm2,
ffm3
LOCATION
QueryStock1(query):=0 query, # ,
F1Stock(query):=0 query # , -
SENSOR LOCATION
FStock(query)
DYNAMIC BEHAVIOUR
ON START DO
parameters1[1]^:=PRI;
parameters1[2]^:=QUAN;
parameters1[4]^:=ADV;
parameters1[5]^:=QUAL;
parameters1[6]^:=1;
parameters1[7]^:=TRU;
parameters1[8]^:=REMOT;
parameters1[9]^:=DELIV;
SIGNAL ffm;
END
WHENEVER T>=TNext
DO IF (NUMBER(FStock)<>0) DO
SIGNAL ffm3;
(ARRAY p1^,past_b^):=strategy(past_b2,LOCATION FStock,ARRAY LOST_cl,
ARRAY balances,ff,1,g,ARRAY parameters1,invest,ARRAY demand);
SIGNAL ffm2;
END
SIGNAL ffm;
TNext^:=TNext+1;
END
ON ffm DO
QueryStock1^: ADD 1 NEW query
CHANGING
(ARRAY QB^):=form(ARRAY parameters1);
END
END
ON ffm2 DO
(ARRAY parameters1^):=form(ARRAY p1);
END
ON ffm3 DO
past_b2^:=past_b;
invest^:=Inv;
END
END OF Firm
( Market), . , .
FUNCTION FChoice
MOBILE SUBCOMPONENT OF CLASS query
DECLARATION OF ELEMENTS
INPUT PARAMETERS
FStock(LOCATION FOR query),
ARRAY[n][s]CRITER(REAL), #
ARRAY [l] Dummy(REAL),
g(INTEGER)
OUTPUT PARAMETERS
ARRAY[l]balance(REAL), #
f(INTEGER), # 1
f2(INTEGER), # 2
f3(INTEGER), # 3
ARRAY[n][l]copy_param(REAL),
ARRAY[l]LOST_clients(LOGICAL),
leader(INTEGER),
ARRAY [l]dem(REAL)
LOCAL VARIABLES
ss(INTEGER):=100,
k(REAL):=0, #
rem(REAL):=0,
maxim(REAL):=0,
imaxim(INTEGER):=0,
JMAX(INTEGER):=0,
ARRAY[l][s]QuBu(REAL):=0, #
ARRAY[l][s]QuanBuy(INTEGER), #
ARRAY [l]clients(INTEGER),
max_cl(INTEGER)
BEGIN
FOR W FROM 1 TO 9
REPEAT
FOR I FROM 1 TO g
REPEAT
copy_param[W][I]:=FStock:query[I].QB[W];
balance[I]:=FStock:query[I].QB[2];
END_LOOP
END_LOOP
#
FOR J FROM 1 TO g
REPEAT
FOR I FROM 1 TO ss
REPEAT
k:=0;
FOR R FROM 1 TO 9
REPEAT
IF R<>2 DO
# 20% .
IF (FStock:query[J].QB[R]<=CRITER[R][I]+CRITER[R][I]*0.2) AND
(FStock:query[J].QB[R]>=CRITER[R][I]-CRITER[R][I]*0.2)
DO
k:=k+1/9;#
END
END
END_LOOP
QuBu[J][I]:=k;
END_LOOP
END_LOOP
#
FOR I FROM 1 TO ss
REPEAT
# , , .
IF (QuBu[1][I]=QuBu[2][I]) AND (QuBu[1][I]=QuBu[3][I])
AND (QuBu[1][I]<>0)
DO LOOP <ch>
FOR J FROM 1 TO g
REPEAT
#
IF balance[J]>=CRITER[2][I] DO
balance[J]:=balance[J]-CRITER[2][I];
QuanBuy[J][I]:=1;
LOST_clients[J]:=FALSE;
EXIT <ch>;
END
END_LOOP <ch>
END
ELSIF (QuBu[1][I]<>QuBu[2][I]) OR (QuBu[1][I]<>QuBu[3][I])
DO
maxim:=0;
FOR J FROM 1 TO g
REPEAT
IF QuBu[J][I]>maxim DO
maxim:=QuBu[J][I];
imaxim:=J;
JMAX:=I;
END
END_LOOP
IF balance[imaxim]>=CRITER[2][I] DO
balance[imaxim]:=balance[imaxim]-CRITER[2][I];
QuanBuy[imaxim][JMAX]:=1;
LOST_clients[imaxim]:=FALSE;
END
ELSIF balance[imaxim]<CRITER[2][I] DO
DISPLAY(" %d !!!\n",imaxim);
LOST_clients[imaxim]:=TRUE;
dem[imaxim]:=dem[imaxim]+CRITER[2][I];
END
END
END_LOOP
FOR J FROM 1 TO ss
REPEAT
f := f + QuanBuy[1][J];# 1
END_LOOP
FOR J FROM 1 TO ss
REPEAT
f2 := f2 + QuanBuy[2][J];# 2
END_LOOP
FOR J FROM 1 TO ss
REPEAT
f3 := f3 + QuanBuy[3][J];# 3
END_LOOP
clients[1]:=f;
clients[2]:=f2;
clients[3]:=f3;
# -
max_cl:=0;
FOR I FROM 1 TO g
REPEAT
IF clients[I]>max_cl
DO
max_cl:=clients[I];
leader:=I;
END
END_LOOP
RETURN
END OF FChoice
. .
HIGH LEVEL COMPONENT Market_HIGH
SUBCOMPONENTS
Firm,
Firm2,
Firm3,
buyer,
Market
COMPONENT CONNECTION
Firm.QueryStock1-->Market.QStock1;
Firm2.QueryStock2-->Market.QStock2;
Firm3.QueryStock3-->Market.QStock3;
buyer.criterion{i OF 1..9}{j OF 1..100}-->Market.criterion[i][j];
Firm.parameters1{i OF 1..9}-->Firm3.parameters1[i]; 1 3-
Firm2.parameters2{i OF 1..9}-->Firm3.parameters2[i]; 2 3-
Market.g-->Firm.g;
Market.g-->Firm2.g;
Market.g-->Firm3.g;
#
Market.ff-->Firm.ff;
Market.ff2-->Firm2.ff2;
Market.ff3-->Firm3.ff3;
#
Market.balances[1]-->Firm.balances[1];
Market.balances[2]-->Firm2.balances[2];
Market.balances[3]-->Firm3.balances[3];
#
Market.LOST_clients[1]-->Firm.LOST_cl[1];
Market.LOST_clients[2]-->Firm2.LOST_cl[2];
Market.LOST_clients[3]-->Firm3.LOST_cl[3];
# -
Market.firm_leader-->Firm.firm_leader;
Market.firm_leader-->Firm2.firm_leader;
Market.firm_leader-->Firm3.firm_leader;
# ,
Market.demand[1]-->Firm.demand[1];
Market.demand[2]-->Firm2.demand[2];
Market.demand[3]-->Firm3.demand[3];
Market.EQUIPOISE-->Firm3.EQUIPOISE;
END OF Market_HIGH
( ), .
1. , . , - .
2 , .
3. 1/3 , 2%.
, , ( 4). , 10 . , ( cash). cash = 1, , . cash . cash = 2 , . cash = 3 . cash = 4 .
.
FUNCTION strategy
MOBILE SUBCOMPONENT OF CLASS query
LOCAL DEFINITIONS
DECLARATION OF SUBFUNCTION
form(ARRAY [n]REAL:PP-->ARRAY[n]REAL)
DECLARATION OF ELEMENTS
INPUT PARAMETERS
past_buy2(INTEGER), #j=2 l=3 n=9
Stock(LOCATION FOR query),
ARRAY[l] LOST_c(LOGICAL),
ARRAY[l] bal(REAL),
ff1(INTEGER),
I(INTEGER), #
g(INTEGER),
ARRAY [n]param1(REAL),
cash(INTEGER),
ARRAY [l]dem(REAL)
OUTPUT PARAMETERS
ARRAY[n] par(REAL),
past_buy(INTEGER)
LOCAL VARIABLES
average_price(REAL):=0,
cash1(INTEGER):=0
BEGIN
(ARRAY par):=form(ARRAY param1);
# 1
FOR J FROM 1 TO g
REPEAT
average_price:=average_price+Stock:query[J].QB[1];
END_LOOP
average_price:=average_price/g;
DISPLAY(" %3.2f\n",average_price);
IF par[1]>average_price
DO
par[1]:=par[1]-par[1]*0.01;
END
ELSIF par[1]<average_price
DO
par[1]:=par[1]+par[1]*0.01;
END
# 2
IF LOST_c[I]
DO
par[2]:=par[2]+dem[I];
END
ELSIF LOST_c[I]=FALSE
DO
par[2]:=par[2];
END
# 3
IF bal[I]>par[2]/3
DO
par[3]:=par[3]+1;
par[2]:=par[2]-par[2]*0.02;
END
# 4
IF ff1>past_buy2
DO
par[2]:=par[2]+10;
END
ELSIF ff1<=past_buy2
DO
IF cash=1
DO
par[6]:=par[6]+1;
END
ELSIF cash=2
DO
par[5]:=par[5]+5;
IF (par[5]>230) AND (par[7]<6)
DO
par[7]:=par[7]+1;
END
END
ELSIF cash=3
DO
par[4]:=par[4]+5;
END
ELSIF (cash=4) AND (par[9]<3)
DO
par[9]:=par[9]+1;
END
END
past_buy:=ff1;
RETURN
END OF strategy
, , . (. 1, 2).
. 1 -
. 2 -
. (Firm), (Firm2), (Firm3). , . , , .
. 3 , .
. 3 -
. , .
. , , , .
. 4 - 1
. 5 - 2
. 6 - 3
:
Copyright (c) 2024 Stud-Baza.ru , , , .