unittest/python/crocoddyl/kkt.py
def solve(self, maxiter=100, init_xs=None, init_us=None, isFeasible=False, verbose=False):
        '''
        From an initial guess init_xs,init_us (feasible or not),
        iterate over computeDirection and tryStep until stoppingCriteria is below threshold.
        '''
        self.setCandidate(init_xs, init_us, isFeasible)
        for i in range(maxiter):
            self.computeDirection()
            d1, d2 = self.expectedImprovement()

            for a in self.alphas:
                dV = self.tryStep(a)
                if verbose:
                    print('\t\tAccept? %f %f' % (dV, d1 * a + .5 * d2 * a**2))
                if d1 < 1e-9 or not isFeasible or dV > self.th_acceptStep * (d1 * a + .5 * d2 * a**2):
                    # Accept step
                    self.setCandidate(self.xs_try, self.us_try, isFeasible=True)
                    break
            if verbose:
                print('Accept iter=%d, a=%f, cost=%.8f' % (i, a, self.problem.calc(self.xs, self.us)))

            self.stop = sum(self.stoppingCriteria())
            if self.stop < self.th_stop:
                return self.xs, self.us, True
            # if d1<self.th_grad:
            #     return self.xs,self.us,False

        # Warning: no convergence in max iterations
        return self.xs, self.us, False

        From an initial guess init_xs,init_us (feasible or not),
        iterate over computeDirection and tryStep until stoppingCriteria is below threshold.
        
From an initial guess init_xs,init_us (feasible or not),
iterate over computeDirection and tryStep until stoppingCriteria is below threshold.
From an initial guess init_xs init_us ( feasible or not ) iterate over computeDirection and tryStep until stoppingCriteria is below threshold .
def solve(self, maxiter=100, init_xs=None, init_us=None, isFeasible=False, verbose=False):
        self.setCandidate(init_xs, init_us, isFeasible)
        for i in range(maxiter):
            self.computeDirection()
            d1, d2 = self.expectedImprovement()
            for a in self.alphas:
                dV = self.tryStep(a)
                if verbose:
                    print('\t\tAccept? %f %f' % (dV, d1 * a + .5 * d2 * a**2))
                if d1 < 1e-9 or not isFeasible or dV > self.th_acceptStep * (d1 * a + .5 * d2 * a**2):
                    self.setCandidate(self.xs_try, self.us_try, isFeasible=True)
                    break
            if verbose:
                print('Accept iter=%d, a=%f, cost=%.8f' % (i, a, self.problem.calc(self.xs, self.us)))
            self.stop = sum(self.stoppingCriteria())
            if self.stop < self.th_stop:
                return self.xs, self.us, True
        return self.xs, self.us, False
def solve ( self , maxiter = 100 , init_xs = None , init_us = None , isFeasible = False , verbose = False ) : self . setCandidate ( init_xs , init_us , isFeasible ) for i in range ( maxiter ) : self . computeDirection ( ) d1 , d2 = self . expectedImprovement ( ) for a in self . alphas : dV = self . tryStep ( a ) if verbose : print ( '\t\tAccept? %f %f' % ( dV , d1 * a + .5 * d2 * a ** 2 ) ) if d1 < 1e-9 or not isFeasible or dV > self . th_acceptStep * ( d1 * a + .5 * d2 * a ** 2 ) : self . setCandidate ( self . xs_try , self . us_try , isFeasible = True ) break if verbose : print ( 'Accept iter=%d, a=%f, cost=%.8f' % ( i , a , self . problem . calc ( self . xs , self . us ) ) ) self . stop = sum ( self . stoppingCriteria ( ) ) if self . stop < self . th_stop : return self . xs , self . us , True return self . xs , self . us , False
From an initial guess init_xs,init_us (feasible or not),
iterate over computeDirection and tryStep until stoppingCriteria is below threshold.
From an initial guess init_xs init_us ( feasible or not ) iterate over computeDirection and tryStep until stoppingCriteria is below threshold .
'''
        From an initial guess init_xs,init_us (feasible or not),
        iterate over computeDirection and tryStep until stoppingCriteria is below threshold.
        ''' # Accept step # if d1<self.th_grad: #     return self.xs,self.us,False # Warning: no convergence in max iterations
self
maxiter
init_xs
init_us
isFeasible
verbose