Skip to content

Commit

Permalink
Fixes for osqp > 0.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bstellato committed Jan 3, 2020
1 parent 0c4f529 commit ac67233
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 44 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,6 @@ results_bak/

# Vim backup files
*.swp
*.csv
*.tex
*.pdf
11 changes: 6 additions & 5 deletions miosqp/node.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import numpy as np
import osqp


class Node(object):
Expand Down Expand Up @@ -84,7 +85,7 @@ def __init__(self, data, l, u, solver, depth=0, lower=None,
self.y = y0

# Set QP solver return status
self.status = self.solver.constant('OSQP_UNSOLVED')
self.status = osqp.constant('OSQP_UNSOLVED')

# Add next variable elements
self.nextvar_idx = None # Index of next variable within solution x
Expand All @@ -110,8 +111,8 @@ def solve(self):
self.status = results.info.status_val

# DEBUG: Problems that hit max_iter are infeasible
# if self.status == self.solver.constant('OSQP_MAX_ITER_REACHED'):
# self.status = self.solver.constant('OSQP_PRIMAL_INFEASIBLE')
# if self.status == osqp.constant('OSQP_MAX_ITER_REACHED'):
# self.status = osqp.constant('OSQP_PRIMAL_INFEASIBLE')

# Store number of iterations
self.num_iter = results.info.iter
Expand All @@ -124,8 +125,8 @@ def solve(self):
self.y = results.y

# Enforce integer variables to be exactly within the bounds
if self.status == self.solver.constant('OSQP_SOLVED') or \
self.status == self.solver.constant('OSQP_MAX_ITER_REACHED'):
if self.status == osqp.constant('OSQP_SOLVED') or \
self.status == osqp.constant('OSQP_MAX_ITER_REACHED'):
# import ipdb; ipdb.set_trace()
n_int = self.data.n_int
i_idx = self.data.i_idx
Expand Down
14 changes: 7 additions & 7 deletions miosqp/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def set_x0(self, x0):
Set initial condition
"""

# Suppose that algorithm hasn't been run yet.
# Suppose that algorithm hasn't been run yet.
# Tree has only one leaf (root)
root = self.leaves[0]

Expand Down Expand Up @@ -193,7 +193,7 @@ def add_right(self, leaf):
# DEBUG:
if any(l_right > u_right):
import ipdb; ipdb.set_trace()

# Create new leaf
new_leaf = Node(self.data, l_right, u_right, self.solver,
depth=leaf.depth + 1, lower=leaf.lower,
Expand Down Expand Up @@ -291,8 +291,8 @@ def bound_and_branch(self, leaf):
self.osqp_solve_time += leaf.osqp_solve_time

# 1) If infeasible or unbounded, then return (prune)
if leaf.status == self.solver.constant('OSQP_PRIMAL_INFEASIBLE') or \
leaf.status == self.solver.constant('OSQP_DUAL_INFEASIBLE'):
if leaf.status == osqp.constant('OSQP_PRIMAL_INFEASIBLE') or \
leaf.status == osqp.constant('OSQP_DUAL_INFEASIBLE'):
return

# 2) If lower bound is greater than upper bound, then return (prune)
Expand Down Expand Up @@ -400,8 +400,8 @@ def print_progress(self, leaf):
gap = "%8.2f%%" % \
((self.upper_glob - self.lower_glob)/abs(self.lower_glob)*100)

if leaf.status == self.solver.constant('OSQP_PRIMAL_INFEASIBLE') or \
leaf.status == self.solver.constant('OSQP_DUAL_INFEASIBLE'):
if leaf.status == osqp.constant('OSQP_PRIMAL_INFEASIBLE') or \
leaf.status == osqp.constant('OSQP_DUAL_INFEASIBLE'):
obj = np.inf
else:
obj = leaf.lower
Expand All @@ -416,7 +416,7 @@ def print_progress(self, leaf):
leaf.depth, intinf, self.lower_glob,
self.upper_glob, gap, leaf.num_iter), end='')

if leaf.status == self.solver.constant('OSQP_MAX_ITER_REACHED'):
if leaf.status == osqp.constant('OSQP_MAX_ITER_REACHED'):
print("!")
else:
print("")
Expand Down
Binary file removed results/power_converter_currents.pdf
Binary file not shown.
Binary file removed results/power_converter_inputs.pdf
Binary file not shown.
5 changes: 0 additions & 5 deletions results/power_converter_miqp.tex

This file was deleted.

6 changes: 0 additions & 6 deletions results/power_converter_timings.csv

This file was deleted.

Binary file removed results/power_converter_timings.pdf
Binary file not shown.
9 changes: 0 additions & 9 deletions results/random_miqp.csv

This file was deleted.

12 changes: 0 additions & 12 deletions results/random_miqp.tex

This file was deleted.

0 comments on commit ac67233

Please sign in to comment.