TransWikia.com

Manipulate and Plot of Tangent Point in Optimization Problem with Kinked Constraint: Solve and PieceWise Problems

Mathematica Asked on August 3, 2021

I’m trying to illustrate an optimization problem with a piecewise constraint creating a kink at the maximum value of T if n>0.

ClearAll[U, f, c, α, T, w, l, n, sols, c1transf, c2transf, fstar, cstar]
U[f_, c_, α_] := f^α*c^(1 - α);
Bconstrtransf[f_, c_, T_, w_, n_]:= Piecewise[{{c - (T - f)*w - n, f < T}}];
MRS = D[U[f, c, α], f]/D[U[f, c, α], c]
AbsSlpCon = D[Bconstrtransf[f, c, T, w, n], f];
TC = MRS - AbsSlpCon;
f < T

sols = Solve[{TC == 0, Bconstrtransf[f, c, T, w, n] == 0}, {f, c}]
{fstar, cstar} = {f, c} /. Last[sols]

sols2 = Solve[{TC == 0, Bconstrtransf[f, c, T, w, n] == 0}, {f, c}]
fcopttransf[T_, w_, α_, n_] := Evaluate[{f, c} /. Last[sols2]]

c1transf[T_, w_, n_] :=  c /. Solve[Bconstrtransf[f, c, T, w, n] == 0, c][[1]]
c2transf[T_, w_, α_, n_] =  Quiet[c /. Solve[U[## & @@ fcopttransf[T, w, α, n],α] == U[f, c, α], c][[1]]];

Manipulate[Plot[{c1transf[T, w, n], c2transf[T, w, α, n]}, {f, 0, 24}, PlotRange -> {25, 6000}, Epilog -> {Red, PointSize@Large, Point@fcopttransf[T, w, α, n]}], {T, 8, 24}, {w, 100, 
  200}, {{α, 1/2}, 10^-2, 1}, {n, 500, 2000}]

My problems are that

  1. I can’t get an output for c2transf or the optimal point

  2. I would like to have a vertical line from (T,n) to (T,0) to show that c1transf creates a "visual set."

Update: I know that the optimal solution is either f*<T or f*=T and the problem is a variation of this:
Manipulate and Plot of Tangent Point in Optimization Problem: Solve Problems

Any hints or solutions for this problem?

Thanks!

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP