N11:maximum number of hours available in a week to make products in
F3

Output:

3 numbers {R1,R2,R3} or "-1"

where:

R1:total number of A's to manufacture in a week
R2:total number of B's to manufacture in a week
R3:total profit which is **maximum possible profit** with the right mix of A and B
**result = `-1` if R1 and/or R2 is non integer(contains fraction)**

Downvoters, would you care to give some constructive criticism?
–
Yuval FilmusFeb 6 '13 at 16:50

my idea is as follows: for each factory find the number of A and B products such that it's maximizes profit. But i am not getting how the output of {10.5,13,3,7,5,6,5,11,16,11, 21.6} is NULL
–
user6709Feb 6 '13 at 16:59

From my interpretation, you need to maximize all three factories at the same time; otherwise, this is (a) not a dynamic programming question, (b) only requires the first five numbers because the algorithm for maximizing for one factory is generalizable, and (c) even in your second example, why would the answer be 3A's if the factories were seperate? Yet, even given that, wouldn't the other example be 1A and not NULL?
–
MerbsFeb 6 '13 at 17:41

If we consider the case of moving from one factory to another. for example If A requires 3hrs and total number of hrs/week in F1 is 5 then make(5/3) A's in F1 and try to make(1/3)A's in some other factory
–
user6709Feb 6 '13 at 17:51

1 Answer
1

This is a basic constrained optimization problem. This will require linear programming because you have inequality constraints.

Alternatively since this is entirely linear and each factory is independent of each other, work out which option A/B offers the highest return per factory. Call this the chosen product. Work out how many units of the chosen product can be produced given the constraint. Look at the factory downtime, if this is bigger than required to build more unit of the non-chosen item then this must also be produced.

Then compare hour blocks to produce the object A,B (i.e. F1 is 3 or 7) to calculate how many multiples of the not-chosen product are foregone in producing the last unit of the chosen product, you must also add on any factory downtime at this stage. i.e. let the value for the chosen product be 7 and 3 for the non-chosen, then we have 2 units foregone. But if we have 2 hours downtime, then it should be (7+2) / 3 to yield 3 units foregone.

Compare if the units foregone for the last output of the chosen product at a given factory exceed in value the last unit produced (this is the remainder problem).

If true, then the factory produces this mixed output. If false, proceed with the prior output strategy for said factory.

Select highest and then move on to the next factory. Rest should be obvious.

This is my C++ code to solve the problem using my alternative method. I hope this clears up all questions.

my understanding is as follows.In the above example for factory1 "chosen product" is A. so we can produce (5/3)=1 A.We have 1 unit foregone.(coz in factory 1 we can't produce B). But i am not getting-"Compare if the units foregone for the last output of the chosen product at a given factory exceed in value the last unit produced (this is the remainder problem)." can you explian this with example given above?
–
user6709Feb 6 '13 at 18:40

You have zero units foregone because 7(b) is larger than 3(a). Units foregone is entirely for the last unit of the chosen product so can only apply if x(b) < y(a) when (a) is the chosen product. An example could be let (a) be the chosen product. (a) requires 10 hours per unit. Let (b) require 3 hour per unit. I have 25 hours on my factory. I have a remainder of 2 hours - factory downtime (2a + 1b). Although 1 (a) produces more profit then 4 (b), 5 (b) produce more profit than 1(a). So it is better to make 1(a) and 5(b) in this situation. This is why we do the units foregone comparison
–
anonFeb 6 '13 at 19:02

I understand your constraint solution, but how would you explain the examples given?
–
MerbsFeb 6 '13 at 19:07

So, for above example 1)chosen product is A 2) downtime for factory1 is 2 3)if we get 5 more hours we can choose B so we are foregone by 0? am i right?
–
user6709Feb 6 '13 at 19:14

1

@Cybernex You should avoid giving the whole code ... boil it down to a pseudocode. And in either case, use proper formatting.
–
PareshFeb 10 '13 at 14:29