Commit 67cb5814 authored by Svetlana's avatar Svetlana

Function for Denormalizer

parent 12b4c9e6
package dp.subcomponents;
function Q newValue = ChangeRange(Q oldMin, Q oldMax, Q newMin, Q newMax, Q oldValue)
Q oldRange = oldMax - oldMin;
Q newRange = newMax - newMin;
newValue = (((oldValue - oldMin) * newRange) / oldRange) + newMin;
end
\ No newline at end of file
package dp.subcomponents;
import changeRange;
import dp.subcomponents.*;
component Denormalizer {
ports in Q^{14} normalizedPredictions,
out Affordance affordance;
implementation Math {
function changeRange(oldMin, oldMax, newMin, newMax, oldValue){
(((oldValue - oldMin) * (newMax - newMin)) / (oldMax - oldMin)) + newMin
}
Q oldMin = 0.1;
Q oldMax = 0.9;
affordance.angle = changeRange(oldMin, oldMax, -0.5, 0.5, normalizedPredictions(0));
affordance.toMarkingL = changeRange(oldMin, oldMax, -7, -2.5, normalizedPredictions(1));
affordance.toMarkingM = changeRange(oldMin, oldMax, -2, 3.5, normalizedPredictions(2));
affordance.toMarkingR = changeRange(oldMin, oldMax, 2.5, 7, normalizedPredictions(3));
affordance.distL = changeRange(oldMin, oldMax, 0, 75, normalizedPredictions(4));
affordance.distR = changeRange(oldMin, oldMax, 0, 75, normalizedPredictions(5));
affordance.toMarkingLL = changeRange(oldMin, oldMax, -9.5, -4, normalizedPredictions(6));
affordance.toMarkingML = changeRange(oldMin, oldMax, -5.5, -0.5, normalizedPredictions(7));
affordance.toMarkingMR = changeRange(oldMin, oldMax, 0.5, 5.5, normalizedPredictions(8));
affordance.toMarkingRR = changeRange(oldMin, oldMax, 4, 9.5, normalizedPredictions(9));
affordance.distLL = changeRange(oldMin, oldMax, 0, 75, normalizedPredictions(10));
affordance.distMM = changeRange(oldMin, oldMax, 0, 75, normalizedPredictions(11));
affordance.distRR = changeRange(oldMin, oldMax, 0, 75, normalizedPredictions(12));
affordance.fast = changeRange(oldMin, oldMax, 0, 1, normalizedPredictions(13));
affordance.angle = ChangeRange(oldMin, oldMax, -0.5, 0.5, normalizedPredictions(0));
affordance.toMarkingL = ChangeRange(oldMin, oldMax, -7, -2.5, normalizedPredictions(1));
affordance.toMarkingM = ChangeRange(oldMin, oldMax, -2, 3.5, normalizedPredictions(2));
affordance.toMarkingR = ChangeRange(oldMin, oldMax, 2.5, 7, normalizedPredictions(3));
affordance.distL = ChangeRange(oldMin, oldMax, 0, 75, normalizedPredictions(4));
affordance.distR = ChangeRange(oldMin, oldMax, 0, 75, normalizedPredictions(5));
affordance.toMarkingLL = ChangeRange(oldMin, oldMax, -9.5, -4, normalizedPredictions(6));
affordance.toMarkingML = ChangeRange(oldMin, oldMax, -5.5, -0.5, normalizedPredictions(7));
affordance.toMarkingMR = ChangeRange(oldMin, oldMax, 0.5, 5.5, normalizedPredictions(8));
affordance.toMarkingRR = ChangeRange(oldMin, oldMax, 4, 9.5, normalizedPredictions(9));
affordance.distLL = ChangeRange(oldMin, oldMax, 0, 75, normalizedPredictions(10));
affordance.distMM = ChangeRange(oldMin, oldMax, 0, 75, normalizedPredictions(11));
affordance.distRR = ChangeRange(oldMin, oldMax, 0, 75, normalizedPredictions(12));
affordance.fast = ChangeRange(oldMin, oldMax, 0, 1, normalizedPredictions(13));
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment