Skip to content

Commit

Permalink
Some fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Speriosu committed Jul 24, 2013
1 parent 799580d commit a842508
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ object ConstructionTPPSolver {
if(thisTC < leastTC) {
optIndex = tour.size
}

if(optIndex < 0) optIndex = 0

tour.insert(optIndex, marketVisit)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ class GaussianPurchaseCoster extends PurchaseCoster {

def g(x:Double, y:Double) = GaussianUtil.g(x,y)

//val maxHeight = g(0.0,0.0)

val storedCosts = new scala.collection.mutable.HashMap[(Int, Int), Double] // (location.id, market.id) => distance
def cost(l:Location, m:Market): Double = {
val key = (l.getId, m.id)
if(storedCosts.contains(key))
storedCosts(key)
else {
val cost = 1.0-g(l.getRegion.distance(m.centroid)/variance, 0)///max
//val cost = (maxHeight-g(l.getRegion.distance(m.centroid)/variance, 0))/maxHeight///max
storedCosts.put(key, cost)
cost
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import opennlp.fieldspring.tr.topo._

class GaussianTravelCoster extends TravelCoster {

val VARIANCE_KM = 1610
val VARIANCE_KM = 1610.0
val variance = VARIANCE_KM / 6372.8

def g(x:Double, y:Double) = GaussianUtil.g(x,y)
Expand All @@ -23,10 +23,10 @@ class GaussianTravelCoster extends TravelCoster {

object GaussianTravelCoster extends App {
val gtc = new GaussianTravelCoster
println((gtc.maxHeight-gtc.g(0,0))/gtc.maxHeight)
println((gtc.maxHeight-gtc.g(0.25,0))/gtc.maxHeight)
//println((gtc.maxHeight-gtc.g(0,0))/gtc.maxHeight)
//println((gtc.maxHeight-gtc.g(0.25,0))/gtc.maxHeight)
println((gtc.maxHeight-gtc.g(0.5,0))/gtc.maxHeight)
println((gtc.maxHeight-gtc.g(1.0,0))/gtc.maxHeight)
println((gtc.maxHeight-gtc.g(2.0,0))/gtc.maxHeight)
println((gtc.maxHeight-gtc.g(3.0,0))/gtc.maxHeight)
//println((gtc.maxHeight-gtc.g(3.0,0))/gtc.maxHeight)
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class MaxentPurchaseCoster(corpus:StoredCorpus, modelDirPath:String) extends Pur

def apply(m:Market, potLoc:PotentialLocation): Double = {
//if(m.locations.map(_._2).toSet.contains(potLoc)) {
potLocsToCosts.getOrElse(potLoc, 1.0) // Not sure what the default cost should be
1.0//potLocsToCosts.getOrElse(potLoc, 1.0) // Not sure what the default cost should be
//}
//else
// Double.PositiveInfinity
Expand Down

0 comments on commit a842508

Please sign in to comment.