You are here

public static function AcquiaLiftTestReports::generateConfidenceReportWithWinners in Acquia Lift Connector 7

Generates confidence report data based on the passed in parameters.

Parameters

$agent_name: The name of the agent to generate a report for.

array $choices: An array of options for which data should be generated, keyed by decision point name and with an array of all possible winning options or combinations of options as values. For multiple decisions at one point, i.e. an MVT, the choices should be flattened into decision combinations, e.g. 'dec-1:option-a,dec-2:option-b'. E.g. array( 'my-first-decision-point' => array( 'my-first-decision:option-A', 'my-first-decision:option-B' ), 'my-MVT-decision-point' => array( 'dec-1:option-a,dec-2:option-a', 'dec-1:option-a,dec-2:option-b', 'dec-1:option-b,dec-2:option-a', 'dec-1:option-b,dec-2:option-b', ) )

array $winners: Optionally specify a winning choice or combination for each decision point. The report data generated will then be such that that option or combination represents a winner.

Return value

array

2 calls to AcquiaLiftTestReports::generateConfidenceReportWithWinners()
AcquiaLiftWebTestWorkflow::testAutoStop in tests/acquia_lift.test
Tests the logic of AcquiaLiftAgent's stopNow() implementation in the simplest use case.
AcquiaLiftWebTestWorkflow::testAutoStopMultiplePoints in tests/acquia_lift.test
Tests the logic of AcquiaLiftAgent's stopNow() implementation when the agent has mulitple decision points including an MVT.

File

tests/acquia_lift.test_classes.inc, line 464
Provides test classes for Acquia Lift

Class

AcquiaLiftTestReports
Class AcquiaLiftTestReports

Code

public static function generateConfidenceReportWithWinners($agent_name, $choices, $winners = array()) {
  $today = time();
  $date_from = date('Y-m-d', $today);
  $date_to = date('Y-m-d', $today);
  $items = array();
  foreach ($choices as $point => $options) {

    // Start with dummy values which we'll just increment for each choice.
    $blo = 0.016;
    $vmean = 0.017;
    $bhi = 0.018;
    $num_decisions = 10;
    $num_goals = 100;
    foreach ($options as $i => $choice) {
      $items[$choice] = array(
        'owner' => 'test-owner-code',
        'agent' => $agent_name,
        'point' => $point,
        'choice' => $choice,
        'count' => $num_decisions + 10 * $i,
        'bLo' => $blo + 0.001 * $i,
        'bHi' => $bhi + 0.001 * $i,
        'vMean' => $vmean + 0.001 * $i,
      );
    }
    if (isset($winners[$point])) {

      // For the winning option, we need to make sure the vMean value is higher
      // than the others.
      $winning_blo = $vmean + 0.001 * (count($options) + 1);
      $winning_vmean = $winning_blo + 0.001;
      $winning_vhi = $winning_vmean + 0.001;
      $items[$winners[$point]]['bLo'] = $winning_blo;
      $items[$winners[$point]]['vMean'] = $winning_vmean;
      $items[$winners[$point]]['bHi'] = $winning_vhi;
    }
  }
  $report = array(
    'agent' => $agent_name,
    'dateFrom' => $date_from,
    'dateThru' => $date_to,
    'data' => array(
      'items' => array_values($items),
      'bLo' => NULL,
      'bHi' => NULL,
    ),
  );
  return $report;
}