Package: science-optimization
Optimization FrameworkThis is a framework for linear and non-linear optimization developed by ENACOM Group.It solves a problem in the form:min  f(x)

s.t. g(x) <= 0
     h(x)  = 0
     x_min <= x <= x_maxwherexis an n-dimensional vector,f(x)maps the n-dimensional space to the o-dimensional space,
withobeing the number of objectives.PrerequisitesWhat you need to be able to run:Python 3.6 +All requirements are in the filerequirements.txt.
To install all packages at once:$pipinstall-rrequirements.txtInstalling science-optimizationBuilding science-optimization requires the following software installed:Python 3Make sure that distutils is installed before continuing. For example in Debian GNU/Linux, disutils is included in the python3-dev package.PyBind11Note  that this is PyBind11, not PyBind.GNU C Compiler version >= 5.0To install the package in any environment:clone this repo$ pip install ./science-optimizationConventionsDevelopmentIn Python programming, it is a common practice to initialize "private" methods/attributes with an underscore
(e.g. _private_method(), _private_attribute). This framework follows this conventionAttributes sets and gets are implemented using the native@propertydecoratorAn abstract base class inherits fromabc.ABCMetaGoogle is the default Docstring formatA package must contain an__init__.pyfile with the package initializationPyCharm 2017+ is highly recommendedA detailed explanation of code development can be foundhereandhere.Tutorials on Python programming can be foundhere.OptimizationGiven thatnis the problem dimension andmis the number of points:A single point is anx1matrixMultiple points are anxmmatrixGradient is anxmmatrixHessian is anxnxmmatrixPackagesBuilderThis package is responsible for building an optimization problem. It was built based on theBuilder Design Patternand it has the following classes.OptimizationProblem(): the base class of every optimization problem.Attributes:objective:Objective()instanceconstraints:Contraints()instancevariables:Variables()instanceMethods:_build_problem(builder): receives aBuilderOptimizationProblem()instance, checks problem
consistency and sets attributes_check_consistency(variables, objectives, constraints): receives attributes and check problem
consistencyinfo(): prints to user the assembled problem__call__(): overloaded method that turns anOptimizationProbleminstance a callable function, that
evaluatesf, g, h, df, dg, dh, hf, hg, hhfor a given pointxBuilderOptimizationProblem(): abstract class responsible for defining the builder's methods of the
optimization problem.Abstract methods:build_objectives(): abstract method responsible for building the problem's objectivesbuild_constraints(): abstract method responsible for building the problem's constraintsbuild_variables(): abstract method responsible for building the problem's variablesObjective(): container class of objectives functions.Attributes:objective_functions: a list with all functions of the problem. Each function
is aFunctionComposite()instance.Methods:C(): return the matrix C of linear objectives coefficientsd(): return the vector d of linear objectives constantsContraints(): container class of constraints functions.Attributes:equality_contraints: a list with equality constraints functions. Each function
is aFunctionComposite()instance.inequality_contraints: a list with inequality constraints functions. Each function
is aFunctionComposite()instance.Methods:equality_contraints_feasibility(x): evaluates the feasibility ofxon these constraintsinequality_contraints_feasibility(x): evaluates the feasibility ofxon these constraintsA(): returns the matrixAof linear inequality constraints coefficientsb(): returns the vectorbof linear inequality constraints boundsAeq(): returns the matrixAeqof linear equality constraints coefficientsbeq(): returns the vectorbeqof linear equality constraints boundsVariables(): container class of the problem variables.Attributes:x_min: variables' lower boundsx_max: variables' upper boundsx_type: list with variables' type ('c': continuous or 'd': discrete)FunctionThis package has the definitions of a function. Is was base on theCompositedesign pattern and
contains the following classes:BaseFunction(): base class of every other class inside this package.Attributes:parameters: abstract attribute for functions parameters (e.g. coefficients)eps: precision for numerical calculationsMethods:eval(x): abstract method for the evaluation ofxgradient(x): numerical calculation of the Gradient ofxhessian(x): numerical calculation of the Hessian ofxdimension(): function dimensionnFunctionsComposite(): container class ofBaseFunction()'s children.Attributes:functions: a list of functionsMethods:eval(x): abstract method for the evaluation ofxinfunctionsgradient(x): numerical calculation of the Gradient ofxinfunctionshessian(x): numerical calculation of the Hessian ofxinfunctionsadd(f): adds functionftofunctionsremove(idx): removes elementfunctions[idx]clear(): removes all functions from listLinearFunction(): implements a function in the formf(x) = c'x + dAttributes:parameters: dictionary withcanddkeysMethods:eval(x): method for the evaluation ofxgradient(x): analytical calculation of the Gradient ofxhessian(x): analytical calculation of the Hessian ofxQuadraticFunction(): implements a function in the formf(x) = x'Qx + c'x + dAttributes:parameters: dictionary withQ,canddkeysMethods:eval(x): method for the evaluation ofxgradient(x): analytical calculation of the Gradient ofxhessian(x): analytical calculation of the Hessian ofxPolynomialFunction(): implements a polynomial functionAttributes:parameters: dictionary with exponentseandccoefficientsMethods:eval(x): method for the evaluation ofxgradient(x): analytical calculation of the Gradient ofxhessian(x): analytical calculation of the Hessian ofxProblemsThis package is responsible for creating the interface ofBuilderOptimizationProblem()for each optimization problem
instance. The classes must follow the format:Problem(BuilderOptimizationProblem): inherits from BuilderOptimizationProblemAttributes: necessary problem attributesMethods:build_objectives(): concrete method responsible for building the problem's objectivesbuild_constraints(): concrete method responsible for building the problem's constraintsbuild_variables(): concrete method responsible for building the problem's variablesThe classGeneric(BuilderOptimizationProblem)builds a generic optimization problem in the canonical
format defined at the beginning of this document. However, it also possible to implement customized
optimization problems inheriting fromBuilderOptimizationProblemclass, such asDietandKleeMinty.For linear programming, the problemMIPis a straightforward abstraction of a problem in the format:min  c'  @ x
    s.t. A   @ x <= b
         Aeq @ x == beq
         x_min  <= x <=  x_maxAlgorithmsThis package contains the implementations of the optimization algorithms. It is organized in sub-packages according
