M
marsultanius
Guest
#include normal.h
#include cstdio
#include cstdlib
#include ctime
#include cmath
using namespace std;
int entered = 0;
int completed = 0;
int rounds = 0;
int timeout1 = 0;
int timeout2 = 0;
int T = 1;
long int rOU = 0;
FILE oilVolume;
FILE fullTime;
FILE waitTime;
FILE nQueue;
float vol_ave = 0;
float fpath_ave = 0;
float queN_ave = 0;
float wait_ave = 0;
float serve_ave;
long int total;
class Tanker {
private
static const float storage;
static const float full_ave;
static const float full_offset;
static const float empty_ave;
static const float empty_offset;
static const float load_ave;
static const float load_offset;
static const float min_storage;
int id;
void dok;
int to_fullPath;
int to_emptyPath;
int to_loading;
int cur_storage;
int cur_wait;
int cur_round;
int cur_serve;
public
friend class Dok;
Tanker(int i);
void putDok(Dok d);
void LoadArrival();
void LoadComplete();
void DokArrival();
void DokComplete();
void run();
};
const float Tankerfull_ave = 5;
const float Tankerstorage = 400;
const float Tankerempty_ave = 4;
const float Tankerfull_offset = 1.5;
const float Tankerempty_offset = 1;
const float Tankerload_ave = 72;
const float Tankerload_offset = 2.4;
const float Tankermin_storage = 3;
class OilHouse {
static const float capacity;
static const float OU_speed;
static const float less_radio;
static const float almost_empty;
static const float more_ratio;
void dok;
float oilLevel;
int check;
public
friend class Dok;
OilHouse();
void putDok(Dok d);
void run();
};
const float OilHousecapacity = 1000;
const float OilHouseOU_speed = 1.45;
const float OilHouseless_radio = 0.8;
const float OilHousemore_ratio = 10;
const float OilHousealmost_empty = 5;
class Dok {
static const float Tanker_speed;
void House;
Tanker serving;
Tanker queue;
int to_break;
int to_work;
int working;
public
Dok();
~Dok();
void putHouse(OilHouse p);
int QLength();
void Arrival(Tanker ptr);
void Complete();
void Night();
void Morning();
void resumeWork();
void stopWork();
void run();
};
const float DokTanker_speed = 2;
TankerTanker(int i)
{
id = i;
to_fullPath = -1;
to_emptyPath = -1;
cur_storage = 0;
to_loading =get_uniform((int)(load_ave 10),(int)(load_offset 10)) 10;
dok = NULL;
cur_wait = -1;
cur_round = 0;
cur_serve = -1;
}
void TankerLoadArrival()
{
to_emptyPath = -1;
to_loading = get_uniform((int)(load_ave 10),(int)(load_offset 10)) 10;
rounds++;
fpath_ave = fpath_ave (1 - 1.0 rounds) + ((float)cur_round) rounds;
fprintf(fullTime, %.3fn, ((float)cur_round) 24);
cur_round = 0;
}
void TankerLoadComplete()
{
to_loading = -1;
cur_storage = storage;
to_fullPath = (int)(get_normal(full_ave, full_offset, 0.01) 24);
if (to_fullPath = 0)to_fullPath = 1;
}
void TankerDokArrival() {
to_fullPath = -1;
((Dok)dok)-Arrival(this);
}
void TankerDokComplete()
{
to_emptyPath = (int)(get_normal(empty_ave, empty_offset, 0.01) 24);
if (to_emptyPath = 0)to_emptyPath = 1;
serve_ave = serve_ave (1 - 1.0 completed) + ((float)cur_serve) completed;
fprintf(fullTime, %.3fn, ((float)cur_round) 24);
cur_serve = -1;
}
void Tankerrun()
{
if (to_fullPath 0)to_fullPath--;
if (to_fullPath == 0)DokArrival();
if (to_emptyPath 0)to_emptyPath--;
if (to_emptyPath == 0)LoadArrival();
if (to_loading 0)to_loading--;
if (to_loading == 0)LoadComplete();
}
void Tankerrun()
{
cur_round++;
if (to_fullPath 0)to_fullPath--;
if (to_fullPath == 0)DokArrival();
if (to_emptyPath 0)to_emptyPath--;
if (to_emptyPath == 0)LoadArrival();
if (to_loading 0)to_loading--;
if (to_loading == 0)LoadComplete();
}
void TankerputDok(Dok d) { dok = d; }
OilHouseOilHouse()
{
oilLevel = 0;
check = 0;
dok = NULL;
}
void OilHouseputDok(Dok d) { dok = d; }
void OilHouserun() {
int a;
if (check == 0) if (oilLevel = almost_empty more_ratio)check = 1;
if (check == 1)if (oilLevel = capacity)
{
timeout2++;
check = 2;
((Dok )dok)-stopWork();
}
if ((total + 1) % 24 == 0) {
a = (total + 1) 24;
vol_ave = vol_ave (1 - 1.0 a) + oilLevel a;
fprintf(oilVolume,%.3fn, oilLevel);
}
if (check == 0)return;
oilLevel -= OU_speed;
rOU++;
if (check == 1)if (oilLevel almost_empty)
{
timeout1++;
check = 0;
return;
}
else return;
else
if (oilLevel = capacity less_radio)
{
check = 1;
((Dok)dok)-resumeWork();
return;
}
}
DokDok()
{
serving = NULL;
House = NULL;
queue = new Tanker [T];
for (int i = 0; i T; i++)queue = NULL;
to_work = -1;
to_break = 6;
working = 1;
}
Dok ~Dok()
{
delete[]queue;
}
void DokputHouse(OilHouse p) { House = p; }
int DokQLength() {
for (int i = 0; i T; i++)
if (queue = NULL)return(i);
return(T);
}
void DokArrival(Tanker ptr)
{
entered++;
if (serving == NULL)
{
serving = ptr;
wait_ave = wait_ave (1 - 1.0 (completed + 1));
fprintf(waitTime, 0n);
ptr-cur_serve = 0;
}
else
{
ptr-cur_wait = 0;
queue[QLength()] = ptr;
}
}
void DokComplete()
{
completed++;
serving-DokComplete();
serving = NULL;
if (queue[0] != NULL)
{
serving = queue[0];
wait_ave = wait_ave (1 - 1.0 (completed + 1)) + (float)(queue[0]-cur_wait) (completed + 1);
fprintf(waitTime, %.3fn, (float)(queue[0]-cur_wait) 24);
for (int i = 0; i (T - 1); i++)queue = queue[i + 1];
queue[T - 1] = NULL;
}
return;
}
void DokNight() {
to_break = 6;
to_work = -1;
}
void DokMorning()
{
to_break = -1;
to_work = 18;
}
void DokstopWork()
{
working = 0;
}
void DokresumeWork()
{
working = 1;
}
void Dokrun() {
int a;
if (to_break 0)to_break--;
if (to_break == 0)Morning();
if (to_work 0)to_work--;
if (to_work == 00)Night();
if (serving != NULL)
{
serving-cur_serve++;
if ((working != 0) && (to_work 0))
{
serving-cur_storage -= Tanker_speed;
(((OilHouse)House)-oilLevel) += Tanker_speed;
if (serving-cur_storage serving-min_storage)Complete();
}
}
for (int i = 0; i T; i++)
if (queue != NULL)(queue-cur_wait)++;
if ((total + 1) % 24 == 0)
{
a = (total + 1) 24;
queN_ave = queN_ave (1 - 1.0 a) + ((float)QLength()) a;
fprintf(nQueue, %dn, QLength());
}
}
#define N 35040
#include classes19.h
#include cstdio
int main()
{
int i;
Tanker t;
oilVolume = fopen(oilVolume, wt);
fullTime = fopen(fullTime, wt);
waitTime = fopen(waitTime, wt);
nQueue = fopen(nQueue, wt);
srand((unsigned)time(0));
t = new Tanker [T];
for (i = 0; i T; i++)
t = new Tanker(i + 1);
Dok d;
OilHouse o;
for (i = 0; i T; i++)
t-putDok(&d);
o.putDok(&d);
d.putHouse(&o);
for (total = 0L; total N; total++)
{
for (i = 0; i T; i++)
t-run();
d.run();
o.run();
}
for (i = 0; i T; i++)
delete t;
delete[]t;
fclose(oilVolume);
fclose(fullTime);
fclose(waitTime);
fclose(nQueue);
printf(Всего поступлений в док %dn, entered);
printf(Разгружено %dn, completed);
printf(Прерывания снабжения очистительной установки %dn, timeout1);
printf(Прерывания разгрузки %dn, timeout2);
printf(Доля времени, в течение которого снабжалась нефтью очистительная установка %.3fn, ((float)rOU) total);
printf(Средний уровень нефти в хранилище %.3fn, vol_ave);
printf(Средняя длительность полного рейса танкера %.3fn, fpath_ave 24);
printf(Средняя длительность ожидания в очереди %.3fn, wait_ave 24);
printf(Средняя длина очереди %.fn, queN_ave);
printf(Средняя длительность разгрузки %.3fn, serve_ave 24);
}
Continue reading...
#include cstdio
#include cstdlib
#include ctime
#include cmath
using namespace std;
int entered = 0;
int completed = 0;
int rounds = 0;
int timeout1 = 0;
int timeout2 = 0;
int T = 1;
long int rOU = 0;
FILE oilVolume;
FILE fullTime;
FILE waitTime;
FILE nQueue;
float vol_ave = 0;
float fpath_ave = 0;
float queN_ave = 0;
float wait_ave = 0;
float serve_ave;
long int total;
class Tanker {
private
static const float storage;
static const float full_ave;
static const float full_offset;
static const float empty_ave;
static const float empty_offset;
static const float load_ave;
static const float load_offset;
static const float min_storage;
int id;
void dok;
int to_fullPath;
int to_emptyPath;
int to_loading;
int cur_storage;
int cur_wait;
int cur_round;
int cur_serve;
public
friend class Dok;
Tanker(int i);
void putDok(Dok d);
void LoadArrival();
void LoadComplete();
void DokArrival();
void DokComplete();
void run();
};
const float Tankerfull_ave = 5;
const float Tankerstorage = 400;
const float Tankerempty_ave = 4;
const float Tankerfull_offset = 1.5;
const float Tankerempty_offset = 1;
const float Tankerload_ave = 72;
const float Tankerload_offset = 2.4;
const float Tankermin_storage = 3;
class OilHouse {
static const float capacity;
static const float OU_speed;
static const float less_radio;
static const float almost_empty;
static const float more_ratio;
void dok;
float oilLevel;
int check;
public
friend class Dok;
OilHouse();
void putDok(Dok d);
void run();
};
const float OilHousecapacity = 1000;
const float OilHouseOU_speed = 1.45;
const float OilHouseless_radio = 0.8;
const float OilHousemore_ratio = 10;
const float OilHousealmost_empty = 5;
class Dok {
static const float Tanker_speed;
void House;
Tanker serving;
Tanker queue;
int to_break;
int to_work;
int working;
public
Dok();
~Dok();
void putHouse(OilHouse p);
int QLength();
void Arrival(Tanker ptr);
void Complete();
void Night();
void Morning();
void resumeWork();
void stopWork();
void run();
};
const float DokTanker_speed = 2;
TankerTanker(int i)
{
id = i;
to_fullPath = -1;
to_emptyPath = -1;
cur_storage = 0;
to_loading =get_uniform((int)(load_ave 10),(int)(load_offset 10)) 10;
dok = NULL;
cur_wait = -1;
cur_round = 0;
cur_serve = -1;
}
void TankerLoadArrival()
{
to_emptyPath = -1;
to_loading = get_uniform((int)(load_ave 10),(int)(load_offset 10)) 10;
rounds++;
fpath_ave = fpath_ave (1 - 1.0 rounds) + ((float)cur_round) rounds;
fprintf(fullTime, %.3fn, ((float)cur_round) 24);
cur_round = 0;
}
void TankerLoadComplete()
{
to_loading = -1;
cur_storage = storage;
to_fullPath = (int)(get_normal(full_ave, full_offset, 0.01) 24);
if (to_fullPath = 0)to_fullPath = 1;
}
void TankerDokArrival() {
to_fullPath = -1;
((Dok)dok)-Arrival(this);
}
void TankerDokComplete()
{
to_emptyPath = (int)(get_normal(empty_ave, empty_offset, 0.01) 24);
if (to_emptyPath = 0)to_emptyPath = 1;
serve_ave = serve_ave (1 - 1.0 completed) + ((float)cur_serve) completed;
fprintf(fullTime, %.3fn, ((float)cur_round) 24);
cur_serve = -1;
}
void Tankerrun()
{
if (to_fullPath 0)to_fullPath--;
if (to_fullPath == 0)DokArrival();
if (to_emptyPath 0)to_emptyPath--;
if (to_emptyPath == 0)LoadArrival();
if (to_loading 0)to_loading--;
if (to_loading == 0)LoadComplete();
}
void Tankerrun()
{
cur_round++;
if (to_fullPath 0)to_fullPath--;
if (to_fullPath == 0)DokArrival();
if (to_emptyPath 0)to_emptyPath--;
if (to_emptyPath == 0)LoadArrival();
if (to_loading 0)to_loading--;
if (to_loading == 0)LoadComplete();
}
void TankerputDok(Dok d) { dok = d; }
OilHouseOilHouse()
{
oilLevel = 0;
check = 0;
dok = NULL;
}
void OilHouseputDok(Dok d) { dok = d; }
void OilHouserun() {
int a;
if (check == 0) if (oilLevel = almost_empty more_ratio)check = 1;
if (check == 1)if (oilLevel = capacity)
{
timeout2++;
check = 2;
((Dok )dok)-stopWork();
}
if ((total + 1) % 24 == 0) {
a = (total + 1) 24;
vol_ave = vol_ave (1 - 1.0 a) + oilLevel a;
fprintf(oilVolume,%.3fn, oilLevel);
}
if (check == 0)return;
oilLevel -= OU_speed;
rOU++;
if (check == 1)if (oilLevel almost_empty)
{
timeout1++;
check = 0;
return;
}
else return;
else
if (oilLevel = capacity less_radio)
{
check = 1;
((Dok)dok)-resumeWork();
return;
}
}
DokDok()
{
serving = NULL;
House = NULL;
queue = new Tanker [T];
for (int i = 0; i T; i++)queue = NULL;
to_work = -1;
to_break = 6;
working = 1;
}
Dok ~Dok()
{
delete[]queue;
}
void DokputHouse(OilHouse p) { House = p; }
int DokQLength() {
for (int i = 0; i T; i++)
if (queue = NULL)return(i);
return(T);
}
void DokArrival(Tanker ptr)
{
entered++;
if (serving == NULL)
{
serving = ptr;
wait_ave = wait_ave (1 - 1.0 (completed + 1));
fprintf(waitTime, 0n);
ptr-cur_serve = 0;
}
else
{
ptr-cur_wait = 0;
queue[QLength()] = ptr;
}
}
void DokComplete()
{
completed++;
serving-DokComplete();
serving = NULL;
if (queue[0] != NULL)
{
serving = queue[0];
wait_ave = wait_ave (1 - 1.0 (completed + 1)) + (float)(queue[0]-cur_wait) (completed + 1);
fprintf(waitTime, %.3fn, (float)(queue[0]-cur_wait) 24);
for (int i = 0; i (T - 1); i++)queue = queue[i + 1];
queue[T - 1] = NULL;
}
return;
}
void DokNight() {
to_break = 6;
to_work = -1;
}
void DokMorning()
{
to_break = -1;
to_work = 18;
}
void DokstopWork()
{
working = 0;
}
void DokresumeWork()
{
working = 1;
}
void Dokrun() {
int a;
if (to_break 0)to_break--;
if (to_break == 0)Morning();
if (to_work 0)to_work--;
if (to_work == 00)Night();
if (serving != NULL)
{
serving-cur_serve++;
if ((working != 0) && (to_work 0))
{
serving-cur_storage -= Tanker_speed;
(((OilHouse)House)-oilLevel) += Tanker_speed;
if (serving-cur_storage serving-min_storage)Complete();
}
}
for (int i = 0; i T; i++)
if (queue != NULL)(queue-cur_wait)++;
if ((total + 1) % 24 == 0)
{
a = (total + 1) 24;
queN_ave = queN_ave (1 - 1.0 a) + ((float)QLength()) a;
fprintf(nQueue, %dn, QLength());
}
}
#define N 35040
#include classes19.h
#include cstdio
int main()
{
int i;
Tanker t;
oilVolume = fopen(oilVolume, wt);
fullTime = fopen(fullTime, wt);
waitTime = fopen(waitTime, wt);
nQueue = fopen(nQueue, wt);
srand((unsigned)time(0));
t = new Tanker [T];
for (i = 0; i T; i++)
t = new Tanker(i + 1);
Dok d;
OilHouse o;
for (i = 0; i T; i++)
t-putDok(&d);
o.putDok(&d);
d.putHouse(&o);
for (total = 0L; total N; total++)
{
for (i = 0; i T; i++)
t-run();
d.run();
o.run();
}
for (i = 0; i T; i++)
delete t;
delete[]t;
fclose(oilVolume);
fclose(fullTime);
fclose(waitTime);
fclose(nQueue);
printf(Всего поступлений в док %dn, entered);
printf(Разгружено %dn, completed);
printf(Прерывания снабжения очистительной установки %dn, timeout1);
printf(Прерывания разгрузки %dn, timeout2);
printf(Доля времени, в течение которого снабжалась нефтью очистительная установка %.3fn, ((float)rOU) total);
printf(Средний уровень нефти в хранилище %.3fn, vol_ave);
printf(Средняя длительность полного рейса танкера %.3fn, fpath_ave 24);
printf(Средняя длительность ожидания в очереди %.3fn, wait_ave 24);
printf(Средняя длина очереди %.fn, queN_ave);
printf(Средняя длительность разгрузки %.3fn, serve_ave 24);
}
Continue reading...