本文整理汇总了PHP中Math::margin_round方法的典型用法代码示例。如果您正苦于以下问题:PHP Math::margin_round方法的具体用法?PHP Math::margin_round怎么用?PHP Math::margin_round使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Math
的用法示例。
在下文中一共展示了Math::margin_round方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updatePEAndWD
//.........这里部分代码省略.........
try {
$ret = Math::safe_eval($fformula);
if (is_numeric($ret)) {
$this->water_demand = $ret;
} else {
$this->water_demand = -1;
}
} catch (Exception $e) {
$this->water_demand = 0;
Yii::log('WD Error. $fformula=' . $fformula, CLogger::LEVEL_INFO, 'updatePEAndWD');
// DEBUG
}
if (isset($info)) {
$info['city'] = ucwords(strtolower($city_state));
$info['water_demand'] = Math::wd_round($this->water_demand) . ' ' . Yii::app()->params['water_demand_unit'];
if ($service_area == null) {
$info['service_area'] = '--';
$operative_margin = DummyOperativeMargin::model()->findAll('lower(area)=:area', array(':area' => strtolower($city_state)));
if (count($operative_margin) == 0) {
Yii::log('Manca il margine operativo del comune. area=' . $city_state, CLogger::LEVEL_INFO, 'updatePEAndWD');
// DEBUG
return;
}
} else {
//var_dump($service_area);
$info['service_area'] = ucwords(strtolower($service_area['desc_area']));
/*TODO: cambiare il $service_area*/
$operative_margin = DummySAOperativeMargin::model()->findAll('lower(area)=:area', array(':area' => strtolower($service_area['area'])));
if (count($operative_margin) == 0) {
Yii::log('Manca il margine operativo dell\'area di servizio. area=' . $city_state, CLogger::LEVEL_INFO, 'updatePEAndWD');
// DEBUG
return;
}
}
$actual_margin = null;
foreach ($operative_margin as $op) {
if ($op->scenario == null) {
$actual_margin = Math::margin_round($op->margin);
break;
}
}
if ($actual_margin == null) {
Yii::log('Manca il margine operativo attuale. area=' . $city_state, CLogger::LEVEL_INFO, 'updatePEAndWD');
// DEBUG
$actual_margin = 0;
}
if ($this->water_demand > $actual_margin) {
$info['margin'] = -1;
} else {
if ($this->water_demand > $actual_margin - $actual_margin * (int) Yii::app()->params['water_demand_range'] / 100) {
$info['margin'] = 0;
} else {
$info['margin'] = 1;
}
}
$info['maximum_water_supply'] = Math::margin_round($actual_margin) . ' ' . Yii::app()->params['water_demand_unit'];
if ($fformula_with_pe != null) {
$info['max_parameter'] = array();
$info['max_parameter']['name'] = $p;
$fformula_with_pe = str_ireplace(Yii::app()->params['formulas']['pe'], 1 / $actual_margin, $fformula_with_pe);
try {
$ret = Math::safe_eval($fformula_with_pe);
if (is_numeric($ret)) {
$max_pe = 1 / $ret;
} else {
$max_pe = -1;
}
} catch (Exception $e) {
$max_pe = -1;
Yii::log('MAX PE Error. $fformula_with_pe=' . $fformula_with_pe, CLogger::LEVEL_INFO, 'updatePEAndWD');
// DEBUG
}
if ($max_pe > 0) {
$info['max_parameter']['value'] = $max_pe / $val;
} else {
$info['max_parameter']['value'] = -1;
}
}
$info['scenari'] = array();
foreach ($operative_margin as $op) {
if ($op->scenario == null) {
continue;
}
$item = array();
$item['scenario'] = $op->scenario;
$item['maximum_water_supply'] = Math::margin_round($op->margin) . ' ' . Yii::app()->params['water_demand_unit'];
if ($this->water_demand > $op->margin) {
$item['margin'] = -1;
} else {
if ($this->water_demand > $op->margin - $op->margin * (int) Yii::app()->params['water_demand_range'] / 100) {
$item['margin'] = 0;
} else {
$item['margin'] = 1;
}
}
array_push($info['scenari'], $item);
}
}
return;
}