Andiguys

65 Reputation

5 Badges

1 years, 54 days

MaplePrimes Activity


These are replies submitted by Andiguys

@acer Thank you.

If I replace the condition a ≤ b with a range like c ≤ a ≤ b, where a, b, and c are functions of p1, how can I isolate p1 to determine its range?

Note: provided all parameters are positive.

restart

kernelopts(version)

`Maple 2019.1, X86 64 WINDOWS, May 21 2019, Build ID 1399874`

(1)

B := w+Ce; A := (1/3)*`ϕ`*(-beta*p1+a)-upsilon*Pu

ineq := -A/upsilon <= (B-A*(2*U*upsilon+1)/upsilon)/(2*(U*upsilon+1)) and (B-A*(2*U*upsilon+1)/upsilon)/(2*(U*upsilon+1)) <= (`&varphi;`*(-beta*p1+a)-A)/upsilon

-((1/3)*varphi*(-beta*p1+a)-upsilon*Pu)/upsilon <= (w+Ce-((1/3)*varphi*(-beta*p1+a)-upsilon*Pu)*(2*U*upsilon+1)/upsilon)/(2*U*upsilon+2) and (w+Ce-((1/3)*varphi*(-beta*p1+a)-upsilon*Pu)*(2*U*upsilon+1)/upsilon)/(2*U*upsilon+2) <= ((2/3)*varphi*(-beta*p1+a)+upsilon*Pu)/upsilon

(2)

temp := collect(ineq,p1);

(1/3)*varphi*beta*p1/upsilon-((1/3)*varphi*a-upsilon*Pu)/upsilon <= (1/3)*varphi*beta*(2*U*upsilon+1)*p1/(upsilon*(2*U*upsilon+2))+(w+Ce-((1/3)*varphi*a-upsilon*Pu)*(2*U*upsilon+1)/upsilon)/(2*U*upsilon+2) and (1/3)*varphi*beta*(2*U*upsilon+1)*p1/(upsilon*(2*U*upsilon+2))+(w+Ce-((1/3)*varphi*a-upsilon*Pu)*(2*U*upsilon+1)/upsilon)/(2*U*upsilon+2) <= -(2/3)*varphi*beta*p1/upsilon+((2/3)*varphi*a+upsilon*Pu)/upsilon

(3)

# lhs and rhs are both of type `+`, so select/remove make sense
new := simplify(temp - remove(depends,lhs(temp),p1) - select(depends,rhs(temp),p1));

Error, invalid input: lhs received (1/3)*varphi*beta*p1/upsilon-((1/3)*varphi*a-upsilon*Pu)/upsilon <= (1/3)*varphi*beta*(2*U*upsilon+1)*p1/(upsilon*(2*U*upsilon+2))+(w+Ce-((1/3)*varphi*a-upsilon*Pu)*(2*U*upsilon+1)/upsilon)/(2*U*upsilon+2) and (1/3)*varphi*beta*(2*U*upsilon+1)*p1/(upsilon*(2*U*upsilon+2))+(w+Ce-((1/3)*varphi*a-upsilon*Pu)*(2*U*upsilon+1)/upsilon)/(2*U*upsilon+2) <= -(2/3)*varphi*beta*p1/upsilon+((2/3)*varphi*a+upsilon*Pu)/upsilon, which is not valid for its 1st argument, expr

 

simplify(solve(new,p1));

Error, invalid input: simplify uses a 1st argument, s, which is missing

 
 

``

Download Q_isolate_acc.mw

@mmcdara So, from the sheet, I gathered that when 1×10^-10 ≤ U_0   and upsilon ≤ 1, both constraints are satisfied. Is that correct?

@vv In constraint p1 is in RHS and LHS, how to bring it to one side? Thats why optimization code not reading it.

    C1 := -0.3500000000 p1 <= -15289.70833 + 0.1837500000 p1

    C2 := 0.1837500000 p1 <= -0.4083333334 p1 + 16956.66667

Stil showing error : "Error, (in Optimization:-NLPSolve) no feasible point found for the linear constraints"

@mmcdara Similarly, I attempted to merge the two plots, but in the second case, the plot appears identical to the first one. Could you help me identify what might have gone wrong? I’ve attached the actual plot for Case 2, created on a separate sheet, where you can see that the value of Pc starts around 2820. However, when I combine both cases into a single sheet, the Pc values for Case 2 seem to be taken from Plot 1 instead.

Problem mentioned in sheet: Q_N1_mmcdara.mw

