ctomkins

156 Reputation

3 Badges

12 years, 47 days

MaplePrimes Activity


These are answers submitted by ctomkins

I actually want to do something slightly more complicated than my original query. I want to produce Pi(Q_gt,s_gt) where the stuff in parentheses has subscripts, rather than say, Pi_gt where Pi has a subscript, which as you indicated above would simply be accomplished by text:=textplot([0.72,0.4,typeset(`#msubsup(mi("Pi"),mi("gt"))`)]); Even just trying to do get this part Pi(Q_gt caused a problem with the parens: text2:=textplot([0.72,0.4,typeset(`#msubsup(mi("Pi(Q"),mi("gt")"))`)]):
Thanks much, both for the advice, which works, and the prompt response. Probably would not (read definitely would not!) have figured it out if I had been left to my own devices. So have to agree with Georgios that this sort of cryptic approach to creating plots with subscripts, etc., in Maple could really provoke violence towards one's computer. :)
Thanks, Paulina, but the reason that I am using plot() in my procedure Q_opt is precisely because I can't use Maximize(). I have min[1,Q+s/2] as an expression for my integration bound in my objective function and the canned optimization routine Maximize() does not handle this. Specifically, the error I get is as follows: Error, (in Optimization:-NLPSolve) unable to compare -(1/2)*s and 0 I therefore wrote the procedure Q_opt to extract the maximum from the grid of points that plot would use -- basically a manual approach to optimization. My routine for Q_opt was as follows: Q_opt:=proc(s_val,p_val,pa_val) if not is( {args}, set(numeric) ) then return 'procname'('args') end if; Payoff :=1-1/24*s^3-1/2*s*min(1, Q+1/2*s)^2+1/4*s^2*min(1, Q+1/2*s)-1/3*min(1, Q+1/2*pa)^3+1/3*min(1, Q+1/2*s)^3+Q*min(1, Q+1/2*pa)^2-Q*min(1, Q+1/2*s)^2-Q^2*min(1, Q+1/2*pa)+Q^2*min(1, Q+1/2*s)+s*Q*min(1, Q+1/2*s)-1/2*pa+1/2*pa*min(1, Q+1/2*pa)^2+1/4*pa^2-1/4*pa^2*min(1, Q+1/2*pa)-s*Q+pa*Q-pa*Q*min(1, Q+1/2*pa)-p*Q; P:=plot(subs(s=s_val,subs(p=p_val,subs(pa=pa_val,Payoff))),Q=0..1); A:=remove(has,op([1,1],P),undefined): MAX:=max(op(map(t->t[2],A))); points:=op([1,1],P): MAXPT:=select(t->t[2]=MAX,points); op(1,MAXPT[1]); end proc: The new Q_opt that I just wrote using Maximize() is Qopt2 := proc (sval, pval, paval) if not is({args}, set(numeric)) then return ('procname')('args') end if; Payoff := proc (Q, s, p, pa) options operator, arrow; 1-(1/24)*s^3-(1/2)*s*min(1, Q+(1/2)*s)^2+(1/4)*s^2*min(1, Q+(1/2)*s)-(1/3)*min(1, Q+(1/2)*pa)^3+(1/3)*min(1, Q+(1/2)*s)^3+Q*min(1, Q+(1/2)*pa)^2-Q*min(1, Q+(1/2)*s)^2-Q^2*min(1, Q+(1/2)*pa)+Q^2*min(1, Q+(1/2)*s)+s*Q*min(1, Q+(1/2)*s)-(1/2)*pa+(1/2)*pa*min(1, Q+(1/2)*pa)^2+(1/4)*pa^2-(1/4)*pa^2*min(1, Q+(1/2)*pa)-s*Q+pa*Q-pa*Q*min(1, Q+(1/2)*pa)-p*Q end proc; [MAXVAL, MAXPT] = Maximize(Payoff(Q, s*val, pval, paval)) end proc BUT returns the following error when I test it: > Qopt2(.2, 0.1e-1, 1) Error, (in Optimization:-NLPSolve) unable to compare -(1/2)*s and 0 Suggestions for handling this optimization problem where the central issue is with checking the value of the integration bounds in my objective function?
I have uploaded my worksheet at the following link: http://www.mapleprimes.com/files/5475_070922_Example.mw The comments in the worksheet point out the inconsistent plotting on Q_opt. (There are some variable name changes from the above post, i.e. T_opt=Q_opt in this file and (x,y,z)=(s,p,pa).) Q_opt evaluates to be decreasing in the parameter s at the command prompt, which is correct. But when plotted the graph shows Q_opt increasing in s -- all the plotted values are wrong! Thanks.
Sorry, the link to the plot is: http://www.mapleprimes.com/files/5475_Example-Maple-Bug.jpg Also, where I typed "X_opt" at the beginning of line 3 I clearly meant to type "T_opt."
Thanks -- that seems to work. (I am using an older version of Maple, Maple 9, so perhaps should upgrade!)
Hi Scott, Thanks -- yes, I will upload a worksheet shortly. Also, I have made some headway. I now have a procedure that uses fsolve to return the optimal Q: > Q_buyer:=proc(s_val,p_val,pa_val) > fsolve(subs(p=p_val,subs(s=s_val,subs(pa=pa_val,FOC_1_alt))),Q); > end proc: For example: > Q_buyer(0.6-0.01,0,0.6); 0.7050000000 And then I have a second procedure that evaluates my profit function as follows: > profit:=proc(s_val,p,pa,m,K) > simplify(p*Q_buyer(s_val,p,pa) + s_val*subs(s=s_val,subs(Q=Q_buyer(s_val,p,pa),y)) + m*(K-subs(s=s_val,subs(Q=Q_buyer(s_val,p,pa),y)))); > end proc: For example: > profit(0.59,0,0.6,0.5,1); 0.5223661250 This is exactly what I wanted to be able to do -- to compute the profit at the optimal Q. Except, now I want to be able to optimize profit with respect to the parameters s_val and p. When I try fsolve with my procedure Maple doesn't like it: > fsolve({profit(s,p,0.8,0.5,1)},{s,p},{s=0..0.7999,p=0..10}); Error, (in fsolve) {s, p} are in the equation, and are not solved for And it doesn't like plot3d with the profit procedure either.
Disregard the last statement - maximize works. It just didn't work for my problem. Maple returned an unevaluated statement, indicating that it had not found a solution. The frustrating thing is that when I plot the payoff function above, I can see that it has an optima in (p,s). I just don't seem to be able to get Maple to find it symbolically! If you plot plot(subs(p=0.1,subs(pa=0.6,x)),s=0..1,view=[0..1,-10..10]); where x is as defined above: x:=-1/4*(s^2-pa^2+4*pa-4*s-4*p)/(s-pa) you'll see that the curve to the left of s=pa is smooth. Why is Maple having difficulty finding the maximizer (s,p)?
Okay, this is helpful. Thanks. But maximize doesn't appear to be recognized in my Maple version. Do I need to activate (or install) the global optimization toolbox? Or do I just try a similar command as I use to add functionality to plot: with(plots)?
Sorry, having problems with the "less than sign." The earlier post should read "s less than pa," where pa is some defined parameter of my problem.
This should say, over the restricted range s
Page 1 of 1