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)可以像线型回归那样,以均方差来表示:也可以用对数.概率等方法.损失函数本质上是衡量”模型预估值“到“实际值”的距离, ... 
随机推荐
- Linux 中查询 CPU 的核数的方法
			以一台 Linux 服务器为例.这台 Linux 包括两颗 Intel(R) Xeon(R) CPU E5-2630 v4 @ 2.20GHz CPU, 单颗 CPU 包括 10 个 cpu core ... 
- java.lang.ClassCastException: java.io.ByteArrayInputStream cannot be cast to java.io.FileInputStream
			今天在做文件上传的时候遇到一个这样的问题 java.lang.ClassCastException: java.io.ByteArrayInputStream cannot be cast to ja ... 
- Vue.之.创建项目
			Vue.之.创建项目 第一次使用vue的时候,在已完成node的情况下,还需要在进行安装vue. 指令:cnpm install vue-cli -g //全局安装 vue-cli 检查vu ... 
- js封装ajax的方法
			常用的ajax请求方法封装 /** * ajax请求的封装代码 */ function ajaxPost(url, params, cb) { $.ajax({ type : 'post', url ... 
- 2019.9.16 csp-s模拟测试44 反思总结
			虽然说好像没有什么写这个的价值OAO 来了来了来写总结了,不能怨任何东西,就是自己垃圾x 开题顺序又和主流背道而驰,先一头扎进了公认最迷的T2,瞎搞两个小时头铁出来,然后T1和T3爆炸.基础很差,全靠 ... 
- codevs1214 线段覆盖
			1214 线段覆盖 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold 题目描述 Description 给定x轴上的N(0<N<100)条线段, ... 
- win10下安装mongodb(解压版)
			首先到官网下载安装包.(https://www.mongodb.com/download-center#community) 1.创建mongodb目录 2.配置文件mongodb.config 3. ... 
- docker相关教程【转】
			https://www.w3cschool.cn/docker/docker-run-command.html 运行容器 https://www.runoob.com/docker/docker-im ... 
- spss命令数据整理中compute与record命令的区别
			spss命令数据整理中compute与record命令的区别 record修改存在的变量,或者生成新的变量 spss变量定义说明 1.Name:变量名,定义规则与其它软件中的雷同,如第一个字符必须为字 ... 
- pom.xml中若出现jar not found;
			pom.xml中若出现jar not found;我们可以直接在view ->tool windows ->Maven Project 中直接install 
