1
$\begingroup$

I've been trying to solve an optimization problem using Mathematica. I'm 100% familiar with the programme, I just practised a few tutorials available online, but they were very small and the problem is a bit larger. This is a screenshot of the actual problem enter image description here

This is my attempt at using Mathematica to solve the problem. enter image description here

I also copied the script from the screenshot above. The script is as follows:

NMaximize[{(1/T) (p (Q - E) + 10 x - 20 Q - 10 - 
 5 ((6000) 25^0.6 e^(-0.1 p) + (Subscript[t, 1]^3/(6 (0.04)) - 
      Subscript[t, 1]^2/2) + Subscript[Qt, 1]) - (5/2) (25 + 
    E) (T - Subscript[t, 1])), 
  Q == 25 + (((6000) 25^0.6 e^(-0.1 p))/(2 (0.04))) (0.04^2 - (0.04 - 
       T)^2 - (2 (0.04) (25^(1 - 0.6) - E^(1 - 0.6)))/(6000 (1 - 
          0.6) e^(-0.1 p))) && Q >= w && Subscript[t, 1] = 
   0.04 - Sqrt[(0.04 - 
     T)^2 - (2 (0.04) (25^(1 - 0.6) - E^(1 - 0.6)))/(6000 (1 - 
        0.6) e^(-0.1 p))] && Subscript[t, 1] >= 0 && E >= 0 && 
    w >= E && Subscript[t, 1] >= 0 && T >= Subscript[t, 1] && 
    m >= T}, {E, p, T, Q, Subscript[t, 1]}]
$\endgroup$
1
  • 1
    $\begingroup$ Welcome to the Mathematica Stack Exchange. E represents the base of natural log. In general use lower case letters for user-defined symbols. Please update the post with this change. $\endgroup$
    – Syed
    Nov 26 '21 at 13:09
2
$\begingroup$

In addition to correcting the equations, also include the constraint that p > 0

Clear["Global`*"]

$Version

(* "12.3.1 for Mac OS X x86 (64-bit) (June 19, 2021)" *)

(sys = {(1/t) (p (q - e) + s*e - c*q - o - 
       h (α*w^β*E^(-λ*p) (t1^3/(6 m) - t1^2/2) + 
          q*t1) - (h/2) (w + e) (t - t1)), 
    q == w + ((α w^β E^(-λ*p))/(2 m))*(m^2 - (m - 
            t)^2 - (2 m (w^(1 - β) - 
              e^(1 - β)))/(α (1 - β) E^(-λ*p))), 
    q >= w, 
    t1 == 
     m - Sqrt[(m - 
           t)^2 + (2 m (w^(1 - β) - 
             e^(1 - β)))/(α (1 - β) E^(-λ*p))], 
    t1 >= 0, e >= 0, w >= e, t >= t1, m >= t, p > 0});

α = 6000; β = 0.6; λ = 0.1; c = 20; (* $/unit *) 
h = 5; (* $/unit/year *) m = 0.04; (* years *) 
o = 10; (* $/order *) s = 10; (* $/unit *) 
w = 25; (* units *)

Maximizing,

NMaximize[sys, {e, p, t, q, t1}]

(* {8366.52, {e -> 6.51561, p -> 28.1919, t -> 0.0231873, q -> 39.6589, 
  t1 -> 0.00645804}} *)
$\endgroup$
7
  • $\begingroup$ Don;t you think that $e$ in the question stands for E in Wolfram Language (see the attached image))? $\endgroup$
    – user64494
    Nov 26 '21 at 16:01
  • $\begingroup$ @user64494 - Yes, that is why I entered e as E and converted the variable E to e. $\endgroup$
    – Bob Hanlon
    Nov 26 '21 at 16:12
  • $\begingroup$ You should rewrite $e^{...}$ as Exp[...], not as e^... with a variable e. Hope I am clear. $\endgroup$
    – user64494
    Nov 26 '21 at 16:18
  • $\begingroup$ @user64494 - compare my equations with the image. Where the image showed e^x (exponentiation) I used E^x; where the image showed the variable E raised to a power (I.e., E^x) I changed this to e^x since the variable is now e $\endgroup$
    – Bob Hanlon
    Nov 26 '21 at 16:27
  • $\begingroup$ @user64494 - in the image the only Exp terms are e^(-λ*p); in my equations these are all entered as E^(-λ*p). And in my equations, the image's E^(1-β) are entered as e^(1-β). I agree with your concept but not your reading of my equations. $\endgroup$
    – Bob Hanlon
    Nov 26 '21 at 16:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.