behavior planning——14.implement a cost function in C++
n most situations, a single cost function will not be sufficient to produce complex vehicle behavior. In this quiz, we'd like you to implement one more cost function in C++. We will use these two C++ cost functions later in the lesson. The goal with this quiz is to create a cost function that would make the vehicle drive in the fastest possible lane, given several behavior options. We will provide the following four inputs to the function:
- Target speed: Currently set as 10 (unitless), the speed at which you would like the vehicle to travel.
- Intended lane: the intended lane for the given behavior. For PLCR, PLCL, LCR, and LCL, this would be the one lane over from the current lane.
- Final lane: the immediate resulting lane of the given behavior. For LCR and LCL, this would be one lane over.
- A vector of lane speeds, based on traffic in that lane: {6, 7, 8, 9}.
Your task in the implementation will be to create a cost function that satisifes:
- The cost decreases as both intended lane and final lane are higher speed lanes.
- The cost function provides different costs for each possible behavior: KL, PLCR/PLCL, LCR/LCL.
- The values produced by the cost function are in the range 0 to 1.
You can implement your solution in cost.cpp below.

cost.cpp
float inefficiency_cost (int target_speed, int intended_lane,int final_lane, vector<int> lane_speeds)
{
float speed_intended=lane_speeds[intended_lane];
float speed_final=lane_speeds[final_lane];
float cost=(2.0*target_speed-speed_intended-speed_final)/target_speed;
return cost;
}
behavior planning——14.implement a cost function in C++的更多相关文章
- behavior planning——13. implement a cost function in C++
In the previous quizzes, you designed a cost function to choose a lane when trying to reach a goal i ...
- behavior planning——11 create a cost function speed penalty
A key part of getting transitions to happen when we want them to is the design of reasonable cost ...
- behavior planning——15.cost function design weightTweaking
Designing cost functions is difficult and getting them all to cooperate to produce reasionable vehic ...
- behavior planning——12.example cost funtion -lane change penalty
In the image above, the blue self driving car (bottom left) is trying to get to the goal (gold sta ...
- machine learning(11) -- classification: advanced optimization 去求cost function最小值的方法
其它的比gradient descent快, 在某些场合得到广泛应用的求cost function的最小值的方法 when have a large machine learning problem, ...
- behavior planning——10 behaior planning pseudocode
One way to implement a transition function is by generating rough trajectories for each accessible & ...
- loss function与cost function
实际上,代价函数(cost function)和损失函数(loss function 亦称为 error function)是同义的.它们都是事先定义一个假设函数(hypothesis),通过训练集由 ...
- 【caffe】loss function、cost function和error
@tags: caffe 机器学习 在机器学习(暂时限定有监督学习)中,常见的算法大都可以划分为两个部分来理解它 一个是它的Hypothesis function,也就是你用一个函数f,来拟合任意一个 ...
- 逻辑回归损失函数(cost function)
逻辑回归模型预估的是样本属于某个分类的概率,其损失函数(Cost Function)可以像线型回归那样,以均方差来表示:也可以用对数.概率等方法.损失函数本质上是衡量”模型预估值“到“实际值”的距离, ...
随机推荐
- windows 环境下搭建docker私有仓库
windows 环境下搭建docker私有仓库 1.在公用仓库中pull仓库镜像 docker pull regitry 2.启动仓库镜像 //-d意思是后台运行,-p是做端口映射,这里是将本地的50 ...
- linux性能监视工具sar
sar是一个优秀的一般性能监视工具,它可以输出Linux所完成的几乎所有工作的数据.sar命令在sysetat rpm中提供.示例中使用sysstat版本5.0.5,这是稳定的最新版本之一.关于版本和 ...
- 30分钟学webpack实战
阅读目录 一:什么是webpack? 他有什么优点? 二:如何安装和配置 三:理解webpack加载器 四:理解less-loader加载器的使用 五:理解babel-loader加载器的含义 六:了 ...
- QT_string转char*
char* convertQString2char(const QString &str) { QByteArray ba = str.toUtf8(); char * pathChar = ...
- android中的http框架,使其更加简单易用
Afinal 是一个android的sqlite orm 和 ioc 框架. Afinal 是一个android的sqlite orm 和 ioc 框架.同时封装了android中的http框架,使其 ...
- 书写更加高效的CSS,走出误区
根据一些CSS写作经验,如何提高渲染效率及所占用消耗的资源,我们来浅谈一下CSS的渲染效率,书写高效的CSS. 1.十六进制的颜色值对位数与大小写 编写十六进制颜色值时你可能会用小写字母或省略成3位数 ...
- django的admin后台管理
Admin后台管理 要进入admin后台管理首先要创建管理员账户 createsuperuser 其中密码要大于8位 使用之前要到应用下的admin.py中注册要管理的模型表 from django. ...
- 阿里云linux服务器到期后续费,网站打不开解决方法之一
续费后打不开网站,可能会出现不同情况,这里只记录我遇到的问题 问题描述:服务器到期后续费,网站打不开. 解决尝试: 1.重启服务器nginx /etc/init.d/nginx restart ...
- 【风马一族_php】数组函数
原文来自:http://www.cnblogs.com/sows/p/6045699.html (博客园的)风马一族 侵犯版本,后果自负 2016-11-09 15:56:26 数组 函数 php- ...
- 在liferay 7中如何删除service builder已经生成的数据库table
在Liferay 7中,加了数据库保护机制,你改了service.xml的结构后,重新运行service builder,并不会帮你生成新的数据库表.然后你发现你在数据库中自己手动删除了表后,重新部署 ...