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)可以像线型回归那样,以均方差来表示:也可以用对数.概率等方法.损失函数本质上是衡量”模型预估值“到“实际值”的距离, ...
随机推荐
- DTD约束与schema约束的不同
本篇笔记了解------Schema约束的语法 ------可以参考W3school之Schema教程. Schema:是基于 XML 的 DTD 替代者,用于描述XML文档结构.支持XML 命名空间 ...
- spring的基于xml的AOP配置案例和切入点表达式的一些写法
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.spr ...
- php百度地图计算两地现实距离
请自行到百度地图官网申请您的ak <!--前端获取手机经纬度的代码--> <!--<!DOCTYPE html>--> <!--<html lang=& ...
- JSP-response(HttpServletResponse)
1 HttpServletResponse概述 2 Response 运行过程 3 通过抓包工具抓取Http响应 4 响应行 5 设置响应头 set 和add的区别 6 重定向 需要完成分析‘ 6 ...
- Vue Router 相关
1. 路由传参: 编程式的导航 router.push this.$router.push("home"); this.$router.push({ name: 'news', p ...
- jquery文字上下滚动--单行 批量多行 文字图片上下翻滚 | 多行滚动
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 关于Python缩进,我们该了解哪些?
Python是一门独特的语言,它的代码块是通过缩进(Indentation)来标记的(大部分语言都是使用花括号作为代码块的标记),具有相同缩进的多行代码属于同一个代码块.如果代码莫名其妙的乱缩进,Py ...
- python第一天 :计算机基础(一)
1.什么是编程语言 答:人类与计算机交流的介质 2.什么是编程 答:利用编程语言控制计算机解决问题 3.为什么要编程 答:可以控制计算机做事,提高生产生活效率 4.计算机的五大组成部分分别有什么作用? ...
- 如何在Data Lake Analytics中使用临时表
前言 Data Lake Analytics (后文简称DLA)是阿里云重磅推出的一款用于大数据分析的产品,可以对存储在OSS,OTS上的数据进行查询分析.相较于传统的数据分析产品,用户无需将数据重新 ...
- MySQL数据库操作语句(cmd环境运行)
一.开启MySQL服务器 1, 通过windows提供的服务管理器来完成 windows键+R 输入: services.msc 2.在本地服务中打开其服务 3.在DOC命令行下 net stop ...