This project consists of executing a program that will optimize the performance of a process chain, maximizing a result and/or reducing the delay as much as possible.
You must therefore run a program that, as input, reads a file that describes the processes, analyze the entire file and propose a valid solution of interest.
You will also have to create a second small checker program.
You have to create at least two process file of your own, that is not a copy/paste of the ones provided.
### Introduction
You may have already seen a project in which all tasks are linked, according to their respective dependencies and restrictions.
The goal of this program is to organize a certain chain of project tasks in order to optimize a defined task the faster and most efficient way.
Example:
Imagine a project with different tasks in witch we have to achieve a final goal. Each of the tasks can have their dependencies and restrictions, lets say you are putting together a new cabinet and you have 7 boards.
The purpose of this example is to optimise time and cabinet, basically the cabinet is the last product to achieve in the project and time is to be prioritized so that the building of your cabinet is done the fastest way possible.
So the number before the task represents the cycle when the task starts. The tasks can run separately or at the same time depending on the stocks that are used.
In the example above we have the first 6 tasks beginning at cycle 0 and running at the same time, this happens because we have 7 boards and all of them can be used in the first 6 tasks without any dependencies. After the 6 tasks are finished it has already passed 20 cycles, so the next task (do_cabinet) will start at cycle 20 and end at cycle 50. This task did not start earlier because it is dependant of the results of the others.
Well, optimizing a regular schedule may help you to prioritize your tasks and make your program work with that purpose.
Priority based project scheduling is a quick and easy heuristic scheduling technique that makes use of two components to construct a resource feasible project schedule, a [priority rule and a schedule generation scheme](http://www.pmknowledgecenter.com/node/256).
Here are some ways to schedule a scheme:
- [Serial schedule generation scheme](http://www.pmknowledgecenter.com/dynamic_scheduling/baseline/optimizing-regular-scheduling-objectives-schedule-generation-schemes): selects the activities one by one from the list and schedules them as-soon-as-possible in the schedule.
- [Parallel schedule generation scheme](http://www.pmknowledgecenter.com/dynamic_scheduling/baseline/optimizing-regular-scheduling-objectives-schedule-generation-schemes): selects at each predefined time period the activities available to be scheduled and schedules them in the list as long as enough resources are available.
#### File format
First we need a configuration file that contains the processes and must obey the following instructions:
- A `#` that defines comments
- A description of the stocks available at the start, with the following format
So, as we said above, you must create at least two configuration file of your own. One file that ends when the resources are consumed, and the other which can rotate indefinitely.(will be explained in the next topic)
Then we can run the **The stock exchange program** to generate a schedule.
- It takes 2 parameters:
`./stock_exchange <file> <waiting_time>`
- The first is the `configuration file` with all stocks and processes. The second parameter is a waiting time that the program should not exceed in seconds.
- In the situation where the resources will be consumed and the processes will stop, due to the lack of resources, the display will go all the way without errors.
- In the situation where the system self-powers and rotates indefinitely, you will choose a reasonable shutdown condition, and your stocks should show that the whole process went well several times.
- There is no obligation of invariance between two executions. This means that, for the same configuration, the first recommended solution, may be different from the second one.
- The first parameter is the configuration file, the second is a log file containing the trace of stock exchange program which must be checked.
- The display must indicate whether the sequence is correct, or indicate the cycle and the process which are causing the problem. In all cases, at the end of the program, stocks are displayed, as well as the last cycle.
Running the stock exchange program with error, you can see the correct file [here](https://public.01-edu.org/subjects/stock-exchange-sim/examples/simple/simple)
Running the checker program with error, you can see the correct file [here](https://public.01-edu.org/subjects/stock-exchange-sim/examples/simple/simple.log)