GithubHelp home page GithubHelp logo

optimizer's Introduction

Optimizer

C++ solutions to optimization problems

About

The goal is to build an Optimization library for C++ which can provide solutions for single variable and multi-variable optimization, constrained and unconstrained problems. The users should be able to select the algorithm to be used and also access any intermediate data which is obtained whilst running the algorithm.

We want the contributors to learn how C++ libraries work and also learn some mathematics. Some minimal efforts are required for each good PR. Unlike other repositories hosted for Hacktoberfest, we want to create a fully utilizable product for developers and researchers over the months of October and beyond. If you wish to be a part of this we promise you that your efforts would bring over a good impact to everyone who will be utlizing this product. Best of Luck!

This repository is also hosted as a part of the Hacktoberfest. Register yourself here and submit 5 PRs to win a free T-shirt. This repository is for you to learn the github workflow, understand the community and get started with Open Source.

Watch the hacktoberfest teaser here.

Understanding the Repository

  • src contains all the code
  • Theory contains all the algorithms we need to implement
  • Features has information about current features as well as features required. New Contributors head here!

How to get this working?

For MAC/ Linux users :

  • Fork and then clone this repository from your fork
  • Install Eigen if you haven't already. Follow the instructions given here
    • Once you have downloaded the zip file from the link, extract it
    • Inside the extracted folder there will be a folder called Eigen
    • Cut and paste that into your /usr/local/include
    • If you have done brew install Eigen (or the equivalent on Linux), you can check your usr/local/include and open the eigen3 folder and move the Eigen folder here outside to usr/local/include(If this folder already has Eigen then you may skip this step).
    • Go to the Tests folder and compile and run test.cpp. If there is no error then you have succesfully installed Eigen, if not then you may get something like Eigen/Dense: No such file or directory. Revisit the previous steps and see if you have screwed up somewhere.
  • Inside test.cpp you can see the line #include "../Optimizer/optimizer" on top. This is a specific link to the Optmizer header file. You can see that if you move test.cpp somewhere outside this folder, it will not work.
  • To make sure that any .cpp file you use can include the Optmizer library by adding the line : #include <Optimizer/optimizer> you need to move the Optmizer folder in this repository into your usr/local/include. Once that is done check if it is working by moving test.cpp to some other arbitrary folder and changing this : #include "../Optimizer/optimizer" to this : #include <Optimizer/optimizer>
  • In case there are any errors, then make sure you report them as issues. Also before you report them, do check if you are using C++11. Mac OS g++ compilers use an older version of C++. You may have to compile the code like this : g++ test.cpp -o test -std=c++11

For Windows users :

  • You will have to move the optmizer.h and grad.h files to wherever you want
  • In your .cpp file you will have to add a #include "*path to Optimizer.h*"
  • Eigen you can install using the same steps for MAC/Linux

Key concepts

If you are pursuing engineering/ will be pursuing engineering/ have already pursued engineering, then this should be very easy for you to grasp. Without going too much into the mathematics you can easily code up the algorithms if you wish. But as a rule of thumb familiarity with these concepts would be helpful :

  • Basic C++
  • Basic Calculus
  • Linear Algebra
  • Polynomials and Polynomial Systems
  • Linear Programming
  • Quadratic Programming

DON'T BE INTIMIDATED! YOU DON'T HAVE TO STUDY ALL THIS! Read on to get started ...

How to Contribute

  • Read this README completely.
  • Checkout Features and Issues
  • Choose one which interests you, if it's already an Issue then add a comment claiming it. Else create a new issue.
  • Read the respective section from Theory to understand how to get the code right
  • Add the code and submit the PR by following the github workflow which you can find here

Your first PR!

Go and add your name to the contributors.md file.

Important

optimizer's People

Contributors

alsd4git avatar ananthavijay avatar bittukumarray avatar captain-darko avatar champagnepappi avatar claire-lovisa avatar debodirno avatar dependabot[bot] avatar elschilling avatar felicia-goh avatar kembolino avatar kiranbzenith avatar kojiadrianojr avatar krupalraj avatar madoxen avatar nileshpatra avatar pablo0910 avatar parammittal16 avatar pokinawa avatar quinny avatar samarthkathal avatar srinathkp avatar sudz123 avatar tulikavijay avatar vinnya3 avatar yashbhutoria avatar zatinme avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