Case 2: 

@mmcdara I have two plots representing two different cases, both with TR on the x-axis and TP on the y-axis. I’d like to combine them into a single plot, using different colored lines to distinguish each case. What code should I use to do this?

restart

_local(D)

DATA := [Cm = 8000, U[0] = 5, Cr = 2000, a = 19000, U = 500, w = 2000, lambda = .9, tau0 = .4, k = 10000, Pu = 500, beta = .8, upsilon = .8, `&varphi;` = .8, t = 1000]

NULL

L_wout := proc (p1, p2) options operator, arrow; (p1-Cm)*(-beta*p1+a)+lambda*(((1/3)*`&varphi;`*(-beta*p1+a)-upsilon*(Pu-Pc))*(-epsilon*p1-Cr+p2-w)+(-beta*p2+a-(1/3)*`&varphi;`*(-beta*p1+a)+upsilon*(Pu-Pc))*(p2-Cm)+k*((1/3)*`&varphi;`*(-beta*p1+a)-upsilon*(Pu-Pc)-tau0*(-beta*p1+a))) end proc

R_wout := proc (Pc) options operator, arrow; lambda*(w*((1/3)*`&varphi;`*(-beta*p1+a)-upsilon*(Pu-Pc))+epsilon*p1*((1/3)*`&varphi;`*(-beta*p1+a)-upsilon*(Pu-Pc))-Pc*((1/3)*`&varphi;`*(-beta*p1+a)-upsilon*(Pu-Pc))-U*((1/3)*`&varphi;`*(-beta*p1+a)-upsilon*(Pu-Pc))+U[0]*((1/3)*`&varphi;`*(-beta*p1+a)-upsilon*(Pu-Pc))^2) end proc

C1 := {-((1/3)*`&varphi;`*(-beta*p1+a)-upsilon*Pu)/upsilon <= Pc}

C2 := {Pc <= (2*`&varphi;`*(-beta*p1+a)*(1/3)+upsilon*Pu)/upsilon}

C_11 := subs(p1 = (-6*beta*k*lambda*tau0*upsilon*U[0]+Cm*beta*lambda*`&varphi;`-6*Cm*beta*upsilon*U[0]-3*Cm*epsilon*lambda*upsilon-Cr*beta*lambda*`&varphi;`+3*Cr*epsilon*lambda*upsilon-3*Pu*epsilon*lambda*upsilon-3*U*epsilon*lambda*upsilon+a*epsilon*lambda*`&varphi;`-6*beta*k*lambda*tau0+beta*k*lambda*`&varphi;`-beta*lambda*w*`&varphi;`-3*epsilon*k*lambda*upsilon+6*epsilon*lambda*upsilon*w-6*a*upsilon*U[0]-6*Cm*beta-6*a)/(2*(beta*epsilon*lambda*`&varphi;`-3*epsilon^2*lambda*upsilon-6*beta*upsilon*U[0]-6*beta)), C1)

C_21 := subs(p1 = (-6*beta*k*lambda*tau0*upsilon*U[0]+Cm*beta*lambda*`&varphi;`-6*Cm*beta*upsilon*U[0]-3*Cm*epsilon*lambda*upsilon-Cr*beta*lambda*`&varphi;`+3*Cr*epsilon*lambda*upsilon-3*Pu*epsilon*lambda*upsilon-3*U*epsilon*lambda*upsilon+a*epsilon*lambda*`&varphi;`-6*beta*k*lambda*tau0+beta*k*lambda*`&varphi;`-beta*lambda*w*`&varphi;`-3*epsilon*k*lambda*upsilon+6*epsilon*lambda*upsilon*w-6*a*upsilon*U[0]-6*Cm*beta-6*a)/(2*(beta*epsilon*lambda*`&varphi;`-3*epsilon^2*lambda*upsilon-6*beta*upsilon*U[0]-6*beta)), C2)

C_1 := subs(DATA, C_11)

C_2 := subs(DATA, C_21)

NULL

