Skip to content

Commit

Permalink
fix: commenting out osqp
Browse files Browse the repository at this point in the history
  • Loading branch information
Lachlan Grose committed Feb 7, 2022
1 parent 8197552 commit c2fd2da
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 27 deletions.
46 changes: 23 additions & 23 deletions LoopStructural/interpolators/discrete_interpolator.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,29 +475,29 @@ def build_matrix(self, square=True, damp=0.0, ie=False):
def _solve_osqp(self, P, A, q, l, u):


import osqp
m = A.shape[0]
n = A.shape[1]
Ad = sparse.random(m, n, density=0.7, format='csc')
b = np.random.randn(m)

# OSQP data
P = sparse.block_diag([sparse.csc_matrix((n, n)), sparse.eye(m)], format='csc')
q = np.zeros(n+m)
A = sparse.vstack([
sparse.hstack([Ad, -sparse.eye(m)]),
sparse.hstack([sparse.eye(n), sparse.csc_matrix((n, m))])], format='csc')
l = np.hstack([b, np.zeros(n)])
u = np.hstack([b, np.ones(n)])

# Create an OSQP object
prob = osqp.OSQP()

# Setup workspace
prob.setup(P, q, A, l, u)

# Solve problem
res = prob.solve()
# import osqp
# m = A.shape[0]
# n = A.shape[1]
# Ad = sparse.random(m, n, density=0.7, format='csc')
# b = np.random.randn(m)

# # OSQP data
# P = sparse.block_diag([sparse.csc_matrix((n, n)), sparse.eye(m)], format='csc')
# q = np.zeros(n+m)
# A = sparse.vstack([
# sparse.hstack([Ad, -sparse.eye(m)]),
# sparse.hstack([sparse.eye(n), sparse.csc_matrix((n, m))])], format='csc')
# l = np.hstack([b, np.zeros(n)])
# u = np.hstack([b, np.ones(n)])

# # Create an OSQP object
# prob = osqp.OSQP()

# # Setup workspace
# prob.setup(P, q, A, l, u)

# # Solve problem
# res = prob.solve()


# Create an OSQP object
Expand Down
6 changes: 5 additions & 1 deletion LoopStructural/modelling/features/geological_feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import numpy as np

from LoopStructural.utils import getLogger
from LoopStructural.utils import getLogger, LoopValueError

logger = getLogger(__name__)

Expand Down Expand Up @@ -134,6 +134,8 @@ def evaluate_value(self, evaluation_points):
numpy array containing evaluated values
"""
if evaluation_points.shape[1] != 3:
raise LoopValueError("Need Nx3 array of xyz points to evaluate value")
# TODO need to add a generic type checker for all methods
# if evaluation_points is not a numpy array try and convert
# otherwise error
Expand Down Expand Up @@ -171,6 +173,8 @@ def evaluate_gradient(self, evaluation_points):
-------
"""
if evaluation_points.shape[1] != 3:
raise LoopValueError("Need Nx3 array of xyz points to evaluate gradient")
self.builder.up_to_date()
v = np.zeros(evaluation_points.shape)
v[:] = np.nan
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
"""
Feature builder
"""
import copy
import logging

import numpy as np
import pandas as pd

Expand Down

0 comments on commit c2fd2da

Please sign in to comment.