Andiguys

100 Reputation

5 Badges

1 years, 260 days

MaplePrimes Activity


These are replies submitted by Andiguys

@sand15 

Thank you for pointing that out. I understand your concern and I apologize for mixing different problems together earlier.
Below is a clean worksheet with only the objective function and constraints so it’s clearer.

Also, I’m sorry if my way of following up seemed inconsiderate. I truly appreciate the time and effort you put into answering my queries, and I’ll make sure to acknowledge the solutions properly before moving on to new questions.

The last syntax you shared worked well and its correct.

restart

_local(Pi)

Pi

(1)

``

NULL

Pi := proc (Pn, Pr, w) options operator, arrow; (Pn-Cn)*(1-(Pn-Pr)/(1-delta))+(Pr-w-Crm)*alpha*rho0*(1-(Pn-Pr)/(1-delta))-Ce*rho0*(1-(Pn-Pr)/(1-delta)) end proc

C1 := (2*(-(1-(Pn-Pr)/(1-delta))/(2*tau)-Cr*(1-(Pn-Pr)/(1-delta))^2/(8*tau^2)))*((2*rho0-1)*tau+i2)+(w/(2*tau)-1/2+i2/(2*tau))*(1-(Pn-Pr)/(1-delta))-Cr*(1/2-i2/(2*tau))*(1-(Pn-Pr)/(1-delta))^2/(2*tau) > 0

 

 

Download Proposal_follow_up.mw

@sand15 Thankyou for the syntax. Just one more question.

If I have three decision variables and one constraint, can I still solve it using the same syntax? How would that work?

restart

with(Optimization); with(plots); with(LinearAlgebra)

_local(Pi)

Pi

(1)

NULL

NULL

SC_CS_sols := solve(
  {
    diff(?????) - mu[1] = 0,
    mu[1]*(-2*(-(1 - (Pn - Pr)/(1 - delta))/(2*tau) - Cr*(1 - (Pn - Pr)/(1 - delta))^2/(8*tau^2))*((2*rho0 - 1)*tau + i2) + (w/(2*tau) - 1/2 + i2/(2*tau))*(1 - (Pn - Pr)/(1 - delta)) - Cr*(1/2 - i2/(2*tau))*(1 - (Pn - Pr)/(1 - delta))^2/(2*tau)) = 0
   
  }
  ,
  {i1, mu[1]}
  , 'parametric'='full', 'parameters'={P, Q, A, B}
)

SC_CS_sols := piecewise(P = 0, piecewise(Q <> 0, [], Q = 0, [{i1 = i1, mu[1] = 0}]), P <> 0, [{i1 = -Q/(2*P), mu[1] = 0}])

(2)

pi__m := (Pn - Cn)*(1 - (Pn - Pr)/(1 - delta)) + (Pr - w - Crm)*alpha*(1/2 + (i1 - i2)/(2*tau))*(1 - (Pn - Pr)/(1 - delta)) - Ce*rho0*(1 - (Pn - Pr)/(1 - delta)):

collect(pi__m, [Pn,Pr,w]):
PQR := [R, Q, P] =~ [coeffs(%, i1)]:

print~(PQR):

R = w*(1/2-(1/2)*i2/tau)*(1-(Pn-Pr)/(1-delta))-C0-(1/2)*Cr*(1/2-(1/2)*i2/tau)^2*(1-(Pn-Pr)/(1-delta))^2+Ce*rho0*(1-(Pn-Pr)/(1-delta))

 

Q = ((1/2)*w/tau-1/2+(1/2)*i2/tau)*(1-(Pn-Pr)/(1-delta))-(1/2)*Cr*(1/2-(1/2)*i2/tau)*(1-(Pn-Pr)/(1-delta))^2/tau

 

P = -(1/2)*(1-(Pn-Pr)/(1-delta))/tau-(1/8)*Cr*(1-(Pn-Pr)/(1-delta))^2/tau^2

(3)

AB := [A = `2*`(-(1 - (Pn - Pr)/(1 - delta))/(2*tau) - Cr*(1 - (Pn - Pr)/(1 - delta))^2/(8*tau^2))*((2*rho0 - 1)*tau + i2) + (w/(2*tau) - 1/2 + i2/(2*tau))*(1 - (Pn - Pr)/(1 - delta)) - Cr*(1/2 - i2/(2*tau))*(1 - (Pn - Pr)/(1 - delta))^2/(2*tau) ]

