Algorithm 版 (精华区)
发信人: shs (花雨飘), 信区: Algorithm
标 题: 遗传算法(15)
发信站: 哈工大紫丁香 (Sat Sep 9 13:00:09 2000), 转信
//print_format.c
#include "f:\coy\mywork\lunwen\gaopc\thesis.h"
void print_equalities(equal,t_var,t_equ,coeff,rhs)
MATRIX equal;
VECTOR rhs;
int t_var,
t_equ;
IVECTOR coeff;
{
int i,j,flag = 0;
fprintf(output,"\n\nEQUALITIES :\n");
for(i=1; i<=t_equ; i++)
{
flag = 0;
for(j=1; j<=t_var+1; j++)
{
if((flag == 0)&&(equal[i][j] != 0.0))
{
fprintf(output," %3.2fX%d",equal[i][j],coeff[j]);
flag = 1;
}
else if(j == t_var + 1)
fprintf(output," = %3.2f\n",rhs[i]);
else if(equal[i][j] < 0.0)
fprintf(output," - %3.2fX%d",fabs(equal[i][j]),coeff[j]);
else if(equal[i][j] > 0.0)
fprintf(output," + %3.2fX%d",fabs(equal[i][j]),coeff[j]);
}
}
}
void print_inequalities(equal,t_var,t_equ,coeff,ineq_rhs)
MATRIX equal;
VECTOR ineq_rhs;
int t_var,
t_equ;
IVECTOR coeff;
{
int i,j,flag = 0;
fprintf(output,"\n\nINEQUALITIES :\n");
for(i=1; i<=t_equ; i++)
{
flag = 0;
for(j=1; j<=t_var+1; j++)
{
if((flag == 0)&&(equal[i][j] != 0.0))
{
fprintf(output," %3.2fX%d",equal[i][j],coeff[j]);
flag = 1;
}
else if(j == t_var + 1)
fprintf(output," <= %3.2f\n",ineq_rhs[i]);
else if(equal[i][j] < 0.0)
fprintf(output," - %3.2fX%d",fabs(equal[i][j]),coeff[j]);
else if(equal[i][j] > 0.0)
fprintf(output," + %3.2fX%d",fabs(equal[i][j]),coeff[j]);
}
}
}
void print_domains(equal,t_equ)
MATRIX equal;
int t_equ;
{
int i,j,temp;
fprintf(output,"\n\nDOMAINS :\n");
for(i=1; i<=t_equ; i++)
{
for(j=1; j<=3; j++)
{
if(j == 2)
fprintf(output," <= X%-2d <= ",(int)equal[i][j]);
else
fprintf(output," %3.2f ",equal[i][j]);
}
fprintf(output,"\n");
}
}
--
○/ V/\V \
\ㄨ/<○> ┃
○<><┃><//>
((<\\> ))
\○/ ┃/\
脖子扭扭,屁股扭扭,大家一起来跳舞
※ 修改:.shs 于 Sep 9 12:57:52 修改本文.[FROM: as.hit.edu.cn]
※ 来源:.武汉白云黄鹤站 bbs.whnet.edu.cn.[FROM: 211.69.196.11]
--
※ 转寄:.武汉白云黄鹤站 bbs.whnet.edu.cn.[FROM: as.hit.edu.cn]
--
☆ 来源:.哈工大紫丁香 bbs.hit.edu.cn.[FROM: shs.bbs@bbs.whnet.ed]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:2.328毫秒