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.
There 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):
The order is important to understand the management of the warehouse.
- You accept or reject the contracts negotiated by your commercial team.
- You optionally order some base products.
- You determine the production quantity of each manufactured product.
- The required products for the production process are brought from the warehouse to the production factory.
- The factory produces the manufactured products.
- The manufactured products created by the production lines are brought to the warehouse.
- You optionally decide which contracts are finalized: the corresponding products are taken from the warehouse and you get paid.
- You pay penalties for all the contracts that you were supposed to ship today or earlier, and that you did not ship.
- Late in the evening, your warehouse receives the base products ordered in the morning.
You 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:
processes[i] is a space separated list of products required to produce B+i.
The init function may return any integer (which is ignored).
- B -- number of base products,
- M -- number of manufactured products,
- L -- production limit in number of products by day,
- C -- the capacity of the warehouse,
- processes containing the M manufacturing processes.
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:
"ID PRICE DAYS PENALTY C0 C1 ... CM-1".
ID is a unique contract ID, PRICE is the sale price, DAYS is the number of days you have to fulfill the contract, PENALTY is the penalty rate (mutiplied by 1000) and Ci is the number of products of type B+i to deliver. Example if B=5 and M=9, contract "35 5540 52 24 0 0 10 0 0 17 0 3 0" means: contract ID35 for 10 manufactured products of type "7", 17 manufactured products of type "10" and 3 manufactured products of type "12" for $5540, after 52 days there is a 5540*24/1000 penalty per day.
Your manage function must return a String containing 4 elements (lists of integers separated by spaces).
- The quantities of each base product that you buy (exactly B integers).
- The production quantities of each manufactured product (exactly M integers). Their sum must be less or equal to the production limit L.
- The list of accepted contracts (IDs of contracts, this list must be a subset of the IDs given in contracts, if you do not accept any contract use an empty string).
- The list of contracts IDs that you ship (IDs of previously accepted contracts).
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:
Price = 4*F + Price+Price+Price+Price.
As the prices of the base products fluctuate, the prices of the manufactured products also fluctuate.
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 scoring
After 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...
The following parameters are chosen randomly and uniformly in the following inclusive ranges:
- B (number of base products) between 5 and 25.
- M (number of manufactured products) between 5 and 25.
- L (production limit by day) between 100 and 1000.
- C (capacity of the warehouse) between 1000 and 10000.
- The reference price P0 of each base product is equal to 50*2r where r is between -1 and 1.
- The value factor F of each manufactured product is equal to 5*2r where r is between -1 and 1.
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.
- The number of contracts that you receive each day is randomly chosen between 0 and 10, inclusive.
- The contract IDs will be unique integers.
- The number of different products ordered is randomly chosen between 1 and 5, inclusive.
- The requested products are then randomly chosen among the M possible products, without repetitions.
- For each product, the quantity ordered is ceil(1000*r3) where r is a random uniform variable in [0, 1].
- The maximal number of days to honor the contract is chosen between 0 and 100, inclusive.
A maximal number of days equals to 1 means that you have to ship the products at the end of the next day.
- The penalty rate is chosen between 0 and 50 (i.e. between 0% to 5% per day).
- The amount of the contract is equal to the current market price of the products multiplied by two modifying factors.
The first one depends on the negotiation skill of your commercial team, this factor is chosen as 1.5r where r is a random uniform variable between -1 and 1.
The second one is a stress factor equals to min(1.5, 1+(number_of_products_requested/maximal_number_of_days)*penalty_rate/10000). If maximal_number_of_days = 0 then the stress factor is 1.5 (or 1.0 if rate also equals zero)
A 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 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
11 0 7
5 28 29
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
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