time | Calls | line |
---|
| | 1 | function outputcost = computecost(Table)
|
| | 2 | %UNTITLED2 Summary of this function goes here
|
| | 3 | % Detailed explanation goes here
|
< 0.001 | 377 | 4 | costweight1 = 200;
|
< 0.001 | 377 | 5 | costweight2 = 200;
|
< 0.001 | 377 | 6 | costweight3 = 10;
|
| | 7 |
|
| | 8 | %legee til samme faglærer
|
| | 9 |
|
< 0.001 | 377 | 10 | outputcost = 0;
|
0.002 | 377 | 11 | for rows = 1:height(Table)
|
| | 12 |
|
| | 13 | %not necesacrry if init is correct
|
| | 14 | % %check if allocated is same as behov
|
| | 15 | % if Table{rows,1} == Table{rows,5}
|
| | 16 | % cost1 = costweight1*1;
|
| | 17 | % else
|
| | 18 | % cost1 = costweight1*0;
|
| | 19 | % end
|
0.004 | 67860 | 20 | cost1 = 0;
|
| | 21 |
|
| | 22 | %check if student want to sit with other student
|
| | 23 | %check if not empty
|
| | 24 |
|
| | 25 | %todo: need to check that it doesnt count double if both students add
|
| | 26 | %each other
|
| | 27 | %tenk litt på det
|
| | 28 | %mulighet for å skru av og på
|
| | 29 | %fjerne dublikater før optimalisering
|
3.079 | 67860 | 30 | if Table.(6)(rows) <= 3
|
2.719 | 55042 | 31 | if Table.(2)(rows) == ""
|
0.002 | 49764 | 32 | cost2 = costweight2*0;
|
< 0.001 | 5278 | 33 | else
|
1.223 | 5278 | 34 | if Table.(4)(rows) == Table.(4)(Table.(2)(rows))
|
< 0.001 | 3490 | 35 | cost2 = costweight2*0;
|
< 0.001 | 1788 | 36 | else
|
< 0.001 | 1788 | 37 | cost2 = costweight2*1;
|
< 0.001 | 5278 | 38 | end
|
0.002 | 55042 | 39 | end
|
0.003 | 67860 | 40 | end
|
| | 41 |
|
0.003 | 67860 | 42 | cost3 = 0;
|
| | 43 |
|
| | 44 | %sjekke etter om studenter sitter på samme rom med andre studenter som
|
| | 45 | %har samme faglærer
|
| | 46 | %øke kostnad på de som ikke sitter sammen med samme faglærer
|
| | 47 |
|
| | 48 | %extract entries with same Faglaerer and same BehovForArbeidsplass
|
12.376 | 67860 | 49 | TF = (Table.(3) == Table.(3)(rows) & Table.(10) == Table.(10)(rows));
|
14.040 | 67860 | 50 | newshorttable = Table(TF,:);
|
3.631 | 67860 | 51 | if Table.(6)(rows) <= 3
|
0.175 | 55042 | 52 | for rows2 = 1:height(newshorttable)
|
29.160 | 263523 | 53 | if Table.(4)(rows) ~= newshorttable.(4)(rows2)
|
0.001 | 18320 | 54 | cost3 = cost3 + costweight3*1;
|
0.011 | 263523 | 55 | end
|
0.015 | 263523 | 56 | end
|
0.004 | 67860 | 57 | end
|
| | 58 | % gammel versjon for sjekk av samme faglærer
|
| | 59 | % for rows2 = 1:height(Table)
|
| | 60 | % if Table{rows,1} == Table{rows2,1}
|
| | 61 | % if strncmpi(Table{rows,3}, Table{rows2,3}, 10)
|
| | 62 | % if strncmpi(Table{rows,4}, Table{rows2,4}, 10)
|
| | 63 | %
|
| | 64 | % else
|
| | 65 | % cost3 = cost3 + costweight3*1;
|
| | 66 | % end
|
| | 67 | % end
|
| | 68 | % end
|
| | 69 | % end
|
| | 70 |
|
0.004 | 67860 | 71 | rowcost = cost1 + cost2 + cost3;
|
| | 72 |
|
0.003 | 67860 | 73 | outputcost = outputcost + rowcost;
|
0.005 | 67860 | 74 | end
|
| | 75 |
|
0.003 | 377 | 76 | end
|
Other subfunctions in this file are not included in this listing.