一些C程序运筹学文档格式.docx
- 文档编号:20671904
- 上传时间:2023-01-25
- 格式:DOCX
- 页数:6
- 大小:18.95KB
一些C程序运筹学文档格式.docx
《一些C程序运筹学文档格式.docx》由会员分享,可在线阅读,更多相关《一些C程序运筹学文档格式.docx(6页珍藏版)》请在冰豆网上搜索。
init(node
*son){
i;
next=son;
for(i=0;
i<
n;
i++)
son->
staus[i]=0;
branch(){
i,t,j;
diff,sum=0,sum_value=0;
*head,*sonbrother,*father,*son,*prenode,*p,*q;
head=prenode=(node
*)malloc(len);
father=(node
init(prenode,father);
bound=32768;
while(head->
next!
=NULL)
{
/*1*/
son=(node
init(father,son);
n&
&
staus[i]!
=0;
staus[i]=father->
staus[i];
t=i;
staus[t]=-(t+1);
sum=0;
sum_value=0;
for(j=0;
j<
t+1&
staus[j]!
j++)
if(son->
staus[j]>
0)
{sum=sum+weight[item[j]];
sum_value=sum_value+value[item[j]];
while(sum!
=wl&
staus[n-1]==0)
{diff=wl-(sum+weight[item[j]]);
if(diff>
=0)
else
{sum=wl;
sum_value=sum_value+(1+diff/weight[item[j]])*value[item[j]];
j++;
bound=sum_value;
/*2*/
sonbrother=(node
init(son,sonbrother);
t;
sonbrother->
staus[t]=t+1;
if(sonbrother->
if(sum>
wl)
{sonbrother->
bound=-32768;
dele(son,sonbrother);
{while(sum!
dele(prenode,father);
father=prenode->
staus[n-1]!
{if(son->
{max_value=sonbrother->
state[i]=sonbrother->
{max_value=son->
state[i]=son->
q=head;
p=head->
while((p!
=NULL)&
(p->
bound<
=max_value))
{dele(q,p);
p=q->
if(p!
{prenode=q;
father=p;
if(father->
{prenode=prenode->
father=father->
getmin(){
amin=weight[0];
for(i=1;
if(amin>
weight[i])
amin=weight[i];
return
amin;
sort(){
i,j,exchange=1;
temp1,temp2;
ratio[i]=value[i]/weight[i];
for(j=n-1;
j>
=0&
exchange==1;
j--)
{exchange=0;
j;
if(ratio[i+1]>
ratio[i])
{exchange=1;
temp1=ratio[i+1];
ratio[i+1]=ratio[i];
ratio[i]=temp1;
temp2=item[i+1];
item[i+1]=item[i];
item[i]=temp2;
main(){
i,j;
clrscr();
printf("
Welcome
to
the
BRANCH_BOUND
system!
"
);
number
of
materials=?
"
scanf("
%d"
&
n);
maximun
weigh
problem=?
wl);
{item[i]=i;
*******************"
input
item%d
data!
i+1);
*******************"
weight
%d=?
%f"
weight[i]);
value
value[i]);
if((getmin())>
{printf("
There
is
no
solution
problem!
exit(0);
sum=sum+weight[i];
if(sum<
=wl)
All
materials
can
be
loaded!
sort();
branch();
The
maximum
%f
max_value);
including
following
materials"
if(state[i]>
{sum=sum+weight[item[i]];
%d"
item[i]+1);
sum);
getch();
(2)CHAIN:
马尔可夫链算法#include
#include
double
a[10][10];
Guass(int
n){
i,j,k;
for(k=0;
k<
n-1;
k++)
{t=a[k][k];
for(j=k;
a[k][j]=a[k][j]/t;
if(i!
=k)
{t=a[i][k]/a[k][k];
a[i][j]=a[i][j]-a[k][j]*t;
chain(){
static
p[10][10],pr[10],diff,table[100][10],pnew[10][10],ptemp[10][10],temp[10],exr[10][10];
n,i,j,k,s,m,found,inr,inc;
Welcome
MARKOV
CHAIN
ANALYSIS
how
many
states
=?
the
steady
transmit
possibility
step
1
?
%lf"
p[i][j]);
initiate
state
pr[i]);
pnew[i][j]=p[i][j];
table[0][i]=pr[i];
1"
%f"
p[i][j]);
for(k=2;
100;
{for(j=0;
{temp[j]=0;
temp[j]=temp[j]+pr[i]*pnew[i][j];
table[k-1][i]=temp[i];
{ptemp[i][j]=0;
for(m=0;
m<
m++)
ptemp[i][j]=ptemp[i][j]+p[i][m]*pnew[m][j];
pnew[i][j]=ptemp[i][j];
{for(i=0;
for(m=i+1;
{diff=pnew[i][j]-pnew[m][j];
if(diff<
diff=-diff;
{found=0;
break;
found=1;
if(found==0)
{if(k%5==0)
k);
pnew[i][j]);
if(k>
=100)
steady_state
probability
have
not
been
detained
in
100"
step
table[k][i]=temp[i];
steady-state
being
%d
j,pnew[n-1][j]);
state"
=k;
i);
%f"
table[i][j]);
if(i%10==0)
for(s=0;
s<
s++)
inr=0;
if(j==s)
continue;
{inc=0;
if(i==s)
a[inr][inc]=-p[j][i];
if(j==i)
a[inr][inc]=1+a[inr][inc];
inc++;
inr++;
a[i][n-1]=1;
Guass(n);
i=0;
if(j!
=s)
exr[j][s]=a[i++][n-1];
exr[j][s]=1/pnew[n-1][s];
Table
expected
first
passage
times
and
recurrence
times"
%d"
exr[i][j]);
}}
chain();
(3)DECISION:
贝叶斯决策方法#include
pi
p(x,t)
exp(-(x-t)*(x-t)/20)/sqrt(20*pi)
decision(){
i,j,type,m,n,flag,state[5],index;
xx,a[5][5],p[5],e[5],sum,decision;
DECISION_STSTEM!
type
problem,max(key
0?
)or
min(key
1?
)?
type);
type
decision,without
data(key?
with
flag);
actions
m);
nature
t%d"
j+1);
m;
A%d"
a[i][j]);
natural
states=?
p[j]);
if(flag)
given
data=?
xx);
nature=?
state[j]);
sum+=p[j]*p(xx,state[j]);
p[j]=p[j]*p(xx,state[j])/sum;
{sum=0;
sum+=p[j]*a[i][j];
e[i]=sum;
decision=e[0];
index=1;
if(type==0)
if(decision<
e[i])
{decision=e[i];
index=i+1;
if(decision>
**********"
Results:
loss
for
each
course
action
based
on
prior
distribution"
e[i]);
optimum
decision);
choose
A(
)"
index);
decision();
(4)dp_invest:
动态规划的投资问题#include
istar[10];
dp_invest(int
N,int
K){
i,j,sum,z,d[10][50];
g[10][50],f[10][50];
function
values
as
follows!
K+1;
j);
N;
task%d:
g[i][j]);
{f[i][j]=0;
d[i][j]=0;
{f[N-1][j]=g[N-1][j];
d[N-1][j]=j;
for(i=N-2;
i>
i--)
for(j=1;
{f[i][j]=g[i][0]+f[i+1][j];
for(z=1;
z<
=j;
z++)
if((g[i][z]+f[i+1][j-z])>
f[i][j])
{f[i][j]=g[i][z]+f[i+1][j-z];
d[i][j]=z;
istar[0]=d[0][K];
=i-1;
sum=sum+istar[j];
istar[i]=d[i][K-sum];
f[0][K];
i,N,K;
WELCOME
TO
THE
DYNAMIC_INVEST
SYSTEM!
How
tasks
N);
How
units
K);
optimal
dp_invest(N,K));
amout
invest
task
i+1,istar[i]);
(5)dp_plan:
生产计划算法#include
pc(j)
20+5*j#define
e(j)
j
dp_plan(){
i,j,k,sum,limit,n,io,max_st
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 一些 程序 运筹学