[A = (2*rho0-1)*tau+i2, B = tau+i2]

(4)

ind  := indets(rhs~(PQR)) union indets(rhs~(AB));

{C0, Ce, Cr, Pn, Pr, delta, i2, rho0, tau, w}

(5)

randomize();
data:=[C0 = 0.02, Ce = 0.05, Cr = 0.05, Pn = 0.603882321, Pr = 0.45, delta = 0.7, i2 = 0.1, rho0 = 0.5, tau = 0.05, w = 0.243374];

PQRAB := { eval(PQR, data)[], eval(AB, data)[] };

all_solutions := allvalues~(eval(SC_CS_sols, PQRAB)):
all_pi        := map(s -> eval(eval(pi__m, data), s), all_solutions):
here          := ListTools:-Search(min(all_pi), all_pi):
SOLUTION      := [all_pi[here], all_solutions[here]];


plot(eval(pi__m, data), i1=eval(eval(A..B, AB), data), gridlines=true)

Download Proposal_follow_up.mw

@sand15 

Thank you very much for your detailed and helpful comments

You’re right , I’ll substitute the solved expression for K2 (the w solution) into {K3,K4} and solve it to simplify Maple’s task.

Point well taken, I will carefully check feasibility and not assume any solution is correct without verifying it myself.

Thanks again for the clear, constructive feedback.

 rcorless 750,  @sand15 and @dharr Thankyou for the reply.

I have modified my objective function and, as before, I am simultaneously solving three equations with three variables and multiple parameters. This process is giving me three different solution sets, and I am unsure which one is correct or should be considered.

Note: All parameters are positive and greater than zero. All decision variable Pn, Pr and w should be positive equal to or greater than zero.

Download Q_solve.mw

@acer I am optimizing a profit function with respect to three decision variables Pn,Pr, and w. When I solve the problem, I obtain conditions such as Pn(Pr,w), Pr​(Pn​,w), and w(Pn,Pr), which makes them appear dependent on each other. How can I simultaneuosly solve K2,K3 and K4 so that I can obtain the optimal values of Pn, Pr​, and w simultaneously as independent decision variables?

 

restart

``

Pi1 := proc (Pn, Pr, w) options operator, arrow; (Pn-Cn)*(1-(Pn-Pr)/(1-delta))+(Pr-w-Cr)*((Pn-Pr)/(1-delta)-(-beta*(-(1/2)*tau+(1/2)*i2+(1/2)*w)*upsilon+Pr)/delta)-Ce*rho0*(1-(Pn-Pr)/(1-delta)) end proc

proc (Pn, Pr, w) options operator, arrow; (Pn-Cn)*(1-(Pn-Pr)/(1-delta))+(Pr-w-Cr)*((Pn-Pr)/(1-delta)-(-beta*(-(1/2)*tau+(1/2)*i2+(1/2)*w)*upsilon+Pr)/delta)-Ce*rho0*(1-(Pn-Pr)/(1-delta)) end proc

(1)

K2 := diff(Pi1(Pn, Pr, w), w) = 0

-(Pn-Pr)/(1-delta)+(-beta*(-(1/2)*tau+(1/2)*i2+(1/2)*w)*upsilon+Pr)/delta+(1/2)*(Pr-w-Cr)*beta*upsilon/delta = 0

(2)

diff(Pi1(Pn, Pr, w), `$`(w, 2))

-beta*upsilon/delta

(3)

solve(K2, w)

-(1/2)*(Cr*beta*delta*upsilon-Pr*beta*delta*upsilon+beta*delta*i2*upsilon-beta*delta*tau*upsilon-Cr*beta*upsilon+Pr*beta*upsilon-beta*i2*upsilon+beta*tau*upsilon-2*Pn*delta+2*Pr)/((-1+delta)*beta*upsilon)

(4)

K3 := diff(Pi1(Pn, Pr, w), Pn) = 0

1-(Pn-Pr)/(1-delta)-(Pn-Cn)/(1-delta)+(Pr-w-Cr)/(1-delta)+Ce*rho0/(1-delta) = 0

(5)

diff(Pi1(Pn, Pr, w), `$`(Pn, 2))

-2/(1-delta)

(6)

solve(K3, Pn)

