Below is  the whole code. I didnt include it originally because it is really
confusing. Basically it uses probability functions to determine the number
of nights a plane may need to overnight at a certain airport, based upon the
costs and expected business for a certain period of time. I am in the
process of translating it from VB-Access, where it was originally written.


<!--- get the params --->
  <cfquery name="get_costmodel_params" datasource="Analytics">
   Select * from nltx_costmodel_parameters
  </cfquery>
  <!--- set basic params --->
  <cfset numPeriods = get_costmodel_params.num_periods>
  <cfset periodsPerDay = numPeriods/7>
  <cfset nextNight = (periodnumber/periodsPerDay + .99) * periodsPerDay>
  <cfset lastNight = (periodnumber/periodsPerDay) * periodsPerDay>
  <cfset missionsToday = get_costmodel_params.MissionsToday_Model>
  <cfset missionsWeek = get_costmodel_params.MissionsWeek_Model>
  <cfset profitablePercent = get_costmodel_params.ProfitablePercent>
  <cfif trim(ac_Type) is "DA-20">
   <cfset planesUp = get_costmodel_params.SmallPlanesUp_Model>
   <cfset stdDev = get_costmodel_params.Std_Dev_Small>
  <cfelse>
   <cfset planesUp = get_costmodel_params.LargePlanesUp_Model>
   <cfset stdDev = get_costmodel_params.Std_Dev_Large>
  </cfif>
  
  <cfquery name="get_airport" datasource="analytics">
   Select * from NLTX_costmodel_airport_stats where ICAO = '#airport#'
  </cfquery>
  <cfif get_airport.recordcount is 0>
   <cfquery name="get_brother_airport" datasource="analytics">
    Select * from NLTX_costmodel_airport_brother where ICAO = '#airport#'
   </cfquery>
   <cfif get_brother_airport.recordcount gt 0>
    <cfquery name="get_airport" datasource="analytics">
     Select * from NLTX_costmodel_airport_stats where ICAO =
'#get_brother_airport.BigBrother_ICAO#'
    </cfquery>
   </cfif>
  </cfif>
  <cfif isDefined("get_brother_airport.recordcount") AND
get_brother_airport.recordcount gt 0>
   <cfset airport = get_brother_airport.BigBrother_ICAO>
  <cfelse>
   <cfset airport = airport>
  </cfif>
  <cfif trim(ac_Type) is "DA-20">
   <cfset percentUse = 1 - get_airport.Big_Percent>
  <cfelse>
   <cfset percentUse = 1>
  </cfif>
  
  <cfquery name="get_demands" datasource="analytics">
   SELECT
     nltx_costmodel_airport_demand.Period,
     nltx_costmodel_airport_demand.Percent AS Specific,
     nltx_costmodel_period_demand.Percent AS Overall
   FROM  nltx_costmodel_airport_demand
     INNER JOIN
      nltx_costmodel_period_demand ON nltx_costmodel_airport_demand.Period =
nltx_costmodel_period_demand.Period
    WHERE  (((nltx_costmodel_airport_demand.ICAO) = '#airport#'))
  </cfquery>
  
  
  <!--- calculate demand that should happen today --->
  <cfset i = lastNight + 1>
  <cfset sumToday = 0>
  
  <cfloop index = "i" from="1" to="#nextNight#">
   <cfloop query="get_demands">
    <cfif get_demands.period is i>
     <cfset sumToday = sumToday + get_demands.overall>
    </cfif>
   </cfloop>
  </cfloop>
  
  <!--- calculate demand for the rest of the day --->
  <cfset j = periodnumber + 1>
  <cfset sum = 0>
  <cfset sum2 = 0>
  
  <cfloop index="j" from="1" to="#nextNight#">
   <cfloop query="get_demands">
    <cfif get_demands.period is j>
     <cfset sum = sum + get_demands.period * get_demands.overall / sumToday>
     <cfset sum2 = sum2 + get_demands.overall / sumToday>
    </cfif>
   </cfloop>
  </cfloop>
  <cfset lambda = sum*missionsToday*profitablePercent*percentUse>
  <cfset lambda2 = sum2*missionsToday*profitablePercent*percentUse>
  
  <!--- PoissonProbability for lambda --->
  <cfset lambda_param = lambda>
  <cfset stopIt = numberplanes + 1>
  <cfinclude template="functions/func_poissonProbability.cfm">
  <!--- this is the likelihood that there will not be enough demand to cover
