Problem Statement | ||||||||||||||||||||||||
You are the manager (and owner) of a manufacturing company, which has a warehouse and a production factory. Your factory has several automated production lines. Each line can create complex products from others simpler products. You can buy base products and store them with your manufactured products in your limited capacity warehouse. Your task will be to maximize profits by managing the day by day factory operations. Your FactoryThere are B different base products and M different manufactured products. Base products are denoted by integers from 0 to B-1 and manufactured products are denoted by integers from B to B+M-1. Each day, you may produce up to L manufactured products. The prerequisite products must be available in sufficient quantities from the warehouse, and you cannot use a product as a prerequisite on the day it is produced. The output products will be brought to the warehouse, which has a limited capacity: you can store at most C products (including base products). Your company has a commercial team that negotiates contracts with customers. Each contract is defined by the quantities of products to deliver, a total price, a maximal date of delivery, and a penalty rate in case of delay. You can accept or reject these contracts but your decision is always final. Your typical day as the Factory manager is (in order):
Implementation DetailsYou will have to manage the factory on a day by day simulation. For this you must provide two functions: First, an init function that receive the parameters:
Then a manage function that will be called at each step of the simulation.
This function receives several parameters necessary to manage the factory.
A int[] warhouse gives the B+M quantities of products in the warehouse.
A int[] prices gives the B prices of the base products.
A String[] contracts gives the contracts of the day that you have to validate.
Each contract contains is formatted as: Your manage function must return a String[] containing 4 elements (lists of integers separated by spaces).
Money matters
Each base product has a reference price P0. Its market price is updated daily according to the following scheme: newPrice[i] = P0[i]0.01*oldPrice[i]0.99*1.05r where r is a random uniform variable between -1 and 1.
The initial price (day 0) is obtained by applying 1000 times this scheme starting from the reference price.
Each manufactured product has a price equal to the sum of the prices of its constituting products plus a value factor F multiplied by the complexity of the process (in number of required products).
For example if a manufactored product requires one each of products 1, 2, 4 and 13, then its price will be: Prices are simulated internly with double precision. However we provide rounded integer values to your function. The actual prices of your transactions will always be the rounded value. The balance of your account is initially 0 and it is allowed to have a negative balance. End of simulation and scoringAfter a very long period of very hard work (5000 days), you decide to sell you factory in order to buy a private island to retire. You negotiated that all the current accepted contract will be honoured by your successor in exchange of the entire stock in the warehouse. The simulation will end after 5000 steps. At the end ot the 5000th day, after receiving the money for the contracts you just shipped and paying the penalties for the delays of the current late contracts, you gather your money and leave forever, leaving the current contracts (late or not) and the current stock to be handled by your successor. For each test case your score is your profits measured by the amount of money on your account when you leave. If you have lost money then your score will be 0. Your total score will be the sum of your relative scores (your score / best score) Any invalid action will give you a 0 score. For example exceeding the warehouse capacity; insufficient quantities of necessary products; produce more than L products; ship several times the same contract; refer to a inexistent or rejected contract; refer to an inexistent product; bad size of the returned vector; etc... Parameter generationBase parameters: The following parameters are chosen randomly and uniformly in the following inclusive ranges:
Process specifications: The number of products required to make a manufactured product is randomly chosen as floor(1.5 + 6*r2) where r is between 0 and 1. Each required products is randomly and independently chosen among all the products having a lower number than the output product with possible repetition. Contracts:
ToolsA jar file and the source are available for offline testing. To use this tool, you will need to create an executable out of your submission. The executable must communicate with the tool via standard out and standard in. You should read the parameters from standard in, and write your outputs to standard out. You may write debugging statements to standard error. To run the tool, open a console, and run "java -jar Tester.jar <command> <seed>". <command> is the command for your executable (Java users must do something like "java class") and <seed> is a seed for the random number generator (examples are 1-10).You should first read the init parameters. B, M, L and C will first be given on one line. The next M lines will contain the M elements of processes. You should not output anything after receiving the init parameters. You will then receive the manage parameters exactly 5000 times. Each time, the elements of warehouse will be given on one line, and the elements of prices will be given on the next line. A single line will then contain N, the number of contracts. The following N lines will contain the N contracts. Each reading the parameters to manage, you should print exactly four lines to standard out, containing the four elements of your return. For example, the text below gives the contents you must read from standard in for the call to init, and the first call to manage for example 0: 21 14 876 7426 14 7 14 7 5 2 1 12 1 22 8 17 23 15 5 20 18 1 11 7 17 11 15 19 21 0 24 19 6 9 8 15 11 0 7 9 5 28 29 19 27 2 27 19 26 12 20 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 30 43 70 34 44 32 35 50 64 58 66 80 21 65 37 39 98 76 52 60 41 6 0 211338 73 35 0 1 0 0 300 0 0 266 0 0 0 0 0 34 1 655720 1 15 0 0 0 0 0 446 0 0 0 0 0 0 0 1 2 101436 59 37 0 1 143 0 37 0 0 0 900 1 0 0 0 0 3 320 84 31 0 1 0 0 0 0 0 0 0 0 0 0 0 0 4 4830 100 25 0 0 0 0 0 0 0 0 0 0 30 0 0 0 5 20920 36 15 0 0 0 35 0 0 0 0 0 0 0 0 0 0 | ||||||||||||||||||||||||
Definition | ||||||||||||||||||||||||
| ||||||||||||||||||||||||
Notes | ||||||||||||||||||||||||
- | Time limit is 30 seconds. | |||||||||||||||||||||||
- | Memory limit is 1GB. | |||||||||||||||||||||||
Examples | ||||||||||||||||||||||||
0) | ||||||||||||||||||||||||
| ||||||||||||||||||||||||
1) | ||||||||||||||||||||||||
| ||||||||||||||||||||||||
2) | ||||||||||||||||||||||||
| ||||||||||||||||||||||||
3) | ||||||||||||||||||||||||
| ||||||||||||||||||||||||
4) | ||||||||||||||||||||||||
| ||||||||||||||||||||||||
5) | ||||||||||||||||||||||||
| ||||||||||||||||||||||||
6) | ||||||||||||||||||||||||
| ||||||||||||||||||||||||
7) | ||||||||||||||||||||||||
| ||||||||||||||||||||||||
8) | ||||||||||||||||||||||||
| ||||||||||||||||||||||||
9) | ||||||||||||||||||||||||
|