Git Product home page Git Product logo

chasedreamer / dpsolver2d Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jetcha/dpsolver2d

0.0 1.0 0.0 2.93 MB

This is a master's graduation project where a novel Dynamic Programming (DP) based algorithm that used to minimize the battery consumption when driving electric vehicles is developed. The project is coded in C and compiled into S-function which can be used in Matlab/Simulink.

C++ 0.26% C 64.33% MATLAB 10.82% Makefile 18.26% CMake 6.34%

dpsolver2d's Introduction

DPSolver2D

Software Information:

Hardware Information (that used to evaluate the solver):

  • CPU: i7-8550U
  • RAM: 16GB
  • System type: 64-bit Winddows 10 operating system

File Explanations:

  • ./MatlabFiles
    • /createSfunc.m: Integrate the C function that contains the DP algorithm (MagicBox) into a Simulink model
    • /inputSolver.m: Input parameters, including model parameters and constraints, and an example scenario.
    • /showResult.m: Figures of the generated solutions.
    • /ModelSolver.slx: Simulink model of the DP solver
  • ./inc (header files)
  • ./src (source files)
    • /SolverStruct.h: Public structures used in the entire program.
    • /SolverAlgorithm.h/c: The main DP algorithm - function MagicBox connects everything.
    • /MathFunction.h/c: General mathematical functions (interpolation, sorting, etc.).
    • /SystemDynamics.h/c: System dynamics calculation.
    • /BoundaryLine.h/c: Boundary line calculation for the vechile speed.
    • /AdaptiveGrid.h/c: Generate state boxes for the adaptive state grid method.
    • /PrintResult.h/c (Not used): Record the output results into a txt file.
  • ./main.c: It is only used when running the codes on the C platform.

Example of using this solver

  1. Run createSfunc.m to compile the C codes into a S-function.
  2. Run inputSolver.m to set the input parameters and the input scenario.
  3. Run ModelSolver.slx to generate the solutions.
  4. Run showResult.m to see the results.

Important Notes:

  • The S-function has to be recompiled when the following parameter(s) is(are) changed:
    • Grid sizes: Nv, Nf, Nt, Nq (in inputSolver.m) / NV, NF, NT, NQ (in SolverStruct.c).
    • Length of horizon: Nhrz (in inputSolver.m)/ HORIZON (in SolverStruct.c)
    • Number of iterations: NUM_IDP (in SolverStruct.c)
    • Shrinking rate: GAMMA (in SolverStruct.c)
  • The parameters of the Grid sizes and the Length of horizon need to be kept the same in inputSolver.m and SolverStruct.c.
  • The boundary line calculation highly depends on the model equations, so it may not be easy to modify this part when the models are very different. It can be turned off by using '#define NOBOUND' in SolverStruct.c.
  • To the best of my knowledge, the C codes does not work with Visual Studio compiler due to the use of Variable Length Array (VLA).

dpsolver2d's People

Watchers

 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.