From 77ce72ec9b5c56740d83e13a33267a9f67dca12c Mon Sep 17 00:00:00 2001
From: asilador <asilador@illinois.edu>
Date: Mon, 13 Feb 2017 22:26:16 -0600
Subject: [PATCH] Update

---
 Assignment 1/assignment1.py | 30 +++++++++++++++++++-----------
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/Assignment 1/assignment1.py b/Assignment 1/assignment1.py
index 3421540..a8bb96f 100644
--- a/Assignment 1/assignment1.py	
+++ b/Assignment 1/assignment1.py	
@@ -1,4 +1,4 @@
-import numpy as np
+iimport numpy as np
 # Initialize iteration counter
 # Import text files 
 Q = np.asmatrix(np.loadtxt('Q.txt'))
@@ -31,7 +31,7 @@ def armijo(alpha0,Q,b,c,D,m):
 		return alpha
 	else: 
 		m+=1
-		print('m is ', m)
+		#print('m is ', m)
 		alpha = beta**m*s
 		alpha = armijo(alpha,Q,b,c,D,m)
 		
@@ -39,22 +39,22 @@ def armijo(alpha0,Q,b,c,D,m):
 		
 def xval():
 	return x
-	
+
 def countval():
 	return count
 
 # Begin Gradient Descent Algorithm
-def grad_opt(epsilon):
-	x = xval()
-	count = countval()
+def grad_opt(epsilon,x,count):
+	
+	
 	alpha = armijo(alpha0,Q,b,c,D,m)
-	print('m is ', m)
+	print('alpha is ', alpha)
 	f1 = f(Q,b,c,x)
 	x = x - alpha*np.transpose(gradf(Q,b,x))*(np.identity(np.size(b)))*gradf(Q,b,x)
 	if np.linalg.norm(gradf(Q,b,x))>= epsilon:
 		count += 1
-		print('f(x*) is ', f(Q,b,c,x))
-		grad_opt(epsilon)
+		print('x is ', x)
+		grad_opt(epsilon,x,count)
 		return 0
 	else:
 		print('Done')
@@ -62,8 +62,16 @@ def grad_opt(epsilon):
 		print('f(x*) is ', f(Q,b,c,x))
 		print('epsilon is ', epsilon)
 		return 0
-		
-grad_opt(0.1)
+
+
+def run(epsilon):
+	xstart = xval()
+	countstart = countval()
+	epsilon = 0.1
+	grad_opt(epsilon,xstart,countstart)
+	
+
+
 
 		
 		
-- 
GitLab