to algorithm's families. Each sub-package contains one abstract implementation of the algorithm's family, it is namedBaseAlgorithmFamily()BaseAlgorithms(): base class for everyBaseAlgorithmFamily()Attributes:eps: algorithms' numerical precisionMethods:optimize(): abstract method for the implementation coreThis framework currently supports the following optimization algorithms:Cutting-plane family:Ellipsoidal (Multiobjective)Decomposition :Nonlinear dual decompositionDerivative-free :Nelder-Mead simplex (constrained)Lagrange (constrained):Augmented lagrangian method (using Quasi Newton)Linear programming:Scipy simplex and interior-pointGLOP for LPCBC for MIPUnidimensional search:Enhanced golden sectionMultimodal golden sectionSearch direction family (unconstrained):Gradient methodModified Newton methodQuasi Newton methodSolversThis package contains the interface to optimization solvers implemented in the framework.Optimizer(): optimization for built-in methods, i.e.algorithms.Attributesoptimization_problem:OptimizationProblem()instancealgorithm: a concrete algorithm implementation instance (e.g.GradientAlgorithm())Methodssolve: implementsalgorithm.optimize()OptimizationResults(): container for optimization resultsAttributesx: the solution of the optimizationfx: function value at solution pointsucess: whether or not the solvers exited successfullymessage: description of the cause of terminationn_iterations: number of iterationsn_function_evaluations: number of function evaluationsMethodsinfo(): displays optimization results info.pareto_samplers package: used to find the pareto border of a multiobjective problem, the implemented
sampling strategies are:Lambda samplerEpsilon samplerNondominated samplerMu samplerExamplesThis package contains modules implementing examples of building and solving an optimization problem. It can also
be used for profiling via@profilingdecorator.ProfilingImplementation of the@profilingdecorator.