Skip to content

Commit

Permalink
fix #15 : choose a car
Browse files Browse the repository at this point in the history
  • Loading branch information
Taeradan committed Feb 6, 2016
1 parent cd26d5b commit 1345d79
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 0 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ build:
pdf: build
$(EXECUTABLE) > out.md
pandoc out.md -o out.pdf -V geometry:a4paper -V geometry:margin=2cm
date

#---- Improvement

Expand Down
2 changes: 2 additions & 0 deletions hahp-example/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import HAHP.Reporting
import HAHP.Sample.Config1
import HAHP.Sample.Config2
import HAHP.Sample.Config3
import HAHP.Sample.CarChoice
import HAHP.Sample.LeaderChoice
import HAHP.Sample.SquareMatrixError

Expand All @@ -19,6 +20,7 @@ main = do
--, (sampleAHPConfig3, sampleAlternatives3)
--, (smeConfig, smeAlternatives)
(leaderChoiceTree, leaderChoiceAlternatives)
, (carChoiceTree, carChoiceAlternatives)
]

time <- getCurrentTime
Expand Down
1 change: 1 addition & 0 deletions hahp.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ library
HAHP.Sample.Config1
HAHP.Sample.Config2
HAHP.Sample.Config3
HAHP.Sample.CarChoice
HAHP.Sample.LeaderChoice
HAHP.Sample.SquareMatrixError
HAHP.Validation.Alternatives
Expand Down
125 changes: 125 additions & 0 deletions src/HAHP/Sample/CarChoice.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
module HAHP.Sample.CarChoice where

import Data.Map
import HAHP.Data
import Numeric.LinearAlgebra.HMatrix

carChoiceTree :: AHPTree
carChoiceTree =
AHPTree "Choose the best car for the Jones family"
( (4><4)
[ 1, 3, 7, 3
, 1/3, 1, 9, 1
, 1/7, 1/9, 1, 1/7
, 1/3, 1, 7, 1
]
)
Nothing
Nothing
Nothing
[ AHPTree "Cost"
( (4><4)
[ 1, 2, 5, 3
, 1/2, 1, 2, 2
, 1/5, 1/2, 1, 1/2
, 1/3, 1/2, 2, 1
]
)
Nothing
Nothing
Nothing
[ AHPLeaf "Purchase Price" True Nothing
, AHPLeaf "Fuel Costs" True Nothing
, AHPLeaf "Maintenance Costs" True Nothing
, AHPLeaf "Resale Value" True Nothing
]
, AHPLeaf "Safety" True Nothing
, AHPLeaf "Style" True Nothing
, AHPTree "Capacity"
( (2><2)
[ 1, 1/5
, 5, 1
]
)
Nothing
Nothing
Nothing
[ AHPLeaf "Cargo Capacity" True Nothing
, AHPLeaf "Passenger Capacity" True Nothing
]
]

asValues =
insert "Purchase Price" 0.242
. insert "Fuel Costs" 0.188
. insert "Maintenance Costs" 0.357
. insert "Resale Value" 0.225
. insert "Safety" 0.215
. insert "Style" 0.346
. insert "Cargo Capacity" 0.090
. insert "Passenger Capacity" 0.136
$ empty

ahValues =
insert "Purchase Price" 0.027
. insert "Fuel Costs" 0.212
. insert "Maintenance Costs" 0.312
. insert "Resale Value" 0.095
. insert "Safety" 0.215
. insert "Style" 0.346
. insert "Cargo Capacity" 0.090
. insert "Passenger Capacity" 0.136
$ empty

psuvValues =
insert "Purchase Price" 0.027
. insert "Fuel Costs" 0.133
. insert "Maintenance Costs" 0.084
. insert "Resale Value" 0.055
. insert "Safety" 0.083
. insert "Style" 0.045
. insert "Cargo Capacity" 0.170
. insert "Passenger Capacity" 0.273
$ empty

crvValues =
insert "Purchase Price" 0.242
. insert "Fuel Costs" 0.160
. insert "Maintenance Costs" 0.100
. insert "Resale Value" 0.415
. insert "Safety" 0.038
. insert "Style" 0.160
. insert "Cargo Capacity" 0.170
. insert "Passenger Capacity" 0.136
$ empty

esuvValues =
insert "Purchase Price" 0.362
. insert "Fuel Costs" 0.151
. insert "Maintenance Costs" 0.089
. insert "Resale Value" 0.105
. insert "Safety" 0.025
. insert "Style" 0.025
. insert "Cargo Capacity" 0.170
. insert "Passenger Capacity" 0.046
$ empty

omValues =
insert "Purchase Price" 0.100
. insert "Fuel Costs" 0.156
. insert "Maintenance Costs" 0.058
. insert "Resale Value" 0.105
. insert "Safety" 0.424
. insert "Style" 0.078
. insert "Cargo Capacity" 0.310
. insert "Passenger Capacity" 0.273
$ empty

carChoiceAlternatives :: [Alternative]
carChoiceAlternatives = [ Alternative "Accord Sedan" asValues
, Alternative "Accord Hybrid" ahValues
, Alternative "Pilot SUV" psuvValues
, Alternative "CR-V SUV" crvValues
, Alternative "Element SUV" esuvValues
, Alternative "Odyssey Minivan" omValues
]

0 comments on commit 1345d79

Please sign in to comment.