Skip to content

Commit cd0a191

Browse files
committed
Updated README and fixed a few issues in the CLI
1 parent 3db4b7c commit cd0a191

4 files changed

Lines changed: 113 additions & 13 deletions

File tree

477 KB
Binary file not shown.
-474 KB
Binary file not shown.

README.md

Lines changed: 58 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# RelSys (**Rel**ocation **Sys**tem)
22
RelSys is a tool for evaluating a system of queues where arriving customers can be relocated to an alternative queue if none of the servers in the preferred queue are idle.
3-
The source code is written in C++, but we have developed a module for the users preferring Python (Linux).
3+
We have developed two interfaces for RelSys: A Python module (Linux) and a command-line interface (Windows/Linux).
44

55
# Table of contents
66

@@ -9,6 +9,7 @@ The source code is written in C++, but we have developed a module for the users
99
* Output types
1010
2. How to use
1111
* Python (Linux)
12+
* Command-line interface (Windows/Linux)
1213
* C++
1314
3. How to cite
1415
4. Licence
@@ -21,10 +22,10 @@ Consider a number of parallel queues where the capacity of the queue equals the
2122

2223
## Input parameters
2324

24-
RelSys has five types of input parameters for the model:
25+
RelSys uses five types of input parameters:
2526

26-
* An arrival rate vector. Each element corresponds to a customer type.
27-
* A service time vector. Each element corresponds to a customer type.
27+
* An arrival rate vector, where each element corresponds to a customer type.
28+
* A service time vector, where each element corresponds to a customer type.
2829
* A relocation probability matrix. Rows correspond to customer types and columns to queues.
2930
* A capacity vector. Each element corresponds to a queue.
3031
* A preferrence vector. Each element indicates the preferred queue of each customer type.
@@ -38,15 +39,17 @@ RelSys has six output types:
3839
* Shortage probabilities.
3940
* Availability probabilities.
4041
* Expected occupancy.
41-
* Expected fraction of capacity occupied.
42+
* Expected fraction of occupied capacity.
43+
44+
All outputs, except for the *expected occupancy* and *expected fraction of occupied capacity*, can be evaluated from two customer perspectives: The perspective of the customers preferring the queues, and the perspective of all customers arriving to the queues.
4245

4346
# How to use
4447

45-
RelSys is available for Python users on Linux, and for C++ users on all operating systems.
48+
Below are guides on how to use both interfaces of RelSys, which is available as a Python module for Linux and a command-line interface for Windows and Linux.
4649

4750
## Python (Linux)
4851

49-
We have created a RelSys module for Python with `pybind11`. Head to the directory `Python/Linux/`, or run `wget https://github.com/areenberg/RelSys/blob/development/Python/Linux/relsys.cpython-310-x86_64-linux-gnu.so` to download the SO-file for the module.
52+
We have created a Python module for Linux with `pybind11`. Head to the directory `Python/Linux/`, or run `wget https://github.com/areenberg/RelSys/blob/development/Python/Linux/relsys.cpython-310-x86_64-linux-gnu.so` to download the SO-file for the module.
5053

5154
Start by importing the module,
5255

@@ -175,11 +178,57 @@ for queueIdx in range(4):
175178

176179
## Command-line Interface (Windows/Linux)
177180

178-
Coming soon.
181+
We have created a Command-Line Interface (CLI) for Windows and Linux, which is similar to the Python module in terms of features, inputs, and outputs. The CLI utilizes files to import the input parameters and export the results, ensuring a seamless integration. Windows users can head to the directory `Command-line Interface/Windows/`, or use `wget https://github.com/areenberg/RelSys/blob/master/Command-line%20Interface/Windows/relsys.exe` to download the EXE-file for the CLI. Similarly, Linux users can head to `Command-line Interface/Linux/` or use `wget https://github.com/areenberg/RelSys/blob/master/Command-line%20Interface/Linux/relsys.exe`.
182+
183+
The syntax for the CLI is `relsys [options]`. Use the `-help` flag to view all available options.
184+
185+
```
186+
relsys -help
187+
```
188+
189+
Create a space-separated file for each of the input parameter types. For instance,
190+
191+
*arrivalRates.txt*
192+
```
193+
0.8 2.5 0.6 2.8
194+
```
195+
196+
*serviceTimes.txt*
197+
```
198+
10 5 10 8
199+
```
200+
201+
*capacity.txt*
202+
```
203+
15 20 10 30
204+
```
205+
206+
*relocProbs.txt*
207+
```
208+
0.0 0.4 0.1 0.5
209+
0.3 0.0 0.5 0.0
210+
0.0 0.5 0.0 0.5
211+
0.2 0.3 0.5 0.0
212+
```
213+
214+
*preferred.txt*
215+
```
216+
0 1 2 3
217+
```
218+
219+
Evaluate the model using simulation, and save the result in a semicolon-separated file named `results.csv`.
220+
221+
```
222+
relsys -m simulation -arr arrivalRates.txt -ser serviceTimes.txt -cap capacity.txt -rel relocProbs.txt -prq preferred.txt -o results.csv
223+
```
224+
225+
### Windows Defender blocking the EXE-file
226+
227+
If you are a Windows user, you may encounter an issue where the Microsoft Defender SmartScreen blocks the EXE-file when you attempt to run the application. In this case, you will need to turn off SmartScreen to run the application. Alternatively, you can compile the EXE-file by downloading the source code from the `RelSys/` directory, removing the `PythonWrapper.cpp` file, and running the command `g++ -O3 *.cpp -o relsys.exe`. This will enable you to run the application without any issues caused by SmartScreen.
179228