all of the planes here. --->
  <cfset nights = PoissonProbability>
  <!--- this is the likelihood that the plane gets out before having to
spend the night. --->
  <cfset probGone = 1 - nights>
  <cfset count = 0>
  <cfloop condition="count lt 3 AND probGone lt .95">
   <cfif nextNight is numPeriods>
    <cfset nextNight = periodsPerDay>
    <cfset lastNight = 0>
   <cfelse>
    <cfset lastNight = nextNight>
    <cfset nextNight = nextNight + periodsPerDay>
   </cfif>
   <cfset x = int(lastNight + 1)>
   <!--- <cfset count = count + 1> --->
   <cfloop condition="x lte nextNight">
    <cfloop query="get_demands">
     <cfif get_demands.period is x>
      <cfset lambda = lambda + get_demands.specific * get_demands.overall *
profitablePercent * missionsWeek * percentUse>
      <cfset lambda2 = lambda2 + get_demands.overall * profitablePercent *
missionsWeek * percentUse>
      <cfbreak>
     </cfif>
    </cfloop>
    <cfset x = x + 1>
   </cfloop>
   <!--- PoissonProbability for lambda --->
   <cfset lambda_param = lambda>
   <cfset stopIt = numberplanes + 1>
   <cfinclude template="functions/func_poissonProbability.cfm">
   <cfset tempVal = PoissonProbability>
   
   <cfset lambda_param = lambda2>
   <cfset stopIt = planesUp>
   <cfinclude template="functions/func_poissonProbability.cfm">
   <cfset tempVal2 = PoissonProbability>
   
   <cfif tempVal2 gt tempVal>
    <cfset tempVal = .75 * tempVal2 + .25 * tempVal>
   </cfif>
   <cfoutput>new tempVal#tempVal#</cfoutput><br>
   <cfset nights = nights + tempVal * (1 - probGone)>
   <cfset probGone = (1 - probGone) * (1 - tempVal) + probGone>
   <cfset count = count + 1>
  </cfloop>
  I
  <cfoutput>#probGone#<br>#nights#</cfoutput>


The PoissonProbability function being included is here:
<cfparam name="lambda_param" default="">
<cfparam name="stopIt" default="">


<cfset value = Exp(lambda_param)>
<cfset current = value>
<cfloop index = "count" from="1" to="#stopIt#">
<!--- current is the probability that there will be exactly 'count'
missions --->
<cfset current = current * lambda_param / count>
<cfset value = value + current>
</cfloop>
<cfset PoissonProbability = value>

-----Original Message-----
From: Barney Boisvert [mailto:[EMAIL PROTECTED]
Sent: Friday, March 12, 2004 2:26 PM
To: CF-Talk
Subject: RE: Interesting Numbers

What's the manipulation that's yielding this result?   

> -----Original Message-----
> From: John Stanley [mailto:[EMAIL PROTECTED]
> Sent: Friday, March 12, 2004 11:18 AM
> To: CF-Talk
> Subject: Interesting Numbers
>
> All,
>     As a result of mathematical manipulations, I am getting
> the following
> result in CFMX.
>
>
> 1.#INF
>
>
> which, I assume means 1. followed by a very large number of
> decimal places.
>
>
> If this assumption is correct, then how can I show this
> number to say one or
> two or three decimal places? Or is this even possible?
>
>
> If this assumption is not correct, then what does the #INF mean?
>
>
> TIA
>
>
> John
>
>  
>
>
>
>
  _____
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to