Giter VIP home page Giter VIP logo

optimizer's Introduction

Optimizer

A optimizer framework written in my spare time.

Example

opt::Variable x = opt::AddVariable("x");
opt::Constant e = 2.71828_const;
opt::Expression expr = (x^4)*(e^-x);

To evaluate expression

// it will use the current value of variables
cout<<expr.eval()<<endl;

Pack expression into function(aka define function)

// build f(x)
auto f = opt::MakeFunction(expr, x);
cout<<f(1.0)<<endl;

Constant literal

opt::Constant pi = 3.1415926_const;

Build

You must install numpy and matplotlib first to draw graph. For some unknown reason, I cannot get numpy work in python_d. Thus, debug build using VC++ may not run correctly. However, mingw and release mode works perfectly. Note that if you are using mingw, you might need to modify pyconfig.h

pip install numpy matplotlib

mkdir build && cd build && cmake .. -G "Visual Studio 15 2017 Win64" -DENABLE_PLOT=1
cmake --build . --config Release

Remove this line in pyconfig.h

#define hypot _hypot

Homework Report

problem 1

Because of the natural of the two search algorithm, Golden and fib search failed to find correct minima within given [a, b] interval.

>p1.exe
9.99999
10

result

problem 2 & 3

I combined univaridate algorithm(cyclic coordinate) and Powell's method with golden search. Since there are two minima in the objective function, I called both function twice with different initial points.

>p2.exe
Univaridate method:
-1.00043 -0.501071
1.00043 0.501068
Powell's method:
-1 -0.500003
1 0.500003

result

optimizer's People

Contributors

tim37021 avatar

Stargazers

Yu-Hua Chen avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.