optimizer's Issues

Implement exhaustive search

Make the necessary changes in Optimizer.h. Refer to K. deb. pg.46 It is a very easy while loop with some conditions. Comment code properly and follow similar nomenclature to the rest of the file.

Edit README in features

We are going to add two new features , so After the Multi-variable Optimization list in the README add:

  • Constrained Optimization Algorithms
    • Penalty Function Method
    • Method of Multipliers

Need documentation

  • Create a new folder in home which will hold the docs website
  • Add examples and create a documentation webpage, with html, css javascript files inside this folder

You can take reference from test.cpp
The site could look like the Eigen documentation here

Add test for Newton's method in test.cpp

Newton's method has been implemented by me in optimizer.h but we need a test to check if it works. You can use the sum-squares function as used in the DFP test

Change README.md

Can someone add a section about how libraries, header files etc work. What type of library is this and what are the differences between various types of libraries? Do not add all the content here. What you can do is provide relevant links.

Create function skeletons for the features

-Go to Features
-Check which have not been implemented
-Go to Optimizer.h
-Create a function by that respective algorithm name(An empty function with no code)
-Make sure the input and output parameters are correct
-Make a PR

Add more tests

I have added a Questions.pdf file in Tests folder. We need to implement all those functions in test.cpp and call them with multi-variable optimization algorithms and see if they are able to converge to the optima.

Need to add macros

In util.h we have included fstream and vector without std predefined macros. We need to add them.

Debug MultiplierConstrained method

Run test.cpp to see that the optimum point is not reached. For correct answer, refer K. Deb pg 166. Our answer should be close to this ideally.

Rename functions

In test.cpp rename :

  • func2 to SumSquares
  • func3 to Matyas

wherever necessary.

Use switch case in optimizer.h

The function SVOptimize has two strings as inputs. These are not being used. One string is supposed to decide which bracketing method is to be used and the other is for which unidirectional search is to be used. Currently there are only 1 bracketing and one unidirectional searches, but we will be adding more.

Change README.md in features

As you can see, Newton Raphson method has been implemented in optimizer.h. Could someone add the "(Implemented)" tag to the features.md file?

Update Readme in Features

The variable metric method is also called the DFP method. Add this in brackets in the README and also add an implemented tag.

Add basic printing function in util.h

util.h has two unimplemented functions in the class Optimum

  • SaveAsTxt()
  • SaveAsCsv()

On being called these should respectively create a txt/csv file. These files should have each line storing data from one row of Eigen::MatrixXd path. Should be fairly easy.

Implement a class to change return type of Multi-Variable Optimization Algorithms

This is a tricky one and would need some time. Basically we need to change the return type from a point to a class which contains:

  • All the points which the algorithm went through to reach here.
  • The termination criteria
  • The gradient values on all these points ( not sure about this )
  • The point itself
  • Number of iterations
  • Number of function evaluations

Basically an overview of the path taken to reach the optimum point. This class should also contain a method which can save to a text file the points such that a third party application can plot it.

The implementation of this is open to suggestions.

Add unit tests infrastructure

What do you think of adding an Unit tests infrastructure?

Currently, the tests in Tests/main.cpp have no explicit checks (I guess you look at the results "by eye"). If there is an unit tests infra, it would be way easier for developers to check they didn't mess up with an already working algorithm, add new test cases, etc...

We could use google tests to do it (https://github.com/google/googletest). The good news is that the licenses are compatible.

@sudz123 , please let me know if you like the idea.

Add tag

DFP or Variable metric method has been implemented. Go to features and add the (Implemented) tag.

Remove Bug in Penalty Function Method

I have made a function template PenaltyConstrained in optimizer.h . For now lets keep it simple and use only the given input parameters, hard code the multi-variable optimization algorithm which is to be used and any other parameters you need to call sub-functions; Checkout K. Deb pg: 154.

Links in Readme

There are a lot of references to files and directories in the readme. Eg src
It would be great if we have links to these.

Implement Method of Multipliers in Constrained Optimization

I have made a function template MultiplierConstrained in optimizer.h . For now lets keep it simple and use only the given input parameters, hard code the multi-variable optimization algorithm which is to be used and any other parameters you need to call sub-functions; Checkout K. Deb pg: 162.

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.