求Petri网的S-不变量和T-不变量的程序

王朝other·作者佚名  2006-01-09
宽屏版  字体: |||超大  

////求Petri网的S-不变量和T-不变量的程序,给出的是求T不变量的,求S-不变量只需要将矩阵转置。Petri网

/////经常用于通信和网络协议的验证,但是直接由矩阵求不变量非常麻烦,故本文将代码共享。

#include <iostream.h>

#include <math.h>

int main()

{

int row,column;

int matrix[50][50]; ////Petri网关联矩阵

int answer[50]; ///求得的不变量

cout << "please input the row num of matrix:" ;

cin >> row;

cout << "please input the column num of matrix:" ;

cin >> column;

cout << "please input information of matrix:" << endl;

for(int i=0;i<row;i++)

{

for(int j=0;j<column;j++)

{

cin >> matrix[i][j];

}

}

long power=pow(2,column);

int total[50];

for(i=1;i<power;i++)

{

for(int j=0;j<column;j++)

{

answer[j]=(i>>j)&0x01;

}

for(int x=0;x<row;x++)

{

total[x]=0;

for(int y=0;y<column;y++)

{

total[x]+=answer[y]*matrix[x][y];

}

if(total[x]!=0)

break;

}

if(x==row)

{

cout << "get a column sequence:" << endl;

for(x=0;x<column;x++)

{

cout << answer[x] << " ";

}

cout << endl;

}

}

}

月影孤鸿 华中科技大学计算机学院 21cnbao@sohu.com

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有