Giter VIP home page Giter VIP logo

2-wheels-1-arm's Introduction

Grenadingue.github.io

My curriculum vitæ

Dependencies

Install

npm install

Run

Regenerate & open web version

npm run start

Only regenerate web version

npm run regenerate

Only open local web version

npm run open

2-wheels-1-arm's People

Contributors

adrientotem avatar adrivig avatar grenadingue avatar pachakamakk avatar tomacf avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

2-wheels-1-arm's Issues

Implement algorithm logger

For WritableResultModel implement

std::ofstream &WritableResultModel::operator〈〈(std::ofstream &file, const WritableResultModel &)

Use WritableResultModel inside void BackupDataController::_workLoop() kind of like this

// result in a ResultModel *
WritableResultModel &json = *result;
std::ofstream file;
// ...
file << json;

Simulate the workability of WritableResultModel in the main()

You will need to add the following attributes in ResultModel in order to use them

class ResultModel
{
protected:
  int _iteration;
  int _theoreticalMaxScore;
  int _maxScore;
  double _averageScore;
  int _worstScore;
  // ...
}

Since theoreticalMaxScore will always has the same value, we will only write it once in the file. For that we will trick a bit. If theorethicalMaxScore is not -1, write only this value as json, if it is -1 write all the others.

Written data must be in the form

{
  "theoreticalMaxScore": 400,
  "results": [
    {
      "iteration": 0,
      "maxScore": 1,
      "averageScore": 0.5,
       "worstScore": 0
    },
    {
      "iteration": 1,
      "maxScore": 3,
      "averageScore": 1.5,
       "worstScore": 0
    }
  ]
}

Open file on Node.js side to check that the syntax is right.

Also, implement the empty methods

  ResultModel::ResultModel(const ResultModel &)
  ResultModel::ResultModel(const ResultModel *)
  ResultModel::ResultModel &operator=(const ResultModel &)
  ResultModel::ResultModel &operator=(const ResultModel *)

Remove

ResultModel::ResultModel()

And add the following

ResultModel::ResultModel(int theoreticalMaxScore)
ResultModel::ResultModel(int iteration, int maxScore, double averageScore, int worstScore)

Implement accurate input parameters

  • Review parameters passing from c++ MainController to GeneticAlgoController, WebServerBridge and BackupDataController
    • Create appropriate classes for passing parameters to each controller
    • Parse input parameters to fill previous structures

Design fixes

  • Put algorithm parameters legends beside forms
  • Add one more line of algorithm parameters
  • Graph size is hard coded for fullscreen, make it fit the window size
  • Put a pre-existant bootstrap style to the "Select a previous simulation" list
  • "Launch simulation" button
    • Replace the text on the button by "Display backup" when "Select a previous simulation" is selected
    • Still display "Launch simulation" when "Input the params you want" is selected
  • Replace
    • "Input the params you want" by "Configure algorithm launcher"
    • "Select a previous simulation" by "Select a simulation backup"

Setup D3.js library

Depends on #11

  • Make a working and reusable D3.js code snippet, theoretically able to work with the real-time and backup data controllers

Update README

Update README.md as build scripts in package.json have been updated

Set y axle focus on graph

  • Create a new socket.io event in webapp, set y axle, receiving as parameter an y max value
  • Set the y axle focus on the graph to be fixed to the given y max value

Why ?

The y max value is the theoretical maximum score, so it's to get a full vision over the score progression

Front-end fixes

Please make a commit for each point


  • Javascript check before emitting "start algo"

  • Check that all the fields from the algorithm launcher are filled before allow emitting "start algo" event

  • Update title

  • Add " - Genetic Algorithms" after "AI - Evolution programs"

  • Update legend on graph

  • Grow legend

  • Update line colors

  • Make line colors follow a color gradient pattern
  • Color pattern and line meaning must consistent for easy understanding

  • Add a field to the algo launcher

  • Add errorAcceptabilityRate

  • Pre-fill all fields of the algorithm launcher

  • Population size : 200
  • Population renewal rate : 0.33
  • Mutation rate : 0.01
  • Simulation cycles : 3
  • Vrep pool size : 4
  • Error acceptability rate : 0.07

