Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168731
Image: ubuntu2004
Zheng Han
ISE@Lehigh University


Motivation

In Linear Optimization(LP), people can solve a given low-dimensional problem by simply scratching the feasible region after which we can immediately figure out the optimal solution(if it exists). Such method only solves LPs with 3\leq 3 variables because human beings are 3-dimensional animals. We have little sense of higher dimensions. However, we know that induction sometimes helps: by starting from lower-dimensional cases, we could infer some properties that a higher-dimensional one should also satisfy thus improve our understanding of all these problems. Furthermore, if we feed more possible lower-dimension cases to our brain, we magically increase our ability to discern those unforseen properties.

This demo aims to take one step toward this direction: let's take a look at the polyhedron as well as the optimal solution of a corresponding LP in 4-dimension. That is, the feasible region, which is a polyhedron, changes (linearly) as time elapses. Consider the LP in the form of:

min(x,t)0cTx+ctts.t.Ax+Attb \begin{darray}{rcl} \displaystyle{\min_{(x,t)\geq 0} }& c^Tx + c_t t \\ \text{s.t.} & Ax +A_t t \leq b \end{darray}

Example

The feasible region is a polyhedron. For instance, the following example: $ \begin{eqnarray} \displaystyle{\min_{(x,t)\geq 0} } & -x_1 -6x_2 -13x_3 \\ \begin{align} \text{s.t.} \\ \ \\ \ \\ \ \\ \end{align} & \begin{align} x_1 + t &\leq 200\\ x_2 + t &\leq 300 \\ x_1 +x_2 +x_3 + t &\leq 400 \\ x_2 +3x_3 + t &\leq 600 \end{align} \end{eqnarray} Wecanimplementinsageandseehowthefeasibleregionandtheoptimalsolutionchangebymodifying We can implement in sage and see how the feasible region and the optimal solution change by modifying t$.

def par(t): # Obtain the feasible region: a polyhedron tmp = [[200-t,-1,0,0],[300-t,0,-1,0],[400-t,-1,-1,-1],[600-t,0,-1,-3],[0,1,0,0],[0,0,1,0],[0,0,0,1]] G = Polyhedron(ieqs = tmp,field = RDF) # For fixed t, adjust parameters c = vector(RDF,[-1,-6,-13]) A = matrix(RDF,[[1,1,1],[0,1,3],[1,0,0],[0,1,0],[-1,0,0],[0,-1,0],[0,0,-1]]) b = vector(RDF,[400-t,600-t,200-t,300-t,0,0,0]) # Find the optimal point and attach it to the polyhedron sol = linear_program(c,A,b) # Plot M = G.render_solid(rgbcolor='blue',alpha=.2)+G.render_wireframe(rgbcolor='black') M+= point(sol['x'],size=15,rgbcolor='red') return M @interact def _(t=(0,100,1)): par(t)
1+1