-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stiefel Manifold #264
Comments
Hi, I also tried a simple Stiefel Manifold optimization with exact penalty and it does not converge, either. However, when I use the Sphere Manifold optimization with exact penalty, it will converge. I do not know the reason and hope your kind advice. Here, I have attached my code. def arraysteering(self,beam,ra,rd):
W=torch.tensor(beam)
Du=torch.tensor(self.Du)
D=torch.tensor(self.D)
rou=1.0
rou_max=2**(20)
theta_rou=2.0
miu=1.0
min_miu=10**(-6)
theta_miu=(min_miu/miu)**(1/30)
diff=1.0
ts=0.01
r1=rd.H
r2=ra.H
while diff > ts:
init_ori=np.zeros(shape=(3,2))
init_ori[:,0]=np.array(r1).squeeze()
init_ori[:,1]=np.array(r2).squeeze()
manifold=Stiefel(3,2)
@pymanopt.function.pytorch(manifold)
def cost(A):
a=torch.tensor(1j*np.zeros(shape=(self.T+self.K,self.N)))
for i in range(self.T+self.K):
for j in range(self.N):
a[i,j]=self.alpha*torch.sin(torch.arccos(A[:,0]@Du[:,i]))*torch.complex(torch.cos(j*torch.pi*Du[:,i]@A[:,1]),torch.sin(-j*torch.pi*Du[:,i]@A[:,1]))
obj_2=0
for i in range(self.T):
for j in range(self.K):
obj_2=obj_2-torch.linalg.norm(a[self.K+i,:]@W[:,j])**2
for i in range(self.K):
sig_p=torch.linalg.norm(1/self.npower*torch.sqrt(torch.tensor(self.beta))/torch.linalg.norm(D[:,i])*a[i,:]@W[:,i])**2
int_p=-sig_p
for j in range(self.K):
int_p=int_p+torch.linalg.norm(1/self.npower*torch.sqrt(torch.tensor(self.beta))/torch.linalg.norm(D[:,i])*a[i,:]@W[:,j])**2
obj_2=obj_2+rou*miu*torch.log2(1+torch.exp((self.QoS-sig_p/(int_p+1))/miu))
return obj_2
prob_2=pymanopt.Problem(manifold, cost)
optimizer=pymanopt.optimizers.ConjugateGradient()
Ori=np.matrix(optimizer.run(prob_2, initial_point=init_ori).point)
r1=np.matrix(np.copy(Ori[:,0]))
r2=np.matrix(np.copy(Ori[:,1]))
diff=np.linalg.norm(Ori[:,0]-init_ori[:,0])+np.linalg.norm(Ori[:,1]-init_ori[:,1])
rou=min(theta_rou*rou, rou_max)
miu=max(theta_miu*miu, min_miu)
Ori_opt=np.matrix(np.zeros(shape=(3,2)))
Ori_opt[:,0]=np.matrix(np.copy(r1))
Ori_opt[:,1]=np.matrix(np.copy(r2))
return Ori_opt Best regards, |
I do not work much with the Python package here (I am the Julia variant person ;)) But the first thing I do not understand is why A only appears in the constraints. Doesn't that make A a parameter one can just choose and then finding max z Is easy? Or are you maximising over all A? Then I do not understand wh your cost would then be the constant z. For your switch of the manifolds, you would then switch from For the code I can sadly not contribute much , as I said I do not program in Python (much), and especially never used pytorch. |
Hi, Thanks great a lot for your response! Let me explain my problem more clearly. My original problem P1 is:
So r1 and r2 lie in the Stiefel Manifold. Problem P1 is equivalent to problem P2:
With block coordinate descent, I optimize z and w using convex optmization. Then the left problem P3 for optimizing r1 and r2 is:
where z and w are constants optimized before. To solve P3, I use exact penalty method and get problem P4:
where m and n are penalty factor and smoothing factor, respectively. I start with a small m and iteratively increase m and optimize A untill convergence. However, the objective function of P4 keeps increasing during the iteration because of the increase of m. Best regards, |
Hi, I See that your r2 has to have a norm of 2, but both Stiefel (second column) or Sphere (second component) would yield norm 1, does that make a difference?
I do not understand this in that shortage, since there might just be too many things called “trick”. Overall I would probably prefer to go for P1 directly, I am not sure why you rephrase that. Just as a side remark – If you want to have something to compare to, there is
|
Hi, Thanks great a lot for your help! And I solved my problem, because I made a mistake with the dimension of the output of the optimization problem. However, I found that the simulation time of using Stiefel manifold was much longer than using Sphere manifold. Is it due to that the retraction steps of Stiefel manifold is more complex than Sphere manifold? Best regards, |
I still have not understood the “orthogonality trick”, but well – great that it works now! “Much longer” is a bit vague and hard to tell. Does it take much more steps? Or the same number of steps? |
Hi,
In my problem, my optimization variable lies in a Stiefel Manifold
A (3x2)
. My original problemP1
is:Then I use exact penalty to transform the original problem into a standard unconstrained manifold optimization problem
P2
as:where
z
,Q
are constants,a
is the penalty factor andb
is the smoothing factor. To solve this problem, I increasea
and decreaseb
to iteratively optimizeA
until convergence. However, the objective function ofP2
just increases with the increase of penalty factora
and doesn't converge to-z
. The original problem is to find the feasible solution and I do not know whether my transformation could work well and I cannot understand why the object function ofP2
just increase until+nan
with iteration.I really need your help and hope for your response!
Best regards,
Fengcheng Pei
The text was updated successfully, but these errors were encountered: