Changeset 1221
- Timestamp:
- 08/18/08 08:21:21 (3 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openopt/scikits/openopt/solvers/UkrOpt/ralg_oo.py
r1198 r1221 64 64 # else: b = B_constr 65 65 66 67 66 """ Ralg main cycle """ 68 67 … … 72 71 ls1 = 0 73 72 # TODO: is (g^T b)^T better? 74 g2 = self.__economyMult__(b.T, moveDirection) 75 if any(g2): g2 /= p.norm(g2) 76 g1 = p.matmult(b, g2) 77 78 x_0 = x.copy() 79 73 g_tmp = self.__economyMult__(b.T, moveDirection) 74 if any(g_tmp): g_tmp /= p.norm(g_tmp) 75 g1 = p.matmult(b, g_tmp) 80 76 81 77 """ Forward line search """ … … 87 83 if ls1 > nh: 88 84 if itn == 0: 89 hs *= 15.085 hs *= 2.0 90 86 else: 91 87 hs *= q2 … … 110 106 return 111 107 108 g2 = self.__getRalgDirection__(newPoint) # used for dilation direction obtaining 109 112 110 iterPoint = newPoint 113 114 moveDirection = self.__getRalgDirection__(iterPoint) 115 g2 = moveDirection 116 117 111 # if ls > 0: 112 # iterPoint = oldPoint 113 # else: 114 # iterPoint = newPoint 118 115 119 116 """ Backward line search """ 120 117 121 x = iterPoint.x.copy() 118 122 119 if ls == 0 and self.doBackwardSearch: 120 x_tmp = newPoint.x.copy() 123 121 PrevPoint = iterPoint 124 122 while 1: … … 127 125 128 126 if itn == 0: 129 x = p.xk - hs * g1127 x_tmp = p.xk - hs * g1 130 128 else: 131 x = 0.5*x+0.5*prevIterPoint.x129 x_tmp = 0.5*x_tmp+0.5*prevIterPoint.x 132 130 hs /= self.hmult 133 131 134 newPoint = p.point(x )132 newPoint = p.point(x_tmp) 135 133 136 134 if PrevPoint.betterThan(newPoint) or newPoint.f() > PrevPoint.f() or abs(newPoint.f() - p.fk) < 15 * p.ftol or p.norm(newPoint.x - p.xk) < 15 * p.xtol: … … 145 143 break 146 144 iterPoint = PrevPoint 147 moveDirection = self.__getRalgDirection__(iterPoint) 145 148 146 149 147 150 148 """ iterPoint has been obtained """ 151 149 150 moveDirection = self.__getRalgDirection__(iterPoint) 152 151 x = iterPoint.x.copy() 153 152 if ls <= 0: hs *= q1 … … 193 192 g = (g / ng).reshape(-1,1) 194 193 vec1 = self.__economyMult__(b, g).reshape(-1,1) 195 vec2 = p.dotmult(g.T, w)194 vec2 = w * g.T 196 195 b += p.matmult(vec1, vec2) 197 196 else: … … 259 258 """ Some final things for ralg main cycle """ 260 259 261 g = g2.copy() 260 g = moveDirection.copy() 261 #g = g2.copy() 262 262 prevIterPoint, iterPoint = iterPoint, None 263 263
