#include <iostream>
#include <math.h>
#include <vector>
using namespace std;
pair<float,float> SubSys2(float x6up,float x11up,float Ar,float Ay,float Wr,float Wy)
{
float x6,x11,x12,x13,x14;
float f;
float t;
int stn11=1;
int stn12=1;
int stn13=1;
int stn14=1;
for(int i=1;i<4;i++)
{
x11=i*1;
for(int j=1;j<4;j++)
{
x12=j*1;
for(int k=1;k<4;k++)
{
x13=k*1;
for(int m=1;m<4;m++)
{
x14=m*1;
if(((x11*x11+1/x12/x12)/x13/x13<=1)&&((x11*x11+x12*x12)/x14/x14<=1))
{
x6=sqrt(x11*x11+x12*x12+x13*x13+x14*x14);
f=-Ar*x6+Wr*(x6-x6up)*(x6-x6up)-Ay*x11+Wy*(x11-x11up)*(x11-x11up);
i=40;
j=40;
k=40;
m=40;
}
}
}
}
}
for(int i=1;i<40;i++)
{
x11=i*0.1;
for(int j=1;j<40;j++)
{
x12=j*0.1;
for(int k=1;k<40;k++)
{
x13=k*0.1;
for(int m=1;m<40;m++)
{
x14=m*0.1;
if(((x11*x11+1/x12/x12)/x13/x13<=1)&&((x11*x11+x12*x12)/x14/x14<=1))
{
x6=sqrt(x11*x11+x12*x12+x13*x13+x14*x14);
t=-Ar*x6+Wr*(x6-x6up)*(x6-x6up)-Ay*x11+Wy*(x11-x11up)*(x11-x11up);
if(f>t)
{
f=t;
stn11=i;
stn12=j;
stn13=k;
stn14=m;
}
}
}
}
}
}
//for(int i=stn11*5-5;i<stn11*5+5;i++)
//{
// x11=i*0.1;
// for(int j=stn12*5-5;j<stn12*5+5;j++)
// {
// x12=j*0.1;
// for(int k=stn13*5-5;k<stn13*5+5;k++)
// {
// x13=k*0.1;
// for(int m=stn14*5-5;m<stn14*5+5;m++)
// {
// x14=m*0.1;
// if(((x11*x11+1/x12/x12)/x13/x13<=1)&&((x11*x11+x12*x12)/x14/x14<=1))
// {
// x6=sqrt(x11*x11+x12*x12+x13*x13+x14*x14);
// t=Ar*(x6-x6up)+Wr*(x6-x6up)*(x6-x6up)+Ay*(x11-x11up)+Wy*(x11-x11up)*(x11-x11up);
// if(f>t)
// {
// f=t;
// stn11=i;
// stn12=j;
// stn13=k;
// stn14=m;
// }
// }
// }
// }
// }
//}
x11=stn11*0.1;
x12=stn12*0.1;
x13=stn13*0.1;
x14=stn14*0.1;
x6=sqrt(x11*x11+x12*x12+x13*x13+x14*x14);
return(pair<float,float>(x11,x6));
}
pair<float,float> SubSys1(float x3up,float x11up,float Ar,float Ay,float Wr,float Wy)
{
float x3,x11,x8,x9,x10;
float f;
float t;
int stn3=1;
int stn8=1;
int stn9=1;
int stn10=1;
int stn11=1;
for(int i=1;i<40;i++)
{
x8=i*1;
for(int j=1;j<40;j++)
{
x9=j*0.1;
for(int k=1;k<40;k++)
{
x10=k*0.1;
for(int m=1;m<40;m++)
{
x11=m*0.1;
if(((x8*x8+x9*x9)/x11/x11<=1)&&((1/x8/x8+x10*x10)/x11/x11<=1))
{
x3=sqrt(x8*x8+1/x9/x9+1/x10/x10+x11*x11);
f=-Ar*x3+Wr*(x3-x3up)*(x3-x3up)-Ay*x11+Wy*(x11-x11up)*(x11-x11up);
i=40;
j=40;
k=40;
m=40;
}
}
}
}
}
for(int i=1;i<40;i++)
{
x8=i*0.1;
for(int j=1;j<40;j++)
{
x9=j*0.1;
for(int k=1;k<40;k++)
{
x10=k*0.1;
for(int m=1;m<40;m++)
{
x11=m*0.1;
if(((x8*x8+x9*x9)/x11/x11<=1)&&((1/x8/x8+x10*x10)/x11/x11<=1))
{
x3=sqrt(x8*x8+1/x9/x9+1/x10/x10+x11*x11);
t=-Ar*x3+Wr*(x3-x3up)*(x3-x3up)-Ay*x11+Wy*(x11-x11up)*(x11-x11up);
if(t<f)
{
f=t;
stn8=i;
stn9=j;
stn10=k;
stn11=m;
}
}
}
}
}
}
//for(int i=stn8*5-5;i<stn8*5+5;i++)
//{
// x8=i*0.1;
// for(int j=stn9*5-5;j<stn9*5+5;j++)
// {
// x9=j*0.1;
// for(int k=stn10*5-5;k<stn10*5+5;k++)
// {
// x10=k*0.1;
// for(int m=stn11*5-5;m<stn11*5+5;m++)
// {
// x11=m*0.1;
// if(((x8*x8+x9*x9)/x11/x11<=1)&&((1/x8/x8+x10*x10)/x11/x11<=1))
// {
// x3=sqrt(x8*x8+1/x9/x9+1/x10/x10+x11*x11);
// t=Ar*(x3-x3up)+Wr*(x3-x3up)*(x3-x3up)+Ay*(x11-x11up)+Wy*(x11-x11up)*(x11-x11up);
// if(t<f)
// {
// f=t;
// stn8=i;
// stn9=j;
// stn10=k;
// stn11=m;
// }
// }
// }
// }
// }
//}
x8=stn8*0.1;
x9=stn9*0.1;
x10=stn10*0.1;
x11=stn11*0.1;
x3=sqrt(x8*x8+1/x9/x9+1/x10/x10+x11*x11);
return(pair<float,float>(x11,x3));
}
vector<float> Sys(float x3l,float x6l,float x11l1,float x11l2,float Ar1,float Ar2,float Ay1,float Ay2,float Wr1,float Wr2,float Wy1,float Wy2)
{
float x1,x2,x3,x4,x5,x6,x7,x11;
float Ry,f,t;
vector<float> res;
int stn3=1;
int stn4=1;
int stn5=1;
int stn6=1;
int stn7=1;
int stn11=1;
for(int i=1;i<4;i++)
{
x3=i*1;
for(int j=1;j<4;j++)
{
x4=j*1;
for(int k=1;k<4;k++)
{
x5=k*1;
for(int m=1;m<4;m++)
{
x6=m*1;
for(int n=1;n<4;n++)
{
x7=n*1;
x1=sqrt(x3*x3+1/x4/x4+x5*x5);
x2=sqrt(x5*x5+x6*x6+x7*x7);
if((1/x3/x3+x4*x4-x5*x5<=0)&&(x5*x5+1/x6/x6-x7*x7<=0))
{
x11=0.1;
f=x1*x1+x2*x2+Ar1*x3+Wr1*(x3-x3l)*(x3-x3l)+Ar2*x6+Wr2*(x6-x6l)*(x6-x6l)+Ay1*(x11-x11l1)+Wy1*(x11-x11l1)*(x11-x11l1)+Ay2*(x11-x11l2)+Wy2*(x11-x11l2)*(x11-x11l2);
i=40;j=40;k=40;m=40;n=40;
}
}
}
}
}
}
for(int i=1;i<40;i++)
{
x3=i*0.1;
for(int j=1;j<40;j++)
{
x4=j*0.1;
for(int k=1;k<40;k++)
{
x5=k*0.1;
for(int m=1;m<40;m++)
{
x6=m*0.1;
for(int n=1;n<40;n++)
{
x7=n*0.1;
x1=sqrt(x3*x3+1/x4/x4+x5*x5);
x2=sqrt(x5*x5+x6*x6+x7*x7);
if(((1/x3/x3+x4*x4)/x5/x5<=1)&&((x5*x5+1/x6/x6)/x7/x7<=1))
{
for(int s=0;s<40;s++)
{
x11=s*0.1;
float tmp=x1*x1+x2*x2+Ar1*x3+Wr1*(x3-x3l)*(x3-x3l)+Ar2*x6+Wr2*(x6-x6l)*(x6-x6l)+Ay1*x11+Wy1*(x11-x11l1)*(x11-x11l1)+Ay2*x11+Wy2*(x11-x11l2)*(x11-x11l2);
if(tmp<f)
{
f=tmp;
stn3=i;
stn4=j;
stn5=k;
stn6=m;
stn7=n;
stn11=s;
}
}
}
}
}
}
}
}
//for(int i=stn3*5-4;i<stn3*5+5;i++)
//{
// x3=i*0.1;
// for(int j=stn4*5-4;j<stn4*5+5;j++)
// {
// x4=j*0.1;
// for(int k=stn5*5-4;k<stn5*5+5;k++)
// {
// x5=k*0.1;
// for(int m=stn6*5-4;m<stn6*5+5;m++)
// {
// x6=m*0.1;
// for(int n=stn7*5-4;n<stn7*5+5;n++)
// {
// x7=n*0.1;
// x1=sqrt(x3*x3+1/x4/x4+x5*x5);
// x2=sqrt(x5*x5+x6*x6+x7*x7);
// if(((1/x3/x3+x4*x4)/x5/x5<=1)&&((x5*x5+1/x6/x6)/x7/x7<=1))
// {
// for(int s=stn11*5-4;s<stn11*5+5;s++)
// {
// x11=s*0.1;
// float tmp=x1*x1+x2*x2+Ar1*(x3-x3l)+Wr1*(x3-x3l)*(x3-x3l)+Ar2*(x6-x6l)+Wr2*(x6-x6l)*(x6-x6l)+Ay1*(x11-x11l1)+Wy1*(x11-x11l1)*(x11-x11l1)+Ay2*(x11-x11l2)+Wy2*(x11-x11l2)*(x11-x11l2);
// if(tmp<f)
// {
// f=tmp;
// stn3=i;
// stn4=j;
// stn5=k;
// stn6=m;
// stn7=n;
// stn11=s;
// }
// }
// }
// }
// }
// }
// }
//}
res.push_back(stn3*0.1);//0
res.push_back(stn4*0.1);
res.push_back(stn5*0.1);
res.push_back(stn6*0.1);//3
res.push_back(stn7*0.1);
res.push_back(stn11*0.1);//5
return res;
}
int main()
{
float Ar1,Ar2,Ay1,Ay2,Wr1,Wr2,Wy1,Wy2,x6l,x3l,x11l1,x11l2;
Ar1=Ar2=0;
Ay1=Ay2=0;
Wr1=Wr2=1;
Wy1=Wy2=1;
//Ar1=Ar2=0;
//Ay1=Ay2=0;
//Wr1=Wr2=0;
//Wy1=Wy2=0;
x11l1=1;
x3l=1;
x11l2=1;
x6l=1;
pair<float,float> Pair1,Pair2;
vector<float> vRes;
vRes=Sys(x3l,x6l,x11l1,x11l2,Ar1,Ar2,Ay1,Ay2,Wr1,Wr2,Wy1,Wy2);
float x3up=vRes[0];
float x6up=vRes[3];
float x11up=vRes[5];
Pair1=SubSys1(x3up,x11up,Ar1,Ay1,Wr1,Wy1);
Pair2=SubSys2(x6up,x11up,Ar2,Ay2,Wr2,Wy2);
for(int i=1;i<50;i++)
{
x11l1=Pair1.first;
x3l=Pair1.second;
x11l2=Pair2.first;
x6l=Pair2.second;
//Ar1=Ar1+2*Wr1*Wr1*(vRes[0]-x3l);
//Ar2=Ar2+2*Wr2*Wr2*(vRes[3]-x6l);
//Ay1=Ay1+2*Wy1*Wy1*(vRes[5]-x11l1);
//Ay2=Ay2+2*Wy2*Wy2*(vRes[5]-x11l2);
Wr1=2*Wr1;
Wr2=2*Wr2;
Wy1=2*Wy1;
Wy2=2*Wy2;
//Ar1=Ar1+0.3*(vRes[1]-Rrlow2);
//Ar2=Ar2+0.3*(vRes[2]-Rrlow2);
//Ay1=Ay1+
评论0