Skip to content

Commit

Permalink
optional import linear programming
Browse files Browse the repository at this point in the history
  • Loading branch information
afourmy committed Feb 24, 2018
1 parent d9b4154 commit b881a59
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
8 changes: 6 additions & 2 deletions algorithms/linear_programming.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
from .base_algorithm import *
from cvxopt import matrix, glpk, solvers
from itertools import chain, combinations
from numpy import concatenate, eye, float, full, ones, vstack, zeros
try:
from cvxopt import matrix, glpk, solvers
from numpy import concatenate, eye, float, full, ones, vstack, zeros
except ImportError:
import warnings
warnings.warn('cvxopt/numpy import failed: linear programming will not work')


class LinearProgramming(BaseAlgorithm):
Expand Down
2 changes: 1 addition & 1 deletion algorithms/local_optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def pairwise_exchange(self, ga_solution=None):
tours.append(solution)
lengths.append(best)
stable = False
if ga_solution:
if ga_solution:
return tours[-1]
return [self.format_solution(step) for step in tours], lengths

Expand Down
1 change: 1 addition & 0 deletions flask_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,6 @@ def genetic_algorithm(data):
session['best'] = length
emit('draw', ([best], [length]))


if __name__ == '__main__':
socketio.run(app)

0 comments on commit b881a59

Please sign in to comment.