TRC_1 := proc (Pc) options operator, arrow; subs(p1 = (-6*beta*k*lambda*tau0*upsilon*U[0]+Cm*beta*lambda*`&varphi;`-6*Cm*beta*upsilon*U[0]-3*Cm*epsilon*lambda*upsilon-Cr*beta*lambda*`&varphi;`+3*Cr*epsilon*lambda*upsilon-3*Pu*epsilon*lambda*upsilon-3*U*epsilon*lambda*upsilon+a*epsilon*lambda*`&varphi;`-6*beta*k*lambda*tau0+beta*k*lambda*`&varphi;`-beta*lambda*w*`&varphi;`-3*epsilon*k*lambda*upsilon+6*epsilon*lambda*upsilon*w-6*a*upsilon*U[0]-6*Cm*beta-6*a)/(2*beta*epsilon*lambda*`&varphi;`-6*epsilon^2*lambda*upsilon-12*beta*upsilon*U[0]-12*beta), R_wout(Pc)) end proc

TRC := subs(DATA, TRC_1(Pc))

``

NULL

L_w := proc (p1, p2) options operator, arrow; (p1+t-Cm)*(a-beta*(p1+t))+lambda*(((1/3)*`&varphi;`*(a-beta*(p1+t))-upsilon*(Pu-Pc-t))*(-epsilon*p1-Cr+p2-w)+(a-beta*(p2+t)-(1/3)*`&varphi;`*(a-beta*(p1+t))+upsilon*(Pu-Pc-t))*(p2+t-Cm)+k*((1/3)*`&varphi;`*(a-beta*(p1+t))-upsilon*(Pu-Pc-t)-tau0*(a-beta*(p1+t)))) end proc

R_w := proc (Pc) options operator, arrow; lambda*((w+t)*((1/3)*`&varphi;`*(a-beta*(p1+t))-upsilon*(Pu-Pc-t))+epsilon*p1*((1/3)*`&varphi;`*(a-beta*(p1+t))-upsilon*(Pu-Pc-t))-(Pc+t)*((1/3)*`&varphi;`*(a-beta*(p1+t))-upsilon*(Pu-Pc-t))-U*((1/3)*`&varphi;`*(a-beta*(p1+t))-upsilon*(Pu-Pc-t))+U[0]*((1/3)*`&varphi;`*(a-beta*(p1+t))-upsilon*(Pu-Pc-t))^2) end proc

NULL

D1 := {-``*((1/3)*`&varphi;`*(-beta*(p1+t)+a)-upsilon*Pu)/upsilon-t <= Pc}

D2 := {Pc <= (2*`&varphi;`*(-beta*(p1+t)+a)*(1/3)+upsilon*Pu)/upsilon-t}

D_11 := subs(p1 = (-6*beta*k*lambda*tau0*upsilon*U[0]-beta*epsilon*lambda*t*`&varphi;`+Cm*beta*lambda*`&varphi;`-6*Cm*beta*upsilon*U[0]-3*Cm*epsilon*lambda*upsilon-Cr*beta*lambda*`&varphi;`+3*Cr*epsilon*lambda*upsilon-3*Pu*epsilon*lambda*upsilon-3*U*epsilon*lambda*upsilon+a*epsilon*lambda*`&varphi;`-6*beta*k*lambda*tau0+beta*k*lambda*`&varphi;`-beta*lambda*t*`&varphi;`-beta*lambda*w*`&varphi;`+12*beta*t*upsilon*U[0]-3*epsilon*k*lambda*upsilon+6*epsilon*lambda*t*upsilon+6*epsilon*lambda*upsilon*w-6*a*upsilon*U[0]-6*Cm*beta+12*beta*t-6*a)/(2*(beta*epsilon*lambda*`&varphi;`-3*epsilon^2*lambda*upsilon-6*beta*upsilon*U[0]-6*beta)), D1)

D_21 := subs(p1 = (-6*beta*k*lambda*tau0*upsilon*U[0]-beta*epsilon*lambda*t*`&varphi;`+Cm*beta*lambda*`&varphi;`-6*Cm*beta*upsilon*U[0]-3*Cm*epsilon*lambda*upsilon-Cr*beta*lambda*`&varphi;`+3*Cr*epsilon*lambda*upsilon-3*Pu*epsilon*lambda*upsilon-3*U*epsilon*lambda*upsilon+a*epsilon*lambda*`&varphi;`-6*beta*k*lambda*tau0+beta*k*lambda*`&varphi;`-beta*lambda*t*`&varphi;`-beta*lambda*w*`&varphi;`+12*beta*t*upsilon*U[0]-3*epsilon*k*lambda*upsilon+6*epsilon*lambda*t*upsilon+6*epsilon*lambda*upsilon*w-6*a*upsilon*U[0]-6*Cm*beta+12*beta*t-6*a)/(2*(beta*epsilon*lambda*`&varphi;`-3*epsilon^2*lambda*upsilon-6*beta*upsilon*U[0]-6*beta)), D2)

