FuncDesigner

A Python module for function design and automatic derivatives
Download

FuncDesigner Ranking & Summary

Advertisement

  • Rating:
  • License:
  • BSD License
  • Price:
  • FREE
  • Publisher Name:
  • Dmitrey Kroshko
  • Publisher web site:
  • http://openopt.org

FuncDesigner Tags


FuncDesigner Description

A Python module for function design and automatic derivatives FuncDesigner is a computer algebra system (CAS) with licensed unde the BSD license and and written in Python + NumPy, that makes it cross-platform (Linux, Windows, Mac OS etc). It enhances RAD abilities of Python language for developing scientific software, especially for numerical optimization and solving systems of non-linear equations.Key feature of the framework is automatic differentiation (AD) (not to be confused with Numerical differentiation via finite-differences derivatives approximation and symbolic differentiation provided by Maxima, SymPy etc). BTW, commercial tool TOMLAB / MAD for automatic differentiation costs over 4000$.See FuncDesigner AD usageExample:from FuncDesigner import *a, b, c = oovars('a', 'b', 'c')f1, f2 = sin(a) + cos(b) - log2(c) + sqrt(b), sum(c) + c * cosh(b) / arctan(a) + c * c + c / (a * c.size)f3 = f1*f2 + 2*a + sin(b) * (1+2*c.size + 3*f2.size)f = 2*a*b*c + f1*f2 + f3 + dot(a+c, b+c)point = {a:1, b:2, c:} # however, you'd better use numpy arrays instead of Python listsprint(f(point))print(f.D(point))print(f.D(point, a))print(f.D(point, ))print(f.D(point, fixedVars = ))Expected output:{a: array(), b: array(), c: array(, , ])}{b: array()}{b: array()} * You can use "for" cycle in FuncDesigner codeExample:from FuncDesigner import *a, b, c = oovars('a', 'b', 'c')f1, f2 = sin(a) + cos(b) - log2(c) + sqrt(b), sum(c) + c * cosh(b) / arctan(a) + c * c + c / (a * c.size)f3 = f1*f2 + 2*a + sin(b) * (1+2*c.size + 3*f2.size)F = sin(f2)*f3 + 1M = 15for i in range(M): F = 0.5*F + 0.4*f3*cos(f1+2*f2)point = {a:1, b:2, c:} # however, you'd better use numpy arrays instead of Python listsprint(F(point))print(F.D(point))print(F.D(point, a))print(F.D(point, ))print(F.D(point, fixedVars = )){a: array(), b: array(), c: array(, , ])}{b: array()}{b: array()} * If some your functions had been written on other languages (C, Fortran, etc), or are beyond FuncDesigner AD capabilities due to any other reason (has "for"/"while" loops, routines for solving systems of nonlinear, mb differential equations etc), you can define your own oofun with wrapper around the function, and the missing derivatives will be covered up by finite-differences derivatives approximation via DerApproximator. * FuncDesigner as well as DerApproximator was excluded from OpenOpt framework as independent Python module. OpenOpt can optimize FuncDesigner models with no needs to provide 1st derivatives.Example:from FuncDesigner import *from openopt import NLPa, b, c = oovars('a', 'b', 'c')f = sum(a*)**2+b**2+c**2startPoint = {a:, b:2, c:40} # however, you'd better use numpy arrays instead of Python listsp = NLP(f, startPoint)p.constraints = , a < 9, (c-2)**2 < 1, b < -1.02, c > 1.01, ((b + c * log10(a).sum() - 1) ** 2).eq(0)]r = p.solve('ralg')print r.xfExpected output:...objFunValue: 717.75631 (feasible, max constraint = 7.44605e-07){a: array(), b: array(), c: array()} Requirements: · Python · NumPy


FuncDesigner Related Software