Skip to content

Commit

Permalink
Merge pull request #43 from cvxgrp/debug
Browse files Browse the repository at this point in the history
Debug
  • Loading branch information
bmeyers authored Apr 14, 2023
2 parents 9a77a56 + 4927829 commit e4f9c58
Show file tree
Hide file tree
Showing 8 changed files with 180 additions and 0 deletions.
118 changes: 118 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -253,3 +253,121 @@ $RECYCLE.BIN/

# Windows shortcuts
*.lnk

# Created by https://www.toptal.com/developers/gitignore/api/pycharm
# Edit at https://www.toptal.com/developers/gitignore?templates=pycharm

### PyCharm ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# AWS User-specific
.idea/**/aws.xml

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# SonarLint plugin
.idea/sonarlint/

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

### PyCharm Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721

# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr

# Sonarlint plugin
# https://plugins.jetbrains.com/plugin/7973-sonarlint
.idea/**/sonarlint/

# SonarQube Plugin
# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
.idea/**/sonarIssues.xml

# Markdown Navigator plugin
# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
.idea/**/markdown-navigator.xml
.idea/**/markdown-navigator-enh.xml
.idea/**/markdown-navigator/

# Cache file creation bug
# See https://youtrack.jetbrains.com/issue/JBR-2257
.idea/$CACHE_FILE$

# CodeStream plugin
# https://plugins.jetbrains.com/plugin/12206-codestream
.idea/codestream.xml

# Azure Toolkit for IntelliJ plugin
# https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij
.idea/**/azureSettings.xml

# End of https://www.toptal.com/developers/gitignore/api/pycharm
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/qss.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions qss/admm.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import numpy as np
import scipy as sp
import time
import os
from qss import proximal
from qss import matrix
from qss import util
Expand Down Expand Up @@ -114,6 +115,21 @@ def admm(
print("ADMM solve".center(util.PRINT_WIDTH))
util.print_header()
admm_start_time = time.time()
if options["debug"]:
debug_start = time.strftime("%Y%m%d_%H%M%S") + f"_{int(np.round(np.modf(time.time())[0],4)*1e4)}"
statement = "####################\ndebug start: "
statement += debug_start + "\n"
ws = options["warm_start"]
statement += f"warm start: {ws}\n"
statement += '####################'
print(statement)
fn_x = debug_start + f"__passed_x.txt"
fn_y = debug_start + f"__passed_y.txt"
folder_loc = 'debug/'
if not os.path.exists(folder_loc):
os.makedirs(folder_loc)
np.savetxt(folder_loc + fn_x, x)
np.savetxt(folder_loc + fn_y, y)

# Unpacking data
P = data["P"]
Expand Down Expand Up @@ -151,6 +167,14 @@ def admm(
finished = False

while not finished:
if options["debug"] and (iter_num <= 5 or iter_num % 10 == 0):
folder_loc = 'debug/'
if not os.path.exists(folder_loc):
os.makedirs(folder_loc)
fn_x = debug_start + f"_{iter_num:04}_x.txt"
fn_z = debug_start + f"_{iter_num:04}_z.txt"
np.savetxt(folder_loc + fn_x, xk1)
np.savetxt(folder_loc + fn_z, zk)
iter_num += 1
rho_vec = rho_controller.get_rho_vec()
if schedule_alpha and max_iter < np.inf:
Expand Down
4 changes: 4 additions & 0 deletions qss/qss.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ def __init__(
self._options["random_init"] = None
self._options["init_seed"] = None
self._options["verbose"] = None
self._options["debug"] = None
return

def _reset_scaling(self):
Expand Down Expand Up @@ -181,6 +182,7 @@ def solve(
random_init=False,
init_seed=1234,
verbose=False,
debug=False
):

self._options["eps_abs"] = eps_abs
Expand All @@ -200,6 +202,7 @@ def solve(
self._options["random_init"] = random_init
self._options["init_seed"] = init_seed
self._options["verbose"] = verbose
self._options["debug"] = debug

np.random.seed(1234)

Expand All @@ -209,6 +212,7 @@ def solve(

# Reset problem parameters if not warm starting
if not self._options["warm_start"]:
if self._options["debug"]: print('### DEBUG ###\nresetting iterates\n#############')
self._reset_iterates(self._options["random_init"])
self._rho_controller = None

Expand Down

0 comments on commit e4f9c58

Please sign in to comment.