Skip to content

Some method of solving nonlinear programming problems, including unconstrained optimization problems and constrained optimization problems

License

Notifications You must be signed in to change notification settings

HolyDDL/Nonlinear_Programming

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nonlinear Programming

This project included three parts:

  1. One-dimensional search methodone(see as dimsearch.py)
  2. Method of unconstrained optimization problems(see as ucoptim.py)
  3. Method of constrained optimization problems(see as coptim.py)

Part 1: One-dimensional Search

  • included 2 methods: GoldenSection Method(0.618 Method), NewtonIteration Method

  • How to use it:

    1. Define a object function that should be minimized
    2. Call method function to solve it
  • DEMO

      from onedimsearch import *
      # define a object function
      def fun(t):
          return np.arctan(t)*t - 0.5*np.log(t*t + 1)
      # call method function
      print(NewtonIter(fun,1))
      print(GoldenSection(fun, -1,1))

Part 2: Unconstrained optimization problems

  • include 2 methods: SteepestDescent Method, ConjugateGradient Method

  • How to use it:

    1. Define a object function that should be minimized
    2. Call method function to solve it
  • DEMO

      from ucoptim import *
      # define a object function
      def fun(x):
          return x[0]**2 + 25*x[1]**2
      # call method function
      print(ConjugateGradient(fun, [32,2],method='FR'))
      print(SteepestDescent(fun, [1,2]))

part 3: Constrained optimization problems

  • include 2 method: ExtenalPenaltyFunction Method(including 3 methods to solve: PSO Method, ConjugateGradient Method, SteepestDescent Method), InternalPenaltyFunction Method(Not be ready yet)

  • How to use it:

    1. Define a object function that should be minimized and constraints
    2. Instantiate Extenal/Internal class
    3. Use class methods to solve it
  • DEMO

      from coptim import *
      # define object function
        def ori_objfun(x):
          x = np.array(x)
          value = 0.0
          for each in x:
              value += each**2
          return value
      # define inequal constraint function
      def inequal(x):
          x = np.array(x)
          value = 0.0
          for each in x:
              value = 1-each
          return value
      # use extenal class to solve
      pf = ExtenalPenaltyFunction(ori_objfun, [inequal],[])
      # use extenal.PSO method to solve
      solution, minvalue = pf.PSO_method(3, [[5], [6], [7]], np.random.rand(3,1), [1,1,1])
      print(solution)
      # use extenal.SteepestDescent method to solve
      # print(pf.SteepestDescent_method([3]))

About

Some method of solving nonlinear programming problems, including unconstrained optimization problems and constrained optimization problems

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages