Algorithm 版 (精华区)
发信人: shs (花雨飘), 信区: Algorithm
标 题: 遗传算法(16)
发信站: 哈工大紫丁香 (Sat Sep 9 13:00:15 2000), 转信
//read_write.c
#include "f:\coy\mywork\lunwen\gaopc\thesis.h"
void read_file(equalities,inequalities,domains,tot_arr)
MATRIX equalities,inequalities,domains;
IVECTOR tot_arr;
{
int t2,i,j,total_variables;
float t1,t3;
if(tot_arr[1] != 0)
for(i=1; i<=tot_arr[1]; i++)
for(j=1; j<=tot_arr[0] + 1; j++)
fscanf(input," %f",&equalities[i][j]);
if(tot_arr[2] != 0)
for(i=1; i<=tot_arr[2]; i++)
for(j=1; j<=tot_arr[0]+1; j++)
fscanf(input," %f",&inequalities[i][j]);
for(i=1; i<=tot_arr[0]; i++)
{
domains[i][1] = MIN;
domains[i][2] = (float) i;
domains[i][3] = MAX;
}
if(tot_arr[3] != 0)
for(i=1; i<=tot_arr[3]; i++)
{
fscanf(input," %f %d %f",&t1,&t2,&t3);
domains[t2][1] = t1;
domains[t2][3] = t3;
}
}
void write_file(final_mat,fin,a1_b,x1,x2,x1_row,x2_row,in)
MATRIX final_mat;
VECTOR a1_b;
IVECTOR x1,x2;
INDEX fin;
int x1_row,x2_row,in;
{
int i,j,k=1;
fprintf(output,"Left\t\t");
for(j=1; j<=fin.c-2; j++)
fprintf(output," X%d\t",x2[j]);
fprintf(output,"\tRight\n");
for(i=1; i<=fin.r; i++)
{
for(j=1; j<=fin.c; j++)
{
if (((j==2)&&(i<in))||(j==fin.c))
fprintf(output,"\t");
fprintf(output,"%5.2f\t",final_mat[i][j]);
}
fprintf(output,"\n");
}
fprintf(output,"\n\n\n\n\t");
for(j=1; j<=fin.c-2; j++)
fprintf(output," X%d\t",x2[j]);
fprintf(output,"const\n\n");
for(i=x2_row+1; i<=x2_row+x1_row; i++)
{
fprintf(output,"X%d\t",x1[k]);
for(j=2; j<fin.c; j++)
fprintf(output,"%5.2f\t",final_mat[i][j]);
fprintf(output,"%5.2f\n",a1_b[k++]);
}
}
--
○/ V/\V \
\ㄨ/<○> ┃
○<><┃><//>
((<\\> ))
\○/ ┃/\
脖子扭扭,屁股扭扭,大家一起来跳舞
※ 修改:.shs 于 Sep 9 12:57:58 修改本文.[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.422毫秒