,,,
« »
«
»
..
30.05.05
11. 230105. 51. 0247
..
30.05.05
. ..
30.05.05
1.
2.
3.
4.
6.
7.
8.
++ : saneek93@mail.ru
1.
, , () . . . . .
- . – . , , . – , , , , , . .
(), (). . .
, () (). . , . – , . – , . , . , . , .
.
. .
, , , , , . . , . ( , . ., . . ) ( ).
:
. . , «
: , , , . , . , , . . ; ; . , , ».
, . - . . - , , . . .
. . C++, , , .
2.
– , , , , , , , .. - , , () , .
- - . – .
.
, . , .., . .
1). .
, , , , .
2). – .
. , , . .
, .
– () . , .
, , , . , , .
. N, , , .
3.
. . , XIX – XX ., .
, . , , , , , , . . , .
( 1):
. 1.
, :
, :
.
( ) - , . - .
– , , , . , .
– , , .
, . .
– .
– , .
:
1. .
:
: ; .
: ; .
2. , . , , .
: ; ; .
: ; ; .
3. , . .
: ; ; .
: ; ; .
4. ( 1 – 3). .
: ; ; ; .
: ( )
5. . . . .
4.
. -
0,2 . , ,
80% , -
. 20%
,
. -
, 4
()
. ,
— 72 .
-
, -
20% .
18 ( ), .
( ) 3 .
6 (312 )
:
: — 72 , -
. -
- , ,
, ().
1 . , -
0,2 , -
, 1,4. , —
, -
1,4
, . 1,4
33,6 , 1/33,6 ≈ 0,03 —
.
312 • 7 • 24 = 52 416 — -
. (4
3 ) (, 28 21). (Supermarket) , -
, -
, 4 .
, , -
, : rand( )%672+l; -(rand( )%28+l)*24.
. , -
rand( ) , -
0 32 767.
, rand( )%K -
, 32 768 .
, — .
,
, . , = 3 ,
= 32 767 0 .
-
, 24.
. , -
: « ?» —
, .
-
, -
. , — -
.
, , ,
.
,
, (Client)
. , , , -
, . -
, , , . -
, ,
,
, : . , , , -
-
.
, —
, , -
. , -
(SuperMarket).
:
:
, , : - , . ,
. ,
,
.
Client ,
,
SuperMarket. () Client .
? , ,
.
, . , -
, -
- .
: ,
, , -
, ; «» , ,
, . ,
, ,
.
«»
main( ).
. -
,
. ,
.
, -
, ,
. ,
:
entered-rejected-satisfied-q_length+l.
entered — ;
rejected — ;
satisfied — ;
q_length — .
, :
, . , -
, :
. -
(, -q_length),
. -
. SuperMarket -
q_extra,
«» . Supertterket: :complete(),
, -
, -
:
c=entered-rejected-satisfied-q_length*q_extra+l
1/ -
.
( ) C++ , .
1.h.
#include
#include
#include
#include
using namespace std;
#include "random.h"
#include "List.h"
FILE *sojourn; //
//
FILE *que; // ;
//
long int entered=0L; //
long int rejected=0L; // ,
long int satisfied=0L; // ,
int num_orders=0; //
float soj_ave=0; //
float que_ave=0; //
long int total; // (
//)
// Client
class Client
{
long int id; //
int hours; //,
public:
friend class SuperMarket;
Client() //-
{
//, , ,
// ,
id=entered-rejected-satisfied+1;
hours=0;
}
void Print();
long int getId();
int getTime();
};
//
void Client::Print()
{
//168 -
printf("id=%ldn %d n", id, hours/168);
}
//
long int Client::getId()
{
return(id);
}
//
int Client::getTime()
{
return(hours);
}
//
class SuperMarket
{
int to_arrival; //
int to_order; //
int order; //
int to_check; //
int q_length; //
int exist; //
ListNode *queue; //
//
const static int mu=3;
const static int checking=28;
const static int ordering=21;
const static int level1=18;
const static int level2=72;
const static int percentage=80;
public:
SuperMarket(int i);
void run();
void arrival();
void complete();
void check();
void Print();
int getLength();
int q_extra; //
};
//-. -
SuperMarket::SuperMarket(int i)
{
q_length=0;
q_extra=0;
queue=NULL;
to_arrival=(int)(get_exp((float)mu/100));
//""
// , .
// ,
// .
//1-exp(-0.03 * 0.5) = 0,015.
if (to_arrival==0) to_arrival=1;
to_order=-1;
order=0;
exist=i;
//
to_check=(rand()%checking+1)*24;
}
int SuperMarket::getLength()
{
return(q_length);
}
void SuperMarket::Print()
{
printf(" %d n", to_arrival);
if (to_order>0) {
printf(" %d , %d n", to_order/24, order);
}
else
printf(" n");
printf(" %d n", to_check/24);
printf(" %d n", q_length);
printf(" %d n", exist);
}
//
void SuperMarket::arrival()
{
//int i;
Client *p=NULL;
//
to_arrival=(int)(get_exp((float)mu/100));
if (to_arrival==0) to_arrival=1;
entered++; //
if (exist>0) //
{
exist--; //
satisfied++; //
//
}
else //
{
if (rand()%100
{
rejected++; //
return;
}
// Client
p=new Client();
ListNode *ptr=new ListNode(p,NULL);
// .
if (q_length==0) queue=ptr;
//
else ListAdd(queue,ptr);
q_length++; //
}
return;
}
//
void SuperMarket::complete()
{
int mi, i, b, c;
to_order=-1;
exist+=order;
order=0;
if (q_length==0) return;
//,
if (exist
for(i=0;i
{
// ,
b=queue->Data()->getTime();
// ( )
fprintf(sojourn,"%.2fn", ((float)b)/24);
//,
// . .
c=entered-rejected-satisfied-q_length+q_extra+1;
soj_ave=soj_ave*(1-1.0/c)+(float)b/c; //
//
//
ListNode *ptr=queue;
queue=queue->Next();
delete ptr;
q_length--; //
exist--; //
}
}
//
void SuperMarket::check()
{
int a;
to_check=checking*24;
//
a=exist+order-q_length;
if (a>=level1) return; //
//
to_order=ordering*24;
//
order=level2-a;
num_orders++; //
}
//-
void SuperMarket::run()
{
//int i;
//float a;
ListNode *ptr;
to_arrival--;
if (to_arrival==0) arrival();
if (to_order>0) to_order--;
if (to_order==0) complete();
to_check--;
if (to_check==0) check();
// , //
if (queue!=NULL)
{
ptr=queue;
while(ptr!=NULL)
{
((ptr->Data())->hours)++;
ptr=ptr->Next();
}
}
//
if (total%7==0) fprintf(que,"%dn", q_length);
//
que_ave=que_ave*(1-1.0/(total+1))+((float)q_length)/(total+1);
return;
}
random.h
#include
#include
#include
float get_exp(float mu) // ,
//
{
int r_num; float root, right;
r_num=rand(); /*
/*/
right=((float)r_num)/(RAND_MAX+1); /* (0;1)*/
root=-log(1-right)/mu; /*
/*/
return(root);
}
int get_uniform(int a, int b)
{ // a+b
int x, y;
x=rand()%(b+1);
y=rand()%2;
if (y==0) return(a-x);
return(a+x);
}
float get_triangle(float A, float B, float C)
{
int r_num; float root, right;
r_num=rand(); //
//
right=((float)r_num)/(RAND_MAX+1); // (0;1).
// RAND_MAX=32767 (215-1) cstdlib
if (right<(C-A)/(B-A)) root=A+sqrt(right*(B-A)*(C-A));
else root=B-sqrt((1-right)*(B-A)*(B-C));
return(root);
}
float get_pareto(float A, float B)
{
int r_num; float root, right;
r_num=rand(); /* */
right=(float)r_num/RAND_MAX+1; /* (0;1)*/
root=A/(pow(1-right, (float)1.0/B)); /* */
return(root);
}
List.h
template // «»
//
//c
class ListNode {
private:
ListNode *next; //
Type *data; //
public:
ListNode(Type *d, ListNode *n); //
~ListNode(); //
Type *Data(); //
ListNode *Next(); //
//
void PutNext(ListNode *n); //
//
void Print(); //
};
template
ListNode::ListNode(Type *d, ListNode *n) : next(n), data(d)
{
}
template
ListNode::~ListNode()
{
delete data;
}
template
Type *ListNode::Data()
{
return data;
}
template
ListNode *ListNode::Next()
{
return next;
}
template
void ListNode::PutNext(ListNode *n)
{
next=n;
}
template
void ListNode::Print()
{
data->Print(); // Print()
//
}
// - , -,
// ,
template
void ListAdd(ListNode *head, ListNode *li)
// li head
{
ListNode *old, *v;
//
for (v=head; v!=NULL; v=v->Next())
old=v;
old->PutNext(li); //
}
template
ListNode *ListDelete(ListNode *head, ListNode *li)
// li head
//
{
//int j;
ListNode *old, *o1;
if (li==head) //
//
{
o1=head->Next();
delete li;
return o1;
}
// .
for (ListNode* v=head; v!=li; v=v->Next())
//
old=v;
o1=li->Next();
old->PutNext(o1);
// «»
//
delete li;
return head;
}
// head
template
void ListPrint(ListNode *head)
{
for (ListNode* v=head; v!=NULL; v=v->Next())
v->Print(); // head
}
template
int ListCount(ListNode *head)
{
int i; i=0;
for (ListNode* v=head; v!=NULL; v=v->Next())
{
v->Print();
i++;
}
return i;
}
main()
#include "stdafx.h"
#include "iostream"
#include "4.h"
#define N 52416 //
using namespace std;
int main(){
//
que=fopen("que1", "wt");
sojourn=fopen("sojourn", "wt");
//
srand((unsigned)time(0));
SuperMarket s(72);
//"" . 8760 -
for(total=0L;total<8760;total++) {
s.run();
}
fclose(que);
fclose(sojourn);
//
que=fopen("que1", "wt");
sojourn=fopen("sojourn", "wt");
entered=0L;
rejected=0L;
satisfied=0L;
num_orders=0;
soj_ave=0;
que_ave=0;
// q_extra //
s.q_extra=s.getLength();
//
for(total=0L;total
s.run();
}
fclose(sojourn);
fclose(que);
setlocale(LC_ALL, "Russian");
//
cout << " " << entered << endl;
cout << " " << ((float)rejected)/entered << endl;
cout << " " << ((float)satisfied)/entered << endl;
cout << " " << num_orders << endl;
cout << " " << soj_ave/24 << " " << endl;
cout << " " << que_ave << endl;
_gettch();
6.
6 :
. 2.
. , , ,
72 . -
,
( — ) -
( 72).
: , ,
.
. 3-5 , . ,
, -
.
. 3.
. 4.
. 5.
,
, , -
, , , .
, «» ,
18. , T
17. ,
( - 1)- , , ,
, , , -
. ,
, ,
, .
, , ,
0,2, 62 , -
92 122 ( -
— 28 ).
, , . 5, -
, 5.
, . 6-8, . ,
« » ( -
), .
. 6.
. 7.
. 8.
.
,
,
. «», -
,
1, 2, 3,
:
F(P) = 1 • Lost + 2 • Orders + 3 • T
F(L) = 1 • Lose + 2 • Orders + 3 • T,
— ;
Lost — ;
Orders — ;
T — ;
L — .
, , ,
. , 1 = 15,
2 = 1, = 0,35.
. 9.
, , — -
.
, . 9,
= 59, — 26,3 —
( = 36), 26,6. ,
- , 36 .
,
( = 28 ). . 10, -
L = 8 25,8,
. , : -
18 — .
, -
8.
. 9.
,
.
, -
.
7.
:
8.
http://www.znaytovar.ru/s/Sistemy_upravleniya_zapasami.html
4. ., . . – : , 2004. – 848
5. .. « », .: , 1999., 576 .
., «» 2001 .
7. .. : . . : . –.: , 2003. -622 .
8. .. . –.: , 2000. -200 .
« » « » .. 30.05.05 11. 230105. 5
Copyright (c) 2025 Stud-Baza.ru , , , .