forked from ssarkar2/cvx4py
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cvx4py.py
26 lines (18 loc) · 821 Bytes
/
cvx4py.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from cvxParser import cvxParser
class cvx4py(object):
def __init__(self, cvxProgram, readFromFile, locals):
if readFromFile == 0:
self.cvxProgramString = cvxProgram
else:
with open(cvxProgram, 'r') as cvxProg:
self.cvxProgramString = cvxProg.read()
# always append a newline to the end
self.cvxProgramString = self.cvxProgramString.split('\n')
self.cvxProgramString = '\n'.join(line.strip() for line in self.cvxProgramString)
self.cvxProgramString += '\n'
self.locals = locals
def solve(self):
print "solving..."
print self.cvxProgramString
self.parserObj = cvxParser() #create a parser class and hen call the aprse function on it.
self.parserObj.parse(self.cvxProgramString)