(1/2)*Ce*rho0+(1/2)*Cn-(1/2)*Cr+Pr-(1/2)*delta-(1/2)*w+1/2

(7)

K4 := diff(Pi1(Pn, Pr, w), Pr) = 0

(Pn-Cn)/(1-delta)+(Pn-Pr)/(1-delta)-(-beta*(-(1/2)*tau+(1/2)*i2+(1/2)*w)*upsilon+Pr)/delta+(Pr-w-Cr)*(-1/(1-delta)-1/delta)-Ce*rho0/(1-delta) = 0

(8)

diff(Pi1(Pn, Pr, w), `$`(Pr, 2))

-2/(1-delta)-2/delta

(9)

solve(K4, Pr)

-(1/4)*beta*delta*i2*upsilon+(1/4)*beta*delta*tau*upsilon-(1/4)*beta*delta*upsilon*w-(1/2)*Ce*rho0*delta+(1/4)*beta*upsilon*i2-(1/4)*beta*upsilon*tau+(1/4)*beta*upsilon*w-(1/2)*delta*Cn+delta*Pn+(1/2)*Cr+(1/2)*w

(10)

``

``

``

``


 

Download Simultaneously_solve.mw

@acer
I had shared the complete details of the substitutions and their explanations in my message last week. Could you please confirm if you were able to review that? I can resend the details if needed. Thankyou. 

@sand15 Thankyou so much.

@sand15 The z-axis values are still shown only up to zero—how can I extend it to display positive values? Also, how can I display the z-value at point P?

@sand15 @acer Thankyou 

@Carl Love Correction: only s1, s2​, and d are greater than or equal to zero. All other parameters can take positive or negative values

restart

kernelopts(version)

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

(1)

X3 := 0 >= A*s1^2+B*s1+C

A*s1^2+B*s1+C <= 0

(2)

X4 := s1 <= (-4*A*d*s2-F)/(4*d*A)

s1 <= (1/4)*(-4*A*d*s2-F)/(d*A)

(3)
 

`assuming`([solve({X3, X4}, {s1})], [s1 > 0, s2 > 0, d > 0])

Download Q_s.mw

@acer 
 

Substitution
In the sheet attached below, I’ve substituted Cmin⁡=β1and Cmax⁡=β2​.
Is this substitution correct, or should it instead be Cmin⁡=−β1 and Cmax⁡=−β2​ (or the other way around)?
This is my first point of confusion.


Regarding the table
From the solution set named SC_CS_sols, I have values for:

  • Pc∗​ (optimal Pc​)

  • μ1​

  • μ2​

I want these results presented in a table where:

  • Column 1 → optimal Pc value

  • Cloumn 2 → μ1​ value

  • Column 3 → μ2​ value

As you know, in the KKT conditions there are three cases, which the above table signifies:

  1. μ1=0, μ2>0

  2. μ2=0, μ1>0

  3. μ1=μ2=0

The table should show the optimal Pc​ value for each of these cases.I just want to tabulate it and export as doc or pdf format.

Questions are highlighted in yellow in sheet.

KKT_Table_Q-22.mw

can you help me in  solving the values of s1 that satisfy both inequality constraints simultaneously — in other words, find a condition or range for s1​, such as s1=… , given ...... > …, under which both inequalities are true.

restart

kernelopts(version)

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

(1)

X3 := 0 >= A*s1^2+B*s1+C

A*s1^2+B*s1+C <= 0

(2)

X4 := s1 <= (-4*A*d*s2-F)/(4*d*A)

s1 <= (1/4)*(-4*A*d*s2-F)/(d*A)

(3)

``

extra1 := `~`[`>`](indets(X3, And(name, Not(constant))), 0)

{0 < A, 0 < B, 0 < C, 0 < s1}

(4)

extra2 := `~`[`>`](indets(X4, And(name, Not(constant))), 0)

{0 < A, 0 < F, 0 < d, 0 < s1, 0 < s2}

(5)

`assuming`([solve({X3, X4}, {s1})], [extra1[], extra2[]])

Download Q_s.mw

@acer Hi can you help me to tabulate the result? and verify whether the substititution i made are right. Thankyou

@sand15 Thankyou.

Can in anyway possible to take out  delta3  from the equaltion so that i get condition like delta > or < (delta3) * L expression.

Basically to show relationship between delta and delta3.

@sand15 Thankyou

1 2 3 4 5 6 7 Last Page 3 of 11