You can try this for specific examples numerically (I dont see another option since you have to specify that the number of boxes have to be integers, as far as I could interpret your picture)
a = 15;
b = 7;
c = 3;
d = 2;
NMinimize[
{
(a*b - n1*c*d - n2*c*d)^2
, Element[n1, Integers]
&& Element[n2, Integers]
&& n1*c <= a
&& n1*d <= b
&& n2*d <= a
&& n2*c <= b
&& 0<=n1 (*additional conditions*)
&& 0<=n2
}
, {n1, n2}
]
{5625., {n1 -> 3, n2 -> 2}}
The result above tells you that the error in the objective function (a*b - n1*c*d - n2*c*d)^2
is 5625 when you use 3 boxes with their long side with length c
parallel to the platform side with length a
and 2 of the other boxes with length d
parallel to a
.
A analytical solution seems difficult since you have to consider only integers for n1
and n2
and they have to fulfill the conditions I also gave in the minimization.
FindMinimum
is only used for numerical computations. First try assuming that some parameters are positive and use the functionMinimize
. For example take a look at thisAssuming[ a > 0 , Simplify[Minimize[a*x^2, x]] ]
$\endgroup$Minimize[(a - p*c)*(b - m*d), {p, m}]
works, but the solution (either $a b$, $0$, or $\infty$) can be readily derived from(a - p*c)*(b - m*d) // Expand
. $\endgroup$KnapsackSolve
(new in v11) is probably better for this sort of problem. But I don't understand the problem, and if I'm not alone, better explanations are needed. 3. The syntax you used withFindMinimum
is simply wrong. Don't guess and then wonder why it didn't work. Look it up! $\endgroup$