Warning: Error with navigation contributor "BrowserModule"

Ticket #24: arcas.cost

File arcas.cost, 2.2 KB (added by rlalleme, 12 months ago)

Cost functions fils

Line 
1// ARCAS Scenario: 1. (2 vbar, 1 hbar)
2// Cost File
3// last Update: jguitton 7 sept. 2012
4#include <iostream>
5
6
7double costFn(number x){
8        return (double)x;
9}
10
11double costDistance(LightEntity A1, LightEntity A2){
12        double XA1 = (double)A1.get<number>("xCoordinate");
13        double XA2 = (double)A2.get<number>("xCoordinate");
14        double YA1 = (double)A1.get<number>("yCoordinate");
15        double YA2 = (double)A2.get<number>("yCoordinate");
16        double R = ceil( sqrt(pow((XA2-XA1),2) + pow((YA2-YA1),2)) );
17        return R;
18}
19
20pair<double, double> durationFn(number x1, number x2){
21        return make_pair((double)x1, (double)x2);
22}
23
24pair<double, double> durationDistance(LightEntity A1, LightEntity A2, LightEntity U){
25        double XA1 = (double)A1.get<number>("xCoordinate");
26        double XA2 = (double)A2.get<number>("xCoordinate");
27        double YA1 = (double)A1.get<number>("yCoordinate");
28        double YA2 = (double)A2.get<number>("yCoordinate");
29        double V = (double)U.get<number>("velocity");
30        double R =  ceil( (sqrt(pow((XA2-XA1),2) + pow((YA2-YA1),2))) / V );
31        return make_pair(R, R);
32}
33
34pair<double, double> durationDistance(LightEntity A1, LightEntity A2){
35        double XA1 = (double)A1.get<number>("xCoordinate");
36        double XA2 = (double)A2.get<number>("xCoordinate");
37        double YA1 = (double)A1.get<number>("yCoordinate");
38        double YA2 = (double)A2.get<number>("yCoordinate");
39        double R =  sqrt((XA2-XA1)*(XA2-XA1) + (YA2-YA1)*(YA2-YA1));
40        return make_pair(R, R);
41}
42
43float computeWastedTime(vector<WastedTimeData*> const& vec, double totalDuration) {
44        double inactive = 0.;
45       
46        vector<WastedTimeData*>::const_iterator it;
47        for(it = vec.begin() ; it < vec.end() ; it++) {
48                vector<double> vecDurations((*it)->getDurations()); // for one agent
49                vector<double>::iterator j;
50                for(j = vecDurations.begin() ; j < vecDurations.end() ; j++) {
51                        inactive += *j;
52                }
53                inactive *= 100;
54        }
55        return inactive;
56}
57
58//Describe the assembly plan order
59double assemblyPlan(LightEntity E){
60        return (double)E.get<number>("order");
61}
62
63//number costFnOrder(number coefficient, number order){
64//      number res=coefficient*order;
65//      //std::cout<<"Res : "<<coefficient<<"x"<<order<<" = "<<res<<std::endl;
66//      return res;
67//}
68
69number costFnOrder(number coefficient, number order){
70        return coefficient*order;
71}