Develop first algorithm implementation

Coding style

  • Protect file headers with #ifndef FOO_HPP_ # define FOO_HPP_ #endif // !FOO_HPP_
  • Preprocessor instructions are indented with a space after an #if, desindented after and #endif, like the previous # define
  • In a class, protected and private members name always start with an _ underscore
  • In a class Foo, for an attribute int _bar the getter/setter syntax will be
    • int bar() const
    • void setBar()
  • Use as much as possible initializer lists in constructors class Foo { Foo() : _bar(42) {} }
  • Skip a line before the : in an initializer list

Fitness

  • Create class Fitness
  • Implement public empty constructor and destructor in both .hpp and .cpp
  • Implement int _score in Fitness, initialize it at 0 at construction
  • Implement _score getter and setter
  • Create a private Fitness *_fitness in Individual
  • Initialize the pointer with a new Fitness in Individual constructors
  • Create a public Fitness &fitness() getter in Individual

Genome

  • Remove Genome templating in Genome.hpp
  • Remove public: typedef std::list<gene_t> genes_t;
  • Implement struct gene_t in Genome, like in 2w1a pseudo code (without fake and debug prints)
  • Replace genes_t _genes; by std::vector<gene_t> _genes;
  • Implement gene_t &operator[](int pos) and gene_t &operator[](unsigned int pos)

Genetic algorithm controller

Look at class World in World.hpp and World.cpp, GeneticAlgoController inherits from it

Implement methods (empty if needed), and attributes

class GeneticAlgoController {
  std::vector<Individual *> _population;

  // fitness
  void _rateIndividual(Individual &individual);
  void _sortPopulationByScoreDesc(); // via Fitness &Individual::fitness().score();

  // generate offspring
  std::vector<Individual *> *_generateOffspring();
  std::pair<Individual *, Individual *> _selectParents(); // pick two individuals for reproduction
  Individual *_itsSexTime(std::pair<Individual *, Individual *> &parents); // generate child from parents
  void _mutateChildGenome(Individual &child); // apply mutation probability
  void _insertChildrenInPopulation(std::vector<Individual *> *); // in _population

  // kill a part of the population
  void _harshLife();

  // current best solution
  Individual *_bestSolution(); // from Individual::fitness().score()
}

Keep in mind that the algorithm must always work, even if you need to simulate something you don't have. Put comments where there is this kind of code.

Implement the previous methods, except _rateIndividual(). You can get inspiration from the string finder algorithm pseudo code. Be smart while taking inspiration from this algorithm, implementation is different than 2w1a one.


Depends

#16 and #4

Implement accurate returned results

  • Emit result with WebServerBridge::Client in WebServerBridge with socket.io client
    • Send start event to web server (theoretical max score)
    • Send iteration results
    • Send solution found
  • Fill a ResultModel with real values in GeneticAlgoController::_algorithm()
  • Receive algo events in web server

Add third value for an iteration in graph

new_iteration socket.io event parameter is now

{ iteration: 0, maxScore: 0, averageScore: 0, worstScore: 0 }
  • Add a third line in the graph for worstScore
  • Review line colors to be visually logical

Choose programming language

We can choose over multiple programming languages. V-rep makes us able to make calls to its API via the regular and remote interfaces. Here is two lists of the available languages.

Regular API:

  • C/C++
  • Lua

Remote API:

  • Same as the regular API
  • Python
  • Java
  • Mathlab
  • Octave
  • Urbi

http://www.coppeliarobotics.com/helpFiles/en/apisOverview.htm


I think we can eliminate the Mathlab and Urbi possibilities (any objection?). This reducing the list to:

  • C/C++
  • Lua
  • Python
  • Java

  • We must select the solution offering the best efficience/laziness ratio
  • We must look at the differences between the regular and remote APIs, to see if the remote API is enough to realize the project
  • We must also look at the limitations imposed by the graphical and backup third-party libraries/softwares we'll choose ( #6 )

Choose graphical data rendering library/software

Data monitoring and rendering is mandatory for us to be able to graphically represent the genetic algorithm. We have two possible main paths to render these data:

  • Directly in the project code, using a graphical library
  • Outside the software, using a third party rendering software

