root/PythonPackages/OpenOpt/openopt/oo.py

Revision 1382, 25.7 kB (checked in by dmitrey, 4 months ago)

add MOP to OO module

Line 
1 import os,sys
2 sys.path.append(os.getcwd()+os.sep+'kernel')
3
4 from LP import LP as CLP
5 from LCP import LCP as CLCP
6 from EIG import EIG as CEIG
7 from SDP import SDP as CSDP
8 from QP import QP as CQP
9 from MILP import MILP as CMILP
10 from NSP import NSP as CNSP
11 from NLP import NLP as CNLP
12 from MOP import MOP as CMOP
13 from MINLP import MINLP as CMINLP
14 from NLSP import NLSP as CNLSP
15 from NLLSP import NLLSP as CNLLSP
16 from GLP import GLP as CGLP
17 from SLE import SLE as CSLE
18 from LLSP import LLSP as CLLSP
19 from MMP import MMP as CMMP
20 from LLAVP import LLAVP as CLLAVP
21 from LUNP import LUNP as CLUNP
22 from SOCP import SOCP as CSOCP
23 from DFP import DFP as CDFP
24 from IP import IP as CIP
25 from ODE import ODE as CODE
26
27
28 def MILP(*args, **kwargs):
29     """
30     MILP: constructor for Mixed Integer Linear Problem assignment
31     f' x -> min
32     subjected to
33     lb <= x <= ub
34     A x <= b
35     Aeq x = beq
36     for all i from intVars: i-th coordinate of x is required to be integer
37     for all j from binVars: j-th coordinate of x is required to be from {0, 1}
38
39     Examples of valid calls:
40     p = MILP(f, <params as kwargs>)
41     p = MILP(f=objFunVector, <params as kwargs>)
42     p = MILP(f, A=A, intVars = myIntVars, Aeq=Aeq, b=b, beq=beq, lb=lb, ub=ub, binVars = binVars)
43     See also: /examples/milp_*.py
44
45     :Parameters:
46     - intVars : Python list of those coordinates that are required to be integers.
47     - binVars : Python list of those coordinates that are required to be binary.
48     all other input parameters are same to LP class constructor ones
49
50     :Returns:
51     OpenOpt MILP class instance
52
53     Notes
54     -----
55     Solving of MILPs is performed via
56     r = p.solve(string_name_of_solver)
57     or  p.maximize, p.minimize
58     r.xf - desired solution (NaNs if a problem occured)
59     r.ff - objFun value (<f,x_opt>) (NaN if a problem occured)
60     (see also other r fields)
61     Solvers available for now:
62     lpSolve (LGPL) - requires lpsolve + Python bindings installations (all mentioned is available in http://sourceforge.net/projects/lpsolve)
63     glpk (GPL 2) - requires glpk + CVXOPT v >= 1.0 installations (read OO MILP webpage for more details)
64     """
65     return CMILP(*args, **kwargs)
66
67 def LP(*args, **kwargs):
68     """
69     LP: constructor for Linear Problem assignment
70     f' x -> min
71     subjected to
72     lb <= x <= ub
73     A x <= b
74     Aeq x = beq
75
76     valid calls are:
77     p = LP(f, <params as kwargs>)
78     p = LP(f=objFunVector, <params as kwargs>)
79     p = LP(f, A=A, Aeq=Aeq, Awhole=Awhole, b=b, beq=beq, bwhole=bwhole, dwhole=dwhole, lb=lb, ub=ub)
80     See also: /examples/lp_*.py
81
82     :Parameters:
83     f: vector of length n
84     A: size m1 x n matrix, subjected to A * x <= b
85     Aeq: size m2 x n matrix, subjected to Aeq * x = beq
86     b, beq: corresponding vectors of lengthes m1, m2
87     lb, ub: vectors of length n, some coords may be +/- inf
88
89     :Returns:
90     OpenOpt LP class instance
91
92     Notes
93     -----
94     Solving of LPs is performed via
95     r = p.solve(string_name_of_solver)
96     or  p.maximize, p.minimize
97     r.xf - desired solution (NaNs if a problem occured)
98     r.ff - objFun value (<f,x_opt>) (NaN if a problem occured)
99     (see also other r fields)
100     Solvers available for now:
101     pclp (BSD) - premature but pure Python implementation with permissive license
102     lpSolve (LGPL) - requires lpsolve + Python bindings installations (all mentioned is available in http://sourceforge.net/projects/lpsolve)
103     cvxopt_lp (GPL) - requires CVXOPT (http://abel.ee.ucla.edu/cvxopt)
104     glpk(GPL2) - requires CVXOPT(http://abel.ee.ucla.edu/cvxopt) & glpk (www.gnu.org/software/glpk)
105     converter to NLP. Example: r = p.solve('nlp:ipopt')
106     """
107     return CLP(*args, **kwargs)
108
109 def LCP(*args, **kwargs):
110     """
111     LCP: constructor for Linear Complementarity Problem assignment
112     find w, z: w = Mz + q
113     
114     valid calls are:
115     p = LP(M, q, <params as kwargs>)
116     p = LP(M=M, q=q, <params as kwargs>)
117     See also: /examples/lcp_*.py
118
119     :Parameters:
120     M: numpy array of size n x n
121     q: vector of length n
122
123     :Returns:
124     OpenOpt LCP class instance
125
126     Notes
127     -----
128     Solving of LCPs is performed via
129     r = p.solve(string_name_of_solver)
130     r.xf - desired solution (1st n/2 coords are w, other n/2 coords are z)
131     r.ff - objFun value (max residual of Mz+q-w) (NaN if a problem occured)
132     (see also other r fields)
133     Solvers available for now:
134     lcpsolve (BSD)
135
136     """
137     return CLCP(*args, **kwargs)
138
139 def EIG(*args, **kwargs):
140     """
141     EIG: constructor for Eigenvalues Problem assignment
142     to solve standard eigenvalue problem:
143         find eigenvalues and eigenvectors of square matrix A:   
144             A x = lambda x
145     or general eigenvalue problem:
146         A x = lambda M x
147     
148     valid calls are:
149     p = EIG(M, q, <params as kwargs>)
150     p = EIG(M=M, q=q, <params as kwargs>)
151     See also: /examples/eig_*.py
152
153     :Parameters:
154     A, (optional) M: numpy array or scipy sparse matrix of size n x n
155
156     :Returns:
157     OpenOpt EIG class instance
158
159     Notes
160     -----
161     Solving of EIGs is performed via
162     r = p.solve(string_name_of_solver)
163     see http://openopt.org/EIG for more info
164     Solvers available for now:
165     arpack (license: BSD)
166
167     """
168     return CEIG(*args, **kwargs)
169
170 def SDP(*args, **kwargs):
171     """
172     SDP: constructor for SemiDefinite Problem assignment
173     f' x -> min
174     subjected to
175     lb <= x <= ub
176     A x <= b
177     Aeq x = beq
178     For all i = 0, ..., I: Sum [j = 0, ..., n-1] {S_i_j x_j} <= d_i (matrix componentwise inequality),
179     d_i are square matrices
180     S_i_j are square positive semidefinite matrices of size same to d_i
181     
182
183     valid calls are:
184     p = SDP(f, <params as kwargs>)
185     p = SDP(f=objFunVector, <params as kwargs>)
186     p = SDP(f, S=S, d=d, A=A, Aeq=Aeq, Awhole=Awhole, b=b, beq=beq, bwhole=bwhole, dwhole=dwhole, lb=lb, ub=ub)
187
188     See also: /examples/sdp_*.py
189
190     :Parameters:
191     f: vector of length n
192     S: Python dict of square matrices S[0, 0], S[0,1], ..., S[I,J]
193     S[i, j] are real symmetric positive-definite matrices
194     d: Python dict of square matrices d[0], ..., d[I]
195     A: size m1 x n matrix, subjected to A * x <= b
196     Aeq: size m2 x n matrix, subjected to Aeq * x = beq
197     b, beq: corresponding vectors of lengthes m1, m2
198     lb, ub: vectors of length n, some coords may be +/- inf
199
200     :Returns:
201     OpenOpt SDP class instance
202
203     Notes
204     -----
205     Solving of SDPs is performed via
206     r = p.solve(string_name_of_solver)
207     r.xf - desired solution (NaNs if a problem occured)
208     r.ff - objFun value (<f,x_opt>) (NaN if a problem occured)
209     (see also other r fields)
210     Solvers available for now:
211     cvxopt_sdp (LGPL) - requires CVXOPT (http://abel.ee.ucla.edu/cvxopt)
212     dsdp (GPL) - requires CVXOPT + DSDP installation, can't handle linear equality constraints Aeq x = beq
213     
214     """
215     return CSDP(*args, **kwargs)
216
217 def SOCP(*args, **kwargs):
218     """
219     SOCP: constructor for Second-Order Cone Problem assignment
220     f' x -> min
221     subjected to
222     lb <= x <= ub
223     Aeq x = beq
224     For all i = 0, ..., I: ||C_i x + d_i|| <= q_i x + s_i   
225
226     valid calls are:
227     p = SDP(f, <params as kwargs>)
228     p = SDP(f=objFunVector, <params as kwargs>)
229     p = SDP(f, S=S, d=d, A=A, Aeq=Aeq, Awhole=Awhole, b=b, beq=beq, bwhole=bwhole, dwhole=dwhole, lb=lb, ub=ub)
230
231     See also: /examples/sdp_*.py
232
233     :Parameters:
234     f: vector of length n
235     Aeq: size M x n matrix, subjected to Aeq * x = beq
236     beq: corresponding vector of length M
237     C: Python list of matrices C_i of shape (m_i, n)
238     d: Python list of vectors of length m_i
239     q: Python list of vectors of length n
240     s: Python list of numbers, len(s) = n
241     
242     lb, ub: vectors of length n, some coords may be +/- inf
243
244     :Returns:
245     OpenOpt SDP class instance
246
247     Notes
248     -----
249     Solving of SOCPs is performed via
250     r = p.solve(string_name_of_solver)
251     r.xf - desired solution (NaNs if a problem occured)
252     r.ff - objFun value (<f,x_opt>) (NaN if a problem occured)
253     (see also other r fields)
254     Solvers available for now:
255     cvxopt_socp (LGPL) - requires CVXOPT (http://abel.ee.ucla.edu/cvxopt)
256     
257     """
258     return CSOCP(*args, **kwargs)
259
260 def QP(*args, **kwargs):
261     """
262     QP: constructor for Quadratic Problem assignment
263     1/2 x' H x  + f' x -> min
264     subjected to
265     A x <= b
266     Aeq x = beq
267     lb <= x <= ub
268
269     Examples of valid calls:
270     p = QP(H, f, <params as kwargs>)
271     p = QP(numpy.ones((3,3)), f=numpy.array([1,2,4]), <params as kwargs>)
272     p = QP(f=range(8)+15, H = numpy.diag(numpy.ones(8)), <params as kwargs>)
273     p = QP(H, f, A=A, Aeq=Aeq, b=b, beq=beq, lb=lb, ub=ub, <other params as kwargs>)
274     See also: /examples/qp_*.py
275
276     INPUT:
277     H: size n x n matrix, symmetric, positive-definite
278     f: vector of length n
279     lb, ub: vectors of length n, some coords may be +/- inf
280     A: size m1 x n matrix, subjected to A * x <= b
281     Aeq: size m2 x n matrix, subjected to Aeq * x = beq
282     b, beq: vectors of lengths m1, m2
283     Alternatively to A/Aeq you can use Awhole matrix as it's described in LP documentation (or both A, Aeq, Awhole)
284     OUTPUT: OpenOpt QP class instance
285
286     Solving of QPs is performed via
287     r = p.solve(string_name_of_solver)
288     r.xf - desired solution (NaNs if a problem occured)
289     r.ff - objFun value (NaN if a problem occured)
290     (see also other r fields)
291     Solvers available for now:
292     cvxopt_qp (GPL) - requires CVXOPT (http://abel.ee.ucla.edu/cvxopt)
293     converter to NLP. Example: r = p.solve('nlp:ipopt')
294     """
295     return CQP(*args, **kwargs)
296
297 def NLP(*args, **kwargs):
298     """
299     NLP: constructor for general Non-Linear Problem assignment
300
301     f(x) -> min (or -> max)
302     subjected to
303     c(x) <= 0
304     h(x) = 0
305     A x <= b
306     Aeq x = beq
307     lb <= x <= ub
308
309     Examples of valid usage:
310     p = NLP(f, x0, <params as kwargs>)
311     p = NLP(f=objFun, x0 = myX0, <params as kwargs>)
312     p = NLP(f, x0, A=A, df = objFunGradient, Aeq=Aeq, b=b, beq=beq, lb=lb, ub=ub)
313     See also: /examples/nlp_*.py
314
315     INPUTS:
316     f: objFun
317     x0: start point, vector of length n
318
319     Optional:
320     name: problem name (string), is used in text & graphics output
321     df: user-supplied gradient of objective function
322     c, h - functions defining nonlinear equality/inequality constraints
323     dc, dh - functions defining 1st derivatives of non-linear constraints
324
325     A: size m1 x n matrix, subjected to A * x <= b
326     Aeq: size m2 x n matrix, subjected to Aeq * x = beq
327     b, beq: corresponding vectors of lengthes m1, m2
328     lb, ub: vectors of length n subjected to lb <= x <= ub constraints, may include +/- inf values
329
330     iprint = {10}: print text output every <iprint> iteration
331     goal = {'minimum'} | 'min' | 'maximum' | 'max' - minimize or maximize objective function
332     diffInt = {1e-7} : finite-difference gradient aproximation step, scalar or vector of length nVars
333     scale = {None} : scale factor, see /examples/badlyScaled.py for more details
334     stencil = {1}|2|3: finite-differences derivatives approximation stencil,
335     used by most of solvers (except scipy_cobyla) when no user-supplied for
336     objfun / nonline constraints derivatives are provided
337         1: (f(x+dx)-f(x))/dx (faster but less precize)
338         2: (f(x+dx)-f(x-dx))/(2*dx) (slower but more exact)
339         3: (-f(x+2*dx)+8*f(x+dx)-8*f(x-dx)+f(x-2*dx))/(12*dx) (even more slower, but even more exact)
340     check.df, check.dc, check.dh: if set to True, OpenOpt will check user-supplied gradients.
341     args (or args.f, args.c, args.h) - additional arguments to objFunc and non-linear constraints,
342         see /examples/userArgs.py for more details.
343
344     contol: max allowed residual in optim point
345     (for any constraint from problem constraints:
346     constraint(x_optim) < contol is required from solver)
347
348     stop criteria:
349     maxIter {400}
350     maxFunEvals {1e5}
351     maxCPUTime {inf}
352     maxTime {inf}
353     maxLineSearch {500}
354     fEnough {-inf for min problems, +inf for max problems}:
355         stop if objFunc vulue better than fEnough and all constraints less than contol
356     ftol {1e-6}: used in stop criterium || f[iter_k] - f[iter_k+1] || < ftol
357     xtol {1e-6}: used in stop criterium || x[iter_k] - x[iter_k+1] || < xtol
358     gtol {1e-6}: used in stop criteria || gradient(x[iter_k]) || < gtol
359
360     callback - user-defined callback function(s), see /examples/userCallback.py
361
362     Notes:
363     1) for more safety default values checking/reassigning (via print p.maxIter / prob.maxIter = 400) is recommended
364     (they may change in future OpenOpt versions and/or not updated in time in the documentation)
365     2) some solvers may ignore some of the stop criteria above and/or use their own ones
366     3) for NSP constructor ftol, xtol, gtol defaults may have other values
367
368     graphic options:
369     plot = {False} | True : plot figure (now implemented for UC problems only), requires matplotlib installed
370     color = {'blue'} | black | ... (any valid matplotlib color)
371     specifier = {'-'} | '--' | ':' | '-.' - plot specifier
372     show = {True} | False : call pylab.show() after solver finish or not
373     xlim {(nan, nan)}, ylim {(nan, nan)} - initial estimation for graphical output borders
374     (you can use for example p.xlim = (nan, 10) or p.ylim = [-8, 15] or p.xlim=[inf, 15], only real finite values will be taken into account)
375     for constrained problems ylim affects only 1st subplot
376     p.graphics.xlabel or p.xlabel = {'time'} | 'cputime' | 'iter' # desired graphic output units in x-axe, case-unsensetive
377
378
379     Note: some Python IDEs have problems with matplotlib!
380
381     Also, after assignment NLP instance you may modify prob fields inplace:
382     p.maxIter = 1000
383     p.df = lambda x: cos(x)
384
385     OUTPUT: OpenOpt NLP class instance
386
387     Solving of NLPs is performed via
388     r = p.solve(string_name_of_solver)
389     or  p.maximize, p.minimize
390     r.xf - desired solution (NaNs if a problem occured)
391     r.ff - objFun value (NaN if a problem occured)
392     (see also other fields, such as CPUTimeElapsed, TimeElapsed, isFeasible, iter etc, via dir(r))
393
394     Solvers available for now:
395     single-variable:
396         goldenSection, scipy_fminbound (latter is not recommended)
397         (both these solvers require finite lb-ub and ignore user-supplied gradient)
398     unconstrained:
399         scipy_bfgs, scipy_cg, scipy_ncg,
400         (these ones cannot handle user-provided gradient) scipy_powell and scipy_fmin
401         amsg2p - requires knowing fOpt (optimal value)
402     box-bounded:
403         scipy_lbfgsb, scipy_tnc - require scipy installed
404         bobyqa - doesn't use derivatives; requires http://openopt.org/nlopt installed
405         ptn, slmvm1, slmvm2 - require http://openopt.org/nlopt installed
406     all constraints:
407         ralg
408         ipopt (requires ipopt + pyipopt installed)
409         scipy_slsqp
410         scipy_cobyla (this one cannot handle user-supplied gradients)
411         lincher (requires CVXOPT QP solver),
412         gsubg - for large-scaled problems
413         algencan (ver. 2.0.3 or more recent, very powerful constrained solver, GPL,
414         requires ALGENCAN + Python interface installed,
415         see http://www.ime.usp.br/~egbirgin/tango/)
416         mma and auglag - require http://openopt.org/nlopt installed
417
418     """
419     return CNLP(*args, **kwargs)
420
421 def MINLP(*args, **kwargs):
422     """
423     MINLP: constructor for general Mixed-Integer Non-Linear Problem assignment
424     parameters and usage: same to NLP, + parameters
425     discreteVars: dictionary numberOfCoord <-> list (or tuple) of allowed values, eg
426         p.discreteVars = {0: [1, 2.5], 15: (3.1, 4), 150: [4,5, 6]}
427     discrtol (default 1e-5) - tolerance required for discrete constraints
428     available solvers:
429     branb (branch-and-bound) - translation of fminconset routine, requires non-default string parameter nlpSolver
430     """
431     return CMINLP(*args, **kwargs)
432
433 def NSP(*args, **kwargs):
434     """
435     Non-Smooth Problem constructor
436     Same usage as NLP (see help(NLP) and /examples/nsp_*.py), but default values of contol, xtol, ftol, diffInt may differ
437     Also, default finite-differences derivatives approximation stencil is 3 instead of 1 for NLP
438     Solvers available for now:
439         ralg - all constraints, medium-scaled (nVars = 1...1000), can handle user-provided gradient/subgradient
440         amsg2p - requires knowing fOpt (optimal value), medium-scaled (nVars = 1...1000), can handle user-provided gradient/subgradient
441         gsubg - for large-scaled problems
442         scipy_fmin - a Nelder-Mead simplex algorithm implementation, cannot handle constraints and derivatives
443         sbplx  -  A variant of Nelder-Mead algorithm; requires http://openopt.org/nlopt installed
444         ShorEllipsoid (unconstrained for now) - small-scale, nVars=1...10, requires r0: ||x0-x*||<=r0
445     """
446     return CNSP(*args, **kwargs)
447
448 def NLSP(*args, **kwargs):
449     """
450     Solving systems of n non-linear equations with n variables
451     Parameters and usage: same as NLP
452     (see help(NLP) and /examples/nlsp_*.py)
453     Solvers available for now:
454         scipy_fsolve (can handle df);
455         converter to NLP. Example: r = p.solve('nlp:ipopt');
456         nssolve (primarily for non-smooth and noisy funcs; can handle all types of constraints and 1st derivatives df,dc,dh; splitting equations to Python list or tuple is recommended to speedup calculations)
457     (these ones below are very unstable and can't use user-supplied gradient - at least, for scipy 0.6.0)
458         scipy_anderson
459         scipy_anderson2
460         scipy_broyden1
461         scipy_broyden2
462         scipy_broyden3
463         scipy_broyden_generalized
464     """
465     r = CNLSP(*args, **kwargs)
466     r.pWarn('''
467     OpenOpt NLSP class had been renamed to SNLE
468     (system of nonlinear equations), use "SNLE" instead of "NLSP"
469     ''')
470     return r
471    
472 def SNLE(*args, **kwargs):
473     """
474     Solving systems of n non-linear equations with n variables
475     Parameters and usage: same as NLP
476     (see help(NLP) and /examples/nlsp_*.py)
477     Solvers available for now:
478         scipy_fsolve (can handle df);
479         converter to NLP. Example: r = p.solve('nlp:ipopt');
480         nssolve (primarily for non-smooth and noisy funcs; can handle all types of constraints and 1st derivatives df,dc,dh; splitting equations to Python list or tuple is recommended to speedup calculations)
481     (these ones below are very unstable and can't use user-supplied gradient - at least, for scipy 0.6.0)
482         scipy_anderson
483         scipy_anderson2
484         scipy_broyden1
485         scipy_broyden2
486         scipy_broyden3
487         scipy_broyden_generalized
488     """
489     return CNLSP(*args, **kwargs)
490
491 def NLLSP(*args, **kwargs):
492     """
493     Given set of non-linear equations
494         f1(x)=0, f2(x)=0, ... fm(x)=0
495     search for x: f1(x, <optional params>)^2 + ,,, + fm(x, <optional params>)^2 -> min
496
497     Parameters and usage: same as NLP
498     (see help(openopt.NLP) and /examples/nllsp_*.py)
499     Solvers available for now:
500         scipy_leastsq (requires scipy installed)
501         converter to NLP. Example: r = p.solve('nlp:ralg')
502     """
503     return CNLLSP(*args, **kwargs)
504    
505 def MOP(*args, **kwargs):
506     '''
507     Multiobjective optimization
508     Search for weak or strong Pareto front
509     
510     Solvers available for now:
511         interalg (http://openopt.org/interalg)
512     '''
513     return CMOP(*args, **kwargs)
514
515 def IP(*args, **kwargs):
516     """
517     Integrate a function f: R^n -> R over a given domain lb_i <= x_i <= ub_i
518     """
519     return CIP(*args, **kwargs)
520
521 def ODE(*args, **kwargs):
522     """
523     Solve ODE dy/dt = f(y,t), y(0) = y0
524     """
525     return CODE(*args, **kwargs)
526
527 def SLE(*args, **kwargs):
528     """
529     SLE: constructor for system of linear equations C*x = d assignment
530     
531     Examples of valid usage:
532     p = SLE(C, d, <params as kwargs>)
533     p = SLE(C=C, d=d, <params as kwargs>)
534     """
535     return CSLE(*args, **kwargs)
536
537
538 def DFP(*args, **kwargs):
539     """
540     Data Fit Problem constructor
541     Search for x: Sum_i || F(x, X_i) - Y_i ||^2 -> min
542     subjected to
543     c(x) <= 0
544     h(x) = 0
545     A x <= b
546     Aeq x = beq
547     lb <= x <= ub
548     
549     Some examples of valid usage:
550     p = NLP(f, x0, X, Y, <params as kwargs>)
551     p = NLP(f=objFun, x0 = my_x0, X = my_X, Y=my_Y, <params as kwargs>)
552     p = NLP(f, x0, X, Y, A=A, Aeq=Aeq, b=b, beq=beq, lb=lb, ub=ub, <params as kwargs>)
553     Parameters and usage: same as NLP, see help(openopt.NLP)
554     See also: /examples/dfp_*.py
555         
556     Solvers available for now:
557         converter to NLP. Example: r = p.solve('nlp:ralg')
558     """
559     return CDFP(*args, **kwargs)
560
561
562 def GLP(*args, **kwargs):
563     """
564     GLP: constructor for general GLobal Problem
565     search for global optimum of general non-linear (maybe discontinious) function
566     f(x) -> min/max
567     subjected to
568     lb <= x <= ub
569     Ax <= b
570     c(x) <= 0
571     
572     usage:
573     p = GLP(f, <params as kwargs>)
574     
575     Solving of NLPs is performed via
576     r = p.solve(string_name_of_solver)
577     or  p.maximize, p.minimize
578     
579     Parameters and usage: same as NLP  (see help(NLP) and /examples/glp_*.py)
580     One more stop criterion is maxNonSuccess (default: 15)
581     See also: /examples/glp_*.py
582
583     Solvers available:
584         galileo - a GA-based solver by Donald Goodman, requires finite lb <= x <= ub
585         pswarm (requires PSwarm installed), license: BSD, can handle Ax<=b, requires finite search area
586         de (this is temporary name, will be changed till next OO release v. 0.22), license: BSD, requires finite lb <= x <= ub, can handle Ax<=b, c(x) <= 0. The solver is based on differential evolution and made by Stepan Hlushak.
587         stogo and mlsl - can use derivatives; require http://openopt.org/nlopt installed
588         isres - can handle any constraints; requires http://openopt.org/nlopt installed
589         interalg - exact optimum wrt required tolerance, see http://openopt.org/interalg for details
590     """
591     return CGLP(*args, **kwargs)
592
593
594 def LLSP(*args, **kwargs):
595     """
596     LLSP: constructor for Linear Least Squares Problem assignment
597     0.5*||C*x-d||^2 + 0.5*damp*||x-X||^2 + <f,x> -> min
598
599     subjected to:
600     lb <= x <= ub
601
602     Examples of valid calls:
603     p = LLSP(C, d, <params as kwargs>)
604     p = LLSP(C=my_C, d=my_d, <params as kwargs>)
605
606     p = LLSP(C, d, lb=lb, ub=ub)
607
608     See also: /examples/llsp_*.py
609
610     :Parameters:
611     C - float m x n numpy.ndarray, numpy.matrix or Python list of lists
612     d - float array of length m (numpy.ndarray, numpy.matrix, Python list or tuple)
613     damp - non-negative float number
614     X - float array of length n (by default all-zeros)
615     f - float array of length n (by default all-zeros)
616     lb, ub - float arrays of length n (numpy.ndarray, numpy.matrix, Python list or tuple)
617
618     :Returns:
619     OpenOpt LLSP class instance
620
621     Notes
622     -----
623     Solving of LLSPs is performed via
624     r = p.solve(string_name_of_solver)
625     r.xf - desired solution (NaNs if a problem occured)
626     r.ff - objFun value (NaN if a problem occured)
627     (see also other r fields)
628     Solvers available for now:
629     lsqr (license: GPL) - most efficient, can hanlde scipy.sparse matrices,
630         user-supplied or generated by FuncDesigner models automatically
631     lapack_dgelss (license: BSD) - slow but stable, requires scipy; unconstrained
632     lapack_sgelss (license: BSD) - single precesion, requires scipy; unconstrained
633     bvls (license: BSD) - requires installation from OO LLSP webpage, can handle lb, ub
634     converter to nlp. Example: r = p.solve('nlp:ralg', plot=1, iprint =15, <...>)
635     """
636     return CLLSP(*args, **kwargs)
637
638 def MMP(*args, **kwargs):
639     """
640     MMP: constructor for Mini-Max Problem
641     search for minimum of max(func0(x), func1(x), ... funcN(x))
642     See also: /examples/mmp_*.py
643
644     Parameters and usage: same as NLP  (see help(NLP) and /examples/mmp_*.py)
645     Solvers available:
646         nsmm (currently unconstrained, NonSmooth-based MiniMax, uses NSP ralg solver)
647     """
648     return CMMP(*args, **kwargs)
649
650 def LLAVP(*args, **kwargs):
651     """
652    LLAVP : constructor for Linear Least Absolute Value Problem assignment
653     ||C * x - d||_1  + damp*||x-X||_1-> min
654
655     subjected to:
656     lb <= x <= ub
657
658     Examples of valid calls:
659     p = LLAVP(C, d, <params as kwargs>)
660     p = LLAVP(C=my_C, d=my_d, <params as kwargs>)
661
662     p = LLAVP(C, d, lb=lb, ub=ub)
663
664     See also: /examples/llavp_*.py
665
666     :Parameters:
667     C - float m x n numpy.ndarray, numpy.matrix or Python list of lists
668     d - float array of length m (numpy.ndarray, numpy.matrix, Python list or tuple)
669     damp - non-negative float number
670     X - float array of length n (by default all-zeros)
671     lb, ub - float arrays of length n (numpy.ndarray, numpy.matrix, Python list or tuple)
672
673     :Returns:
674     OpenOpt LLAVP class instance
675
676     Notes
677     -----
678     Solving of LLAVPs is performed via
679     r = p.solve(string_name_of_solver)
680     r.xf - desired solution (NaNs if a problem occured)
681     r.ff - objFun value (NaN if a problem occured)
682     (see also other r fields)
683     Solvers available for now:
684     nsp:<NSP_solver_name> - converter llavp2nsp. Example: r = p.solve('nsp:ralg', plot=1, iprint =15, <...>)
685     """
686     return CLLAVP(*args, **kwargs)
687
688
689 def LUNP(*args, **kwargs):
690     """
691    LUNP : constructor for Linear Uniform Norm Problem assignment
692     || C * x - d ||_inf (that is max | C * x - d |)  -> min
693
694     subjected to:
695     lb <= x <= ub
696     A x <= b
697     Aeq x = beq
698
699     Examples of valid calls:
700     p = LUNP(C, d, <params as kwargs>)
701     p = LUNP(C=my_C, d=my_d, <params as kwargs>)
702
703     p = LUNP(C, d, lb=lb, ub=ub, A = A, b = b, Aeq = Aeq, beq=beq, ...)
704
705     See also: /examples/lunp_*.py
706
707     :Parameters:
708     C - float m x n numpy.ndarray, numpy.matrix or Python list of lists
709     d - float array of length m (numpy.ndarray, numpy.matrix, Python list or tuple)
710     damp - non-negative float number
711     lb, ub - float arrays of length n (numpy.ndarray, numpy.matrix, Python list or tuple)
712
713     :Returns:
714     OpenOpt LUNP class instance
715
716     Notes
717     -----
718     Solving of LUNPs is performed via
719     r = p.solve(string_name_of_solver)
720     r.xf - desired solution (NaNs if a problem occured)
721     r.ff - objFun value (NaN if a problem occured)
722     (see also other r fields)
723     Solvers available for now:
724     lp:<LP_solver_name> - converter lunp2lp. Example: r = p.solve('lp:lpSolve', <...>)
725     """
726     return CLUNP(*args, **kwargs)
Note: See TracBrowser for help on using the browser.