NULL

NULL

D_1 := solve(subs(DATA, D_11), Pc)

D_2 := subs(DATA, D_21)

NULL

NULL

TRC_2 := proc (Pc) options operator, arrow; subs(p1 = (-6*beta*k*lambda*tau0*upsilon*U[0]-beta*epsilon*lambda*t*`&varphi;`+Cm*beta*lambda*`&varphi;`-6*Cm*beta*upsilon*U[0]-3*Cm*epsilon*lambda*upsilon-Cr*beta*lambda*`&varphi;`+3*Cr*epsilon*lambda*upsilon-3*Pu*epsilon*lambda*upsilon-3*U*epsilon*lambda*upsilon+a*epsilon*lambda*`&varphi;`-6*beta*k*lambda*tau0+beta*k*lambda*`&varphi;`-beta*lambda*t*`&varphi;`-beta*lambda*w*`&varphi;`+12*beta*t*upsilon*U[0]-3*epsilon*k*lambda*upsilon+6*epsilon*lambda*t*upsilon+6*epsilon*lambda*upsilon*w-6*a*upsilon*U[0]-6*Cm*beta+12*beta*t-6*a)/(2*beta*epsilon*lambda*`&varphi;`-6*epsilon^2*lambda*upsilon-12*beta*upsilon*U[0]-12*beta), R_w(Pc)) end proc

T_R := subs(DATA, TRC_2(Pc))

obj   := TRC:
cstr  := [C_1[], C_2[]]:
H     := lambda__1*(lhs(cstr[1])-Pc), lambda__2*(Pc-rhs(cstr[2])):
lag   := obj + add(H):
sols  := [solve([diff(lag, Pc), H], {Pc, lambda__1, lambda__2})]:
sols  := map(s -> if eval(lambda__1^2+lambda__2^2, s) = 0 then NULL else s end if, sols):
objs  := map(s -> eval(diff(obj, Pc), s), sols):
pairs := map(s -> [eval(Pc, s), eval(TRC, Pc=eval(Pc, s))], sols):

print():print():

TP_1   := eval(L_wout(p1, p2), sols[1]):
TP     := collect(subs(DATA, TP_1), [p1, p2]):
sol    := solve(diff~(TP, [p1, p2]), {p1, p2}):
triple := eval([p1, p2, TP], sol):

 

(1)

ob   := T_R:
cst  := [D_1[], D_2[]]:
H_1     := lambda__1*(lhs(cst[1])-Pc), lambda__2*(Pc-rhs(cst[2])):
lag_1   := ob + add(H_1):
sols_1  := [solve([diff(lag_1, Pc), H], {Pc, lambda__1, lambda__2})]:
sols_1  := map(s_1 -> if eval(lambda__1^2+lambda__2^2, s_1) = 0 then NULL else s_1 end if, sols_1):
objs_1  := map(s_1 -> eval(diff(ob, Pc), s_1), sols_1):
pairs_1 := map(s_1 -> [eval(Pc, s_1), eval(T_R, Pc=eval(Pc, s_1))], sols_1):

print():print():

TP_2   := eval(L_w(p1, p2), sols_1[1]):
TP_21     := collect(subs(DATA, TP_2), [p1, p2]):
sol_1    := solve(diff~(TP_21, [p1, p2]), {p1, p2}):
triple_1 := eval([p1, p2, TP_21], sol_1):

 

(2)

with(plots)

display(plot([pairs[1][2], triple[3], varepsilon = 0 .. .2], color = blue, linestyle = 3, labels = [TR, 'TP']), seq(textplot([(eval([pairs[1][2], triple[3]], varepsilon = val))[], nprintf("%1.04f", val)], align = {right}), val = 0 .. .2, 0.4e-1), seq(pointplot([eval([pairs[1][2], triple[3]], varepsilon = val)], symbol = solidcircle, symbolsize = 10, color = blue), val = 0 .. .2, 0.4e-1), size = [500, 400])

 

display(plot([pairs_1[1][2], triple_1[3], varepsilon = 0 .. .2], color = blue, linestyle = 3, labels = [TR, 'TP']), seq(textplot([(eval([pairs_1[1][2], triple_1[3]], varepsilon = val))[], nprintf("%1.04f", val)], align = {right}), val = 0 .. .2, 0.4e-1), seq(pointplot([eval([pairs_1[1][2], triple_1[3]], varepsilon = val)], symbol = solidcircle, symbolsize = 10, color = blue), val = 0 .. .2, 0.4e-1), size = [500, 400])

 
 

