Git Product home page Git Product logo

q-learning-in-matlab's Introduction

Q学习的 Matlab 实现

本项目是基于迷宫环境. 与最短路径算法不同, Q学习算法使agent能够通过与环境交互(采取四个方向的动作), 计算从给定的起点到固定的终点的最短路径.

文件结构

  1. readMaze.m: 读取迷宫数据, 目前存储为矩阵的形式
  2. q_learning.m: Q学习的核心算法
  3. plotMaze.m: 绘制平均路径, 地图和各个点的最佳方向
  4. actions.m: 定义动作空间
  5. plotQ.m: 单独保存某一次迭代的Q矩阵图像, 默认保存为目录下的images文件夹
  6. main.m: 执行主要功能

说明

如果需要修改起始点, 并绘制相关的路径, 可以在main.m运行完q_learning函数之后, 修改start并运行

start = [2,3];
plotMaze(OM, Q, HA, HP, start, dest, seed, gamma, alpha,epsilon,lambda);

代码即可绘制其他起点的图像.

结果

  1. 输出的Q值矩阵(迭代1000次):

  1. 各个状态的采取的最优的行为:

  1. 最优的路径:

  1. 平均的回报:

需求

基于 Matlab 2019a 开发. 需要使用部分函数进行绘图:

函数 Matlab版本的最低需求
heatmap Matlab 2017a
strings Matlab 2016b

q-learning-in-matlab's People

Contributors

ddayzzz 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.