Home > src > BN_pol_rec > functions > getCostChange.m

getCostChange

PURPOSE ^

040407 RS. costChange = meassures how fast the enemy is approaching per time

SYNOPSIS ^

function [fuzzy_costChange, oldCost, oldSimulationTime] = getCostChange(oldCost, cost, oldSimulationTime, enemy, friendly_force)

DESCRIPTION ^

 040407 RS. costChange = meassures how fast the enemy is approaching per time
 unit; values = [-inf, +inf];
 fuzzy_costChange depends on sign of the costChange and characteristic
 value c; values = [Positive, Neutral; Negative];
__________________________________________________________________________

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 
0002 
0003 function     [fuzzy_costChange, oldCost, oldSimulationTime] = getCostChange(oldCost, cost,  oldSimulationTime, enemy, friendly_force)
0004 
0005 % 040407 RS. costChange = meassures how fast the enemy is approaching per time
0006 % unit; values = [-inf, +inf];
0007 % fuzzy_costChange depends on sign of the costChange and characteristic
0008 % value c; values = [Positive, Neutral; Negative];
0009 %__________________________________________________________________________
0010 global simulationTime;
0011 costChange =  cost - oldCost; 
0012 if costChange == 0
0013     fuzzy_costChange = [0.33 0.34 0.33];
0014     return;
0015 end;    
0016 timeChange = abs(simulationTime - oldSimulationTime);
0017 costChangePerTime = costChange/timeChange;
0018 %update
0019 oldCost = cost; 
0020 oldSimulationTime = simulationTime;
0021 % Initial values
0022 fuzzy_costChange = [0.334 0.332 0.334];
0023 % Fuzzy coefficient c
0024 c = 0.05; 
0025 if costChangePerTime > c
0026     fuzzy_costChange = [0 0 1];
0027     return;
0028 end;
0029 if costChangePerTime < c
0030     fuzzy_costChange = [1 0 0];
0031     return;
0032 end;
0033 if costChange <= 0
0034     neutral = (c + costChange)/c; 
0035 else
0036     neutral = (c + costChange)/c; 
0037 end;
0038 fuzzy_costChange = [neutral/2 neutral neutral/2];

Generated on Wed 16-Mar-2005 09:17:47 by m2html © 2003