<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head >
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>解释结构模型,计算演示</title>
</head>
<body>
<?php
include_once("ism_matrix.php");
$matrix_A=new ism_mat(array(
array(0,0,0,0,0,0,1,0,0,0,0,0,0,0,0),
array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),
array(0,1,0,0,0,0,0,0,0,0,1,0,0,0,0),
array(0,0,0,0,0,0,1,0,0,0,0,0,0,0,0),
array(0,1,0,0,0,0,0,0,0,0,0,0,0,0,0),
array(0,0,0,0,0,0,0,0,0,0,0,0,1,0,0),
array(0,1,0,0,0,0,0,0,0,0,0,0,0,0,0),
array(0,0,0,0,0,0,1,0,0,0,0,0,0,0,0),
array(0,0,0,0,0,0,1,0,0,1,0,0,0,0,0),
array(0,0,0,1,0,0,0,0,0,0,0,0,0,0,0),
array(0,0,0,0,0,0,0,0,0,0,0,1,0,0,0),
array(0,0,1,0,0,0,0,0,0,0,0,0,0,0,0),
array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),
array(1,0,0,1,0,0,0,0,1,0,0,0,0,0,1),
array(1,1,0,0,0,0,0,0,0,0,0,1,0,0,0),
),
15,
array(a=>'a',b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z));
//array(a=>'a',b,c,d,e,f,g,h,i,j,k,l,m,n,o));
echo '<br><h1>显示第一个矩阵 matrix_A 该矩阵为原始矩阵! </h1><hr><br>';
echo '<br><h1> echo matrix_A ! </h1><hr><br>';
$matrix_A=$matrix_A->rand_mat(1.5);
$matrix_A->echo_mat(matrix_A);
echo '<br><h1>显示原始矩阵 matrix_I 的单位矩阵! </h1><hr><br>';
$matrix_I=$matrix_A->i();
$matrix_I->echo_mat();
echo '<br><h1>显示相乘矩阵 matrix_B与matrix_B1 该矩阵为原始矩阵与单位矩阵相加 </h1><hr><br>';
$matrix_B=$matrix_A->plus($matrix_I);
$matrix_B->echo_mat();
$matrix_B1=$matrix_I->plus($matrix_A);
$matrix_B1->echo_mat();
echo '<br><h1>相乘矩阵自己相乘获得可达矩阵的过程 </h1><hr><br>';
$R_Step=$matrix_B->get_r_mat_step_data();
foreach ($R_Step as $i=>$v)
{
echo '<br>第'.$i.'步';
$v->echo_mat();
}
echo '<br><h1>可达矩阵matrix_R为</h1><hr><br>';
$matrix_R=$matrix_B->r_mat();
$matrix_R->echo_mat();
echo '<br><h1>由可达矩阵matrix_R或者原始矩接判断有几个独立的系统,或者说几个独立的区域</h1><hr><br>';
$the_group1=$matrix_A->get_group_e_name();
$the_group2=$matrix_R->get_group_e_name();
//print_r($step);
echo '<table border="1">'."\n";
echo '<tr>';
echo '<td>';
foreach ($the_group1 as $i=>$group)
{
$no=$i+1;
echo '第'.$no.'个系统中包含:<br>';
foreach($group as $e_name)
{
echo $e_name.'、';
}
echo '<br>';
}
echo '</td>';
echo '<td>';
foreach ($the_group1 as $i=>$group)
{
$no=$i+1;
echo '第'.$no.'个系统中包含:<br>';
foreach($group as $e_name)
{
echo $e_name.'、';
}
echo '<br>';
}
echo '</td>';
echo '</tr>';
echo "</table>\n";
echo '<br><h1>由对矩阵进行缩减给出最大的独立子系统、既包含要素最多的区域组</h1><hr><br>';
echo '<table border="1">'."\n";
echo '<tr>';
$the_group_r=$matrix_R->get_group();
foreach($the_group_r as $i=>$group)
{
echo '<td>可达矩阵分解的</td>';
echo '<td>';
$the_group_mat[$i]=$matrix_R->group_mat_by_num($group);
$the_group_mat[$i]->echo_mat();
echo '</td>';
}
echo '</tr>';
echo '<tr>';
$the_group_a=$matrix_A->get_group();
foreach($the_group_a as $i=>$group)
{
echo '<td>原始矩阵分解的</td>';
echo '<td>';
$the_group_mat[$i]=$matrix_A->group_mat_by_num($group);
$the_group_mat[$i]->echo_mat();
echo '</td>';
}
echo '</tr>';
echo "</table>\n";
echo '<br><h1>获得可达矩阵与原始矩阵的最大的独立区域的 矩阵</h1><hr><br>';
$max_group_r=$matrix_R->get_max_group_mat();
$max_group_a=$matrix_A->get_max_group_mat();
$max_group_r->echo_mat();
$max_group_a->echo_mat();
echo '<br><h1>获得可达矩阵最大区域与原始矩阵的最大的独立区域的可达矩阵 两个是相等的</h1><hr><br>';
$max_group_r=$matrix_R->get_max_group_mat();
$max_group_a=$matrix_A->get_max_group_mat();
$max_group_r->echo_mat();
$r_mat_max_group_a=$max_group_a->r_mat();
$r_mat_max_group_a->echo_mat();
echo '<br><h1>缩减后的矩阵获得构成环路的要素</h1><hr><br>';
$max_ring_r=$max_group_r->get_ring();
$max_ring_a=$max_group_a->get_ring();
//print_r($max_ring_r);
//print_r($max_ring_a);
$max_ring_r1=$max_group_r->get_ring_e_name();
$max_ring_a1=$max_group_a->get_ring_e_name();
echo '<table border="1">'."\n";
echo '<tr>';
echo '<td>';
foreach ($max_ring_r1 as $i=>$group)
{
$no=$i+1;
echo '环路中包含:<br>';
foreach($group as $e_name)
{
echo $e_name.'、';
}
echo '<br>';
}
echo '</td>';
echo '<td>';
foreach ($max_ring_a1 as $i=>$group)
{
$no=$i+1;
echo '系统中包含:<br>';
foreach($group as $e_name)
{
echo $e_name.'、';
}
echo '<br>';
}
echo '</td>';
echo '</tr>';
echo "</table>\n";
echo '<br><h1>去掉环路以后的缩减矩阵注意环路用一个要素标识</h1><hr><br>';
echo '<table border="1">'."\n";
echo '<tr>';
echo '<td>';
$d_ring_r=$max_group_r;
foreach ($max_ring_r1 as $i=>$group)
{
$d_ring_r=$d_ring_r->deduce_e_by_ring_name($group);
echo '这个是从可达矩阵缩减环路得到的=';
// print_r($d_ring_r);
$d_ring_r->echo_mat();
echo '<br>';
}
echo '</td>';
echo '<td>';
$d_ring_a=$max_group_a;
foreach ($max_ring_a1 as $i=>$group)
{
$d_ring_a=$d_ring_a->deduce_e_by_ring_name($group);
echo '这个是原始矩阵缩减环路得到的=';
$d_ring_a->echo_mat();
}
echo '</td>';
echo '<td>';
echo '缩减后矩阵的可达矩阵=';
$s=$d_ring_a->r_mat();
$s->echo_mat();
echo '</td>';
echo '<td>';
echo '没有缩减环路时候的可达矩阵(去掉†独立的区域的)=';
$max_group_r->echo_mat();
echo '</td>';
echo '<br>';
echo '</tr>';
echo "</table>\n";
echo '<br><h1>以结果优先的方法对缩减矩阵进行层级抽取</h1><hr><br>';
$d_ring_r_step=$d_ring_r->get_r_f_level_data();
//print_r($d_ring_r_step);
echo '<table border="1">'."\n";
foreach($d_ring_r_step as $index=>$stepdata)
{
echo '<tr>';
foreach($stepdata as $type=>$data)
{
echo "<td>";
if($type==r_mat ||$type==t_mat ||$type==m_mat)
{
$data->echo_mat();
}
elseif($type==lev)
{
echo '抽取了要素:<br>';
foreach($data as $e)
{
echo $e.'也就是-->';
$name=$d_ring_r->element_name[$e];
echo $name;
echo '<br>';
}
echo '<br>';
}
else
{
print_r($data);
}
echo "</td>";
}
echo '</tr>';
}
echo "</table>\n";
echo '<br><h1>以原因优先的方法对缩减矩阵进行层级抽取</h1><hr><br>';
$d_ring_r_step1=$d_ring_r->get_g_f_level_data();
//print_r($d_ring_r_step);
echo '<table border="1">'."\n";
foreach($d_ring_r_step1 as $index=>$stepdata)
{
echo '<tr>';
foreach($stepdata as $type=>$data)
{
echo "<td>";
if($type==r_mat ||$type==t_mat ||$type==m_mat)
{
$data->echo_mat();
}
elseif($type==lev)
{
echo '抽取了要素:<br>';
foreach($data as $e)
{
echo $e.'也就是-->';
$name=$d_ring_r->element_name[$e];
echo $name;
echo '<br>';
}
echo '<br>';
}
else
{
print_r($data);
}
echo "</td>";
}
echo '</tr>';
}
echo "</table>\n";
echo '<br><h1>骨架矩阵</h1><hr><br>';
$s=$d_ring_r;
//print_r($s);
echo "缩减后的矩阵=";
$s->echo_mat();
$si=$s->i();
//print_r($si);
echo "对应单位矩阵i=";
$si->echo_mat();
$s_i=$s->minus($si);
//print_r($s_i);
echo "R-I=";
$s_i->echo_mat();
$s2=$s_i->muti($s_i);
$the_s=$s->minus($s2);
echo "骨架矩阵=R-(R-I)的平方=";
$the_s->echo_mat();
echo '<br><h1>原始矩阵的骨架矩阵</h1><hr><br>';
$matrixS=$matrix_A->s_mat();
$matrixS1=$matrix_B->s_mat();
echo "原始矩阵的骨架矩阵没有去掉区域划分与环路的=";
$matrixS->echo_mat();
echo "相乘矩阵的的骨架矩阵没有去掉区域划分与环路的=";
$matrixS1->echo_mat();
echo "上面两个应该相同的,下面一个是缩减后的";
$v1=$d_ring_r->s_mat();
$v1->echo_mat();
echo '<br><h1>矩阵的另外表示法</h1><hr><br>';
$d_ring_r_step1=$d_ring_r->get_g_f_level_data();
$d_ring_r->echo_e();
//print_r($d_ring_r_step1);
//$d_ring_r_step1->echo_level();
echo '<br><h1>再回来看以原因优先的方法对缩减矩阵进行层级抽取</h1><hr><br>';
$d_ring_r_step1=$d_ring_r->get_g_f_level_data();
//print_r($d_ring_r_step);
echo '<table border="1">'."\n";
echo '<tr><td>可达集合</td><td>先行集合</td><td>两者的交集</td><td>先行集合=交集</td></tr>';
foreach($d_ring_r_step1 as $index=>$stepdata)
{
echo '<tr>';
foreach($stepdata as $type=>$data)
{
echo "<td>";
if($type==r_mat ||$type==t_mat ||$type==m_mat)
{
$data->echo_e();
}
elseif($type==lev)
{
echo '抽取了要素:<br>';
foreach($data as $e)
{
echo $e.'也就是-->';
$name=$d_ring_r->element_name[$e];
echo $name;
echo '<br>';
}
echo '<br>';
}
else
{
print_r($data);
}
echo "</td>";
}
echo '</tr>';
}
echo "</table>\n";
echo '<br><h1>再回来看以原因优先的方法对最古老的可达阵进行层级抽取</h1><hr><br>';
$levstep=$matrix_A->r_mat()->get_g_f_level_data();
//print_r($d_ring_r_step);
echo '<table border="1">'."\n";
echo '<tr><td>可达集合</td><td>先行集合</td><td>两者的交集</td><td>先行集合=交集</td></tr>';
foreach($levstep as $index=>$stepdata)
{
echo '<tr>';
foreach($stepdata as $type=>$data)
{
echo "<td>";
if($type==r_mat ||$type==t_mat ||$type==m_mat)
{
$data->echo_e();
}
elseif($type==lev)
{
echo '抽取了要素:<br>';
foreach($data as $e)
{
echo $e.'也就是-->';
$name=$matrix_A->r_mat()->element_name[$e];
echo $name;
echo '<br>';
}
echo '<br>';
}
else
{
print_r($data);
}
echo "</td>";
}
echo '</tr>';
}
echo "</table>\n";
echo "上面的,请各位留意,貌似交集就是就不是单位矩阵。";
echo '<br><h1>这个是活动要素的问题了,找出活动要素</h1><hr><br>';
$one=$d_ring_r_step;
$two=$d_ring_r_step1;
$one_lev=array();
$two_lev=array();
if (count($one)==count($two))
{
echo '没有算错';
}
$i=0;
foreach($one as $k=>$stepdata)
{
$one_lev[$i]=$stepdata[lev];
$i++;
}
$i=0;
foreach($two as $k=>$stepdata)
{
$two_lev[$i]=$stepdata[lev];
$i++;
}
for ($i=0;$i<count($one_lev);$i++)
{
if($one_lev[$i]!=$two_lev[count($one_lev)-1-$i])
{
$result = array_diff($one_lev[$i], $two_lev[count($one_lev)-1-$i]);
echo '<br>活动要素有:';
// print_r($one_lev[$i]);
// echo '----';
// print_r($two_lev[count($one_lev)-1-$i]);
// echo '----';
// print_r($result);
foreach($result as $v)
{
$name=$d_ring_r->element_name[$v];
echo $name.'、';
}
$result1 = array_diff($two_lev[count($one_lev)-1-$i],$one_lev[$i]);
echo '----这层中的---';
// print_r($one_lev[$i]);
// echo '----';
// print_r($two_lev[count($one_lev)-1-$i]);
// echo '----';
// print_r($result);
foreach($result1 as $v)
{
$name=$d_ring_r->element_name[$v];
echo $name.'、';
}
echo '<font color=blue>具体在那个层级间跳动,没有去看。⊙﹏⊙b汗一个,这个也是一个活动网络的问题的。</font><br>';
}
}
?>
</body>
</html> |