180229
## C++
181230

182-
The approach in C++ is very similar to that of Python. The directory `RelSys/` contains the complete source code for RelSys. Start by heading there. Create a `main.cpp` file.
231+
The following guide will show you how to use the C++ source code for evaluating a model. The directory `RelSys/` contains the complete source code for RelSys. Start by heading there. Create a `main.cpp` file.
183232

184233
Write the following into the `main.cpp` file,
185234

RelSys/main.cpp

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ using namespace std;
2121

2222
//input data structure (including example values)
2323
struct Data {
24+
vector<double> arrivalRates;
25+
vector<double> serviceTimes;
26+
vector<int> capacity;
27+
vector<vector<double>> relocationProbabilities;
28+
vector<int> preferredQueue;
29+
} data;
30+
31+
struct DemoData {
2432
vector<double> arrivalRates = {0.8,2.5,0.6,2.8};
2533
vector<double> serviceTimes {10,5,10,8};
2634
vector<int> capacity = {15,20,10,30};
@@ -29,7 +37,7 @@ struct Data {
2937
{0.0,0.5,0.0,0.5},
3038
{0.2,0.3,0.5,0.0}};
3139
vector<int> preferredQueue = {0,1,2,3};
32-
} data;
40+
} demoData;
3341

3442
//model settings structure
3543
struct Settings {
@@ -66,6 +74,14 @@ struct Results {
6674

6775
//ACTION METHODS
6876

77+
void loadDemo(){
78+
::data.arrivalRates = demoData.arrivalRates;
79+
::data.serviceTimes = demoData.serviceTimes;
80+
::data.capacity = demoData.capacity;
81+
::data.relocationProbabilities = demoData.relocationProbabilities;
82+
::data.preferredQueue = demoData.preferredQueue;
83+
}
84+
6985
void setVerbose(bool set){
7086
settings.verbose=set;
7187
}
@@ -389,9 +405,10 @@ void saveResults(string fileName, string sep){
389405

390406

391407
void printHelp(){
392-
cout << "Usage: relsys.exe [options]" << endl <<
393-
endl << "A demo is loaded if no options are provided." << endl << endl;
394-
cout << "Options include:" << endl << "-v Activate verbose." << endl;
408+
cout << "Usage: relsys.exe [options]" << endl << endl;
409+
410+
cout << "Options include:" << endl;
411+
cout << "-v Activate verbose." << endl;
395412
cout << "-arr <filename> A space-separated vector containing the arrival rates of each customer type." << endl;
396413
cout << "-ser <filename> A space-separated vector containing the service times of each customer type." << endl;
397414
cout << "-cap <filename> A space-separated vector containing the capacities of each queue." << endl;
@@ -400,6 +417,7 @@ void printHelp(){
400417
cout << "-evq <filename> A space-separated vector containing the indices of the queues that are evaluated by the program." << endl;
401418
cout << "-o <filename> Write all results (incl. key measures and distributions) to a semicolon-separated file." << endl;
402419
cout << "-hk Hide key measures from the terminal." << endl << endl;
420+
cout << "-demo Load demo parameters." << endl << endl;
403421

404422
cout << "-m <value> Select the model type (simulation (default), approximation, auto)." << endl;
405423
cout << "-sd <value> Set a seed for the model." << endl;
@@ -415,6 +433,30 @@ void printHelp(){
415433

416434
void checkParameters(){
417435
//checks if parameters are feasible
436+
if (::data.arrivalRates.size()==0){
437+
cout << "The arrival rates were not loaded. Aborting program." << endl;
438+
exit(1);
439+
}
440+
441+
if (::data.serviceTimes.size()==0){
442+
cout << "The service times were not loaded. Aborting program." << endl;
443+
exit(1);
444+
}
445+
446+
if (::data.capacity.size()==0){
447+
cout << "The capacities were not loaded. Aborting program." << endl;
448+
exit(1);
449+
}
450+
451+
if (::data.preferredQueue.size()==0){
452+
cout << "The preferred queues were not loaded. Aborting program." << endl;
453+
exit(1);
454+
}
455+
456+
if (::data.relocationProbabilities.size()==0){
457+
cout << "The relocation probabilities were not loaded. Aborting program." << endl;
458+
exit(1);
459+
}
418460

419461
if (::data.arrivalRates.size() != ::data.serviceTimes.size()){
420462
cout << "The number of arrival rates must equal the number of service times. Aborting program." << endl;
@@ -712,6 +754,13 @@ void argVerbose(int &argc, char** argv){
712754
}
713755
}
714756

757+
void argDemo(int &argc, char** argv){
758+
bool act = argActivate("-demo",argc,argv);
759+
if (act){
760+
loadDemo();
761+
}
762+
}
763+
715764
void argEqualize(int &argc, char** argv){
716765
bool act = argActivate("-equal",argc,argv);
717766
if (act){
@@ -734,8 +783,10 @@ void argOutputToFile(int &argc, char** argv){
734783
}
735784

736785
void readArguments(int &argc, char** argv){
786+
argDemo(argc,argv);
737787
argArrivalRates(argc,argv);
738788
argServiceTimes(argc,argv);
789+
argCapacity(argc,argv);
739790
argRelocProbs(argc,argv);
740791
argPreferred(argc,argv);
741792
argEvalQueues(argc,argv);

0 commit comments

Comments
 (0)