``

Download Q_N1.mw

I have a doubt regarding the result. When I run the optimization, I get a different value for TR compared to what's shown in the graph. For example, at varepsilon = 0.09, the graph indicates that TR is around 102,000, but when I solve it using NLP optimization, the TR value comes out to be approximately 6.03 × 10^7. Interestingly, the value of Pc is the same in both the graph and the optimized result. Could you help me understand what might have gone wrong? I’m also attaching a screenshot of the code I used, which I placed below the Case 1 scenario in your example.

@mmcdara 

Thank you for sharing the syntax. I have two questions:

  1. Just a Doubt: Are we optimizing the TR and TP functions? I couldn't find any maximize or NLPsolve  functions in the code you provided.

  2. How can I combine the graphs for Case 1 and Case 2 into a single plot? Specifically, I’d like to merge the plots for P1​, Pc​, and ε from both cases into one graph, and do the same for the TR and TP graphs. I’ve attached the spreadsheet for both cases.
    Case_1.mw
    Case_2.mw

@vv When examining the first plot, the value at Pc = 1436 appears to be around 4×10⁷, but the result is showing 10⁸. Also, I'm getting a different plot after using the NLP SOLVE syntax.

Sheet: Q_result_1.mw

@vv Attaching the screeshot by using NLPsolve....Giving same result. Any other function which consider global optimum

@C_R It’s taking a long time to solve, and I still don’t have the result. Is there an easier or faster way to get it done?

Sheet: Simple_T.mw

Can we simplify C1−C2 symbolically, by eliminating all like terms, so that the resulting expression contains the minimum number of terms? Also, what is the syntax to perform this simplification without substituting any numerical values?

@mmcdara Will do.

@mmcdara You can change the syntax.

I have three equation A10,A11 and A12.

I want a slider plot where x-coordinate value is from -10000 to 30000

and y coordinate is value for the y function provided in the attached sheet. y range should be greater than 0 to 500000

Sheet: Slider_Q_(1).mw
Sample plot for your refernce is below, i need plot like this:

@acer Could you assist in solving the three equations for three variables under specific conditions, including the given constraints?

I have to solve A,B, C such that all conditions are satisfied.

Showing error : "Warning, solutions may have been lost"


 

restart

``

A := -beta*(.81*theta*upsilon+134400.00*beta-.72*theta-1125.00*upsilon+4000000)/(2*(8*beta-0.9e-2*upsilon))+500000 >= theta-upsilon*(125/2+(0.1250000000e-1*(134400.00*beta+0.9e-1*theta+3.99887500*10^6))/(16*beta-0.18e-1)+9*theta*(1/8)) and theta-upsilon*(125/2+(0.1250000000e-1*(134400.00*beta+0.9e-1*theta+3.99887500*10^6))/(16*beta-0.18e-1)+9*theta*(1/8)) >= 0

B := 40000 >= (.81*theta*upsilon+134400.00*beta-.72*theta-1125.00*upsilon+4000000)/(2*(8*beta-0.9e-2*upsilon)) and (.81*theta*upsilon+134400.00*beta-.72*theta-1125.00*upsilon+4000000)/(2*(8*beta-0.9e-2*upsilon)) >= 0

C := 3000 >= 1875/2-(0.1250000000e-1*(134400.00*beta+0.9e-1*theta+3.99887500*10^6))/(16*beta-0.18e-1)-9*theta*(1/8) and 1875/2-(0.1250000000e-1*(134400.00*beta+0.9e-1*theta+3.99887500*10^6))/(16*beta-0.18e-1)-9*theta*(1/8) >= 0

-0.1250000000e-1*(134400.00*beta+0.9e-1*theta+3998875.000)/(16*beta-0.18e-1)-(9/8)*theta <= 4125/2 and 0 <= 1875/2-0.1250000000e-1*(134400.00*beta+0.9e-1*theta+3998875.000)/(16*beta-0.18e-1)-(9/8)*theta

(1)

solve(eval({A, B, C}), [upsilon, beta, theta])

``

``


 

Download Q4.mw

 

@acer 

Thank you for your response.

I have a question—suppose I assign numerical values to the parameters Pu and theta, and I want to determine the range of upsilon that satisfies all the given conditions. What would be the appropriate syntax for this?

lets say Pu= 800 and theta = 30000

1 2 3 4 5 6 7 Page 2 of 7