Remove vrep pool instanciation in web server

  • Redo config file as before

  • Remove vrep spawning code

  • Put a list of vrep ports in the config file (we will start vrep manually)

  • Send those ports to the algorithm, like previously 42042,42043,42044

Launch a demo instance of vrep from web server

The web server actually instanciate a vrep pool for running algorithm simulations inside

Our need now is to be able to display the actual best indiviual, during the algorithm run

So we will need the web server to launch an instance of vrep alongside the others

Like the others vrep instances, we need to launch this one before the algorithm started. Unlike the others, this one will run with with a graphical interface

Once this instance is started, send the port as parameter to the algorithm, in a separate field vrepDemoPort

Setup server base

Create:

  • /config/base.json
  • /library/express.js
  • /controller/real-time.js
  • /controller/data-backup.js
  • /algorithm/cpp/
  • /algorithm/index.js
  • /server.js (main)
  • /routes.js
  • /view/index.html

Init:

  • A decent package.json for the project
  • The base config file with server needed data (eg. server.port, etc.) in /config/base.json
  • Express.js in /library/express.js
  • The http web server in /server.js
  • Root http route in /routes.js

Retrieve:

  • Empty controller modules realTime and dataBackup in /server.js
  • Empty /algorithm module in /controller/real-time.js

Select needed documentation to produce for the final defense

From project subject:

Let's see what we expect from you:

  • You have to design every single part of your program. No further information will be given other than those contained in this document or in the joined files.
  • We DO NOT expect a movement sequence ONLY! Trace your progress, show us how your little robot found his way! We will judge it too.
  • Every document you can provide in order to present your work is welcome: charts, design explanations, scientific papers, etc.
  • You must pay attention to every element of design, and expose your solution with accuracy.
  • You have to deal with your environment. You doubt that is accurate? You think you lack of information? Find a way to bypass your problems, and show us how you have done.

WARNING!
Remember to trace EVERY STEP of your work! We will ask your captain’s log during the assessment. Be scientific!

Implement accurate input parameters

Parameters :

  • Review parameters passing from webapp to web server
    • Consider genetic algorithm parameters
  • Review parameters passing from web server to node c++ addon
    • Consider parameters from webapp (algorithm)
    • Consider parameters from configuration file (socket.io port)
    • Consider parameters for algorithm logger (json file name)

Add contributing instructions

  • Branches
    • Creation rules
    • Usage rules
    • master rules
  • Commits
  • Message rules
  • Pull-requests
    • Submission
    • Validation
    • Merge with master
  • Workflow example
    • Resolving this issue

Design software logic

Depends on:

  • #4 Choose and describe a simple algorithm for the first implementation
  • #5 Select needed/useful data to render/backup

Design software architecture

Architecture depends on:

  • #2 Design software logic
  • #3 Choose a design pattern
  • #6 Choose graphical data rendering library/software
  • #9 Choose backup data format
  • #7 Choose programming language

Update READMEs

  • Add how to use project in /README.md
  • Move how to use sample code to /sample_code/README.md
  • Link readme files together

Launch a vrep pool before starting algorithm

  • Add vrep executable full path to the config file
  • In frontend, use a parameter field to specify a number of vrep instances to launch
  • Send the value of the previously created field to web server
  • In web server, launch the N vrep instances before starting the c++ algorithm
    • Launch a vrep instance on a generated port
      • Also specify in parameters the 2w1a.ttt scene
    • Add the generated port to a list
    • Catch vrep process close event
      • If process failed, remove the port from the list, an try to launch another instance with another port
    • When all vrep process have spawned
      • Concatenate the list of all the ports in a string like 4000,4001,4002
      • Put the created string in the algorithm parameters as vrepPool
      • Then the algorithm can be launched

Usefull: http://www.coppeliarobotics.com/helpFiles/en/commandLine.htm

Note: The scene path must be the full path

Make algorithm emitting real values

in

GeneticAlgoController::_emitTheoreticalMaxScore();
GeneticAlgoController::_emitNewResult();
GeneticAlgoController::_emitSolutionFound();

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.