2
$\begingroup$

I find Maximize doesn't work well under conditional statement. Here is an example. enter image description here

A car is driving up a slope. I want to find out the largest slope angle the car can drive upwards. I choose the slope angle θ and engine torque τ as decision variables. The friction force can be described by Coulomb friction model, which is a conditional statement

enter image description here

The complete formulation is

enter image description here

Therefore, the Nonlinear Optimization can be solved by

  Maximize[{θ, 0 < θ < Pi/2 && 0 < τ < 2 && 
            If[τ/r < μs*G*Cos[θ], τ/r, μd G Cos[θ]] > G Sin[θ]}, {θ, τ}]

given the parameters: G = 70; r = 0.025; μs = 0.5; μd = 0.4;

Mathematica gives θ=0.380506,,which is ArcTan[μd], whereas the expected result should be θ=0.46364,which is ArcTan[μs].

$\endgroup$
2
$\begingroup$

Try If[c, x > z, y > z] instead of If[c, x, y] > z:

G = 70; r = 0.025; μs = 0.5; μd = 0.4;
Maximize[{θ, 0 < θ < Pi/2 && 0 < τ < 2 && 
   If[τ/r < μs*G*Cos[θ], τ/r > G Sin[θ], μd G Cos[θ] > G Sin[θ]]}, {θ, τ}]
{0.463648, {θ -> 0.463648, τ -> 0.782624}}
ArcTan[μs]
0.463648
$\endgroup$
  • $\begingroup$ :@ybeltukov,aha! Thanks. There is a trick. $\endgroup$ – novice Jan 17 '14 at 2:38
1
$\begingroup$

Just a long comment. A bit annoying :

constr[x_, θ_] = 
  Piecewise[{{x - G Sin[θ], x < μs*G*Cos[θ]}, 
             {μd G Cos[θ] - G Sin[θ], x >= μs*G*Cos[θ]}
            }] ;

sol = NMaximize[Join[{θ, 0 < θ < Pi/2, 0 < τ < 2}, {constr[τ/r, θ] > 0}], {θ, τ}] 
(* {0.380506, {θ -> 0.380506, τ -> 1.08698}} *)

but

constr[τ/r, θ] /. sol[[2]]
(* -8.0802*10^-6 *)
$\endgroup$
  • $\begingroup$ It seems the piecewise method has the same answer as the if conditional statement. $\endgroup$ – novice Oct 21 '13 at 8:02
  • $\begingroup$ Yes, you're right. I only wanted to stress that the constraints is not met, even though by a small number. $\endgroup$ – b.gates.you.know.what Oct 21 '13 at 8:16
  • $\begingroup$ Is it because the friction function is not continuous? And, is there another way to impose the constraint? $\endgroup$ – novice Oct 22 '13 at 2:13

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.