Operator Form of Input for Optimization Package Commands
This help page describes the operator form of input for commands in the Optimization package. For general information on all the input forms accepted by the Optimization package commands, see the Optimization/InputForms help page.
The descriptions of the various components below assume that the optimization problem involves minimizing or maximizing a function of variables x1, x2, ..., xn.
Objective Function
Constraints
Bounds
Initial Values
Solution
Examples
Specify the objective function as a procedure that accepts n floating-point parameters corresponding to the problem variables and returns a float.
The Optimization[LSSolve] command accepts an objective function of the form 12⁢f1⁡x1,x2,...,xn2+f2⁡x1,x2,...,xn2+...+fq⁡x1,x2,...,xn2. In this situation, the objective function is specified as a list of procedures, each taking n floating-point parameters representing the problem variables and returning a float. These procedures compute the least-squares residuals f1, f2, ..., fq.
Specify the inequality constraints as a set or list of procedures. A single constraint v⁡x1,x2,...,xn≤0 is specified as a procedure v of the same form as the objective function previously described and returning the left-hand side value of the constraint.
Specify the equality constraints also as a set or list of procedures. Each constraint w⁡x1,x2,...,xn=0 is specified as a procedure returning the left-hand side value of the constraint.
Specify bounds as a sequence of ranges. For example, the sequence −1.0..2.5,0.5..3.2 indicates that the first problem variable is constrained to be between −1.0 and 2.5, and the second is constrained to be between 0.5 and 3.2. If bounds are provided, the number of ranges must be equal to the number of problem variables.
Bounds can be included with the general constraints. For example, adding the inequalities 1.5≤x and x≤3.2 to the constraint set is equivalent to specifying x=1.5..3.2. Bounds are not required to be specified separately, though this usually leads to more efficient computation.
The problem variables are not assumed to be non-negative by default, but the assume=nonnegative option can be used to specify this. For more information, see the Optimization/Options help page.
Specify the initial values using the option initialpoint=p, where p is a list of realcons. The list must contain one value for each problem variable. For more information on the initialpoint option, see the Optimization/Options help page.
Maple returns the solution as a list containing the final minimum (or maximum) value and a point (the computed extremum). The point is a Vector containing the values of the problem variables unless the problem involves units in which case the point will be a list (see Optimization/General/Units).
with⁡Optimization
ImportMPS,Interactive,LPSolve,LSSolve,Maximize,Minimize,NLPSolve,QPSolve
Use simple procedures as input to the NLPSolve command.
p := proc(x) if x <= 0 then x^2+1; else sin(x)/x; end if; end proc;
p ≔ procxifx<=0thenx^2+1elsesin⁡x/xend ifend proc
NLPSolve⁡p,−5..30
−0.0424796169776126,23.5194525091898
Use operator form to solve a least-squares problem.
b1 := proc(x) x-1 end proc:
b2 := proc(x) x-7 end proc:
c1 := proc(x) -2*x-3 end proc:
c2 := proc(x) x-5 end proc:
LSSolve⁡b1,b2,c1,c2,1..10
9.00000000000000178,4.
Use operator form as input to the Maximize command.
Maximize⁡x,y↦3⋅x2+y,x,y↦x−2⋅y−2,x,y↦y2−x−3,initialpoint=5,5
241.024997396375710,8.898979485566363.44948974278318
See Also
Optimization
Optimization/InputForms
Optimization/Options
Optimization[LSSolve]
Download Help Document