Skip to content

Commit 3bdfe2f

Browse files
committed
(Issue #291) Prefer identical prefix to group solver indices.
1 parent 3232bef commit 3bdfe2f

4 files changed

Lines changed: 22 additions & 16 deletions

File tree

pounders/m/create_trsp_solver.m

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@
55
% ----- HARDCODED VALUES
66
% Ensure that these match the analogous constants implemented for
77
% POUNDERS/Python.
8-
SIMPLE_TRSP = 1;
9-
MINQ5_TRSP = 2;
10-
MINQ8_TRSP = 3;
8+
%
9+
% Both MATLAB and Python implementations should declare the union of all
10+
% solvers available even if they don't support one or more of the solvers.
11+
TRSP_SOLVER_SIMPLE = 1;
12+
TRSP_SOLVER_MINQ5 = 2;
13+
TRSP_SOLVER_MINQ8 = 3;
1114

1215
% ----- DEFINE POUNDERS-COMPATIBLE INTERFACES ON SOLVERS
1316
% Stefan's crappy 10 line solver
@@ -44,12 +47,12 @@
4447
end
4548

4649
% ----- IDENTIFY DESIRED SOLVER
47-
if spsolver == SIMPLE_TRSP
50+
if spsolver == TRSP_SOLVER_SIMPLE
4851
solver = @bqmin_wrapper;
49-
elseif spsolver == MINQ5_TRSP
52+
elseif spsolver == TRSP_SOLVER_MINQ5
5053
check_minq_installation(5);
5154
solver = @minq5_wrapper;
52-
elseif spsolver == MINQ8_TRSP
55+
elseif spsolver == TRSP_SOLVER_MINQ8
5356
check_minq_installation(8);
5457
solver = @minq8_wrapper;
5558
else

pounders/py/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# fmt: on
1818
from .create_squared_diff_from_mean_functions import create_squared_diff_from_mean_functions
1919

20-
from .constants import SIMPLE_TRSP, MINQ5_TRSP
20+
from .constants import TRSP_SOLVER_SIMPLE, TRSP_SOLVER_MINQ5, TRSP_SOLVER_MINQ8
2121
from .create_trsp_solver import create_trsp_solver
2222

2323
# -- Python unittest-based test framework

pounders/py/constants.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# ----- TRUST-REGION SUBPROBLEM SOLVERS
22
# Ensure that these match the analogous constants implemented for
33
# POUNDERS/MATLAB.
4-
SIMPLE_TRSP = 1
5-
MINQ5_TRSP = 2
6-
MINQ8_TRSP = 3
4+
#
5+
# Both MATLAB and Python implementations should declare the union of all solvers
6+
# available even if they don't support one or more of the solvers.
7+
TRSP_SOLVER_SIMPLE = 1
8+
TRSP_SOLVER_MINQ5 = 2
9+
TRSP_SOLVER_MINQ8 = 3

pounders/py/create_trsp_solver.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import numpy as np
44

5-
from .constants import SIMPLE_TRSP, MINQ5_TRSP
5+
from .constants import TRSP_SOLVER_SIMPLE, TRSP_SOLVER_MINQ5
66
from .._get_minq_installation import get_minq_installation
77
from .bqmin import bqmin
88

@@ -23,10 +23,10 @@ def create_trsp_solver(spsolver):
2323
for all components :math:`s_j` of :math:`\svec`.
2424
2525
:param spsolver:
26-
* ``ibcdfo.pounders.SIMPLE_TRSP`` - simplistic 10 line solver that is
26+
* ``ibcdfo.pounders.TRSP_SOLVER_SIMPLE`` - simplistic 10 line solver that is
2727
included only for testing and maintenance purposes
28-
* ``ibcdfo.pounders.MINQ5_TRSP`` - Arnold Neumaier's minq5 solver
29-
* ``ibcdfo.pounders.MINQ8_TRSP`` - Arnold Neumaier's minq8 solver
28+
* ``ibcdfo.pounders.TRSP_SOLVER_MINQ5`` - Arnold Neumaier's minq5 solver
29+
* ``ibcdfo.pounders.TRSP_SOLVER_MINQ8`` - Arnold Neumaier's minq8 solver
3030
:return: Python function with the interface
3131
3232
.. code:: python
@@ -47,15 +47,15 @@ def create_trsp_solver(spsolver):
4747
* ``flag`` communicates the termination condition of the solver with a
4848
negative value indicating failure.
4949
"""
50-
if spsolver == SIMPLE_TRSP:
50+
if spsolver == TRSP_SOLVER_SIMPLE:
5151

5252
def __bqmin_wrapper(H, G, Low, Upp):
5353
Xsp, mdec = bqmin(H, G, Low, Upp)
5454
return Xsp, mdec, 0
5555

5656
return __bqmin_wrapper
5757

58-
elif spsolver == MINQ5_TRSP:
58+
elif spsolver == TRSP_SOLVER_MINQ5:
5959
required_minq_SHA, minq_installation = get_minq_installation()
6060
if not minq_installation["is_valid"]:
6161
msg = f"Please set MINQ clone to git commit {required_minq_SHA}.\nSee User Guide (https://ibcdfo.readthedocs.io) for more information and instructions."

0 commit comments

Comments
 (0)