Minimize the Pairwise Distance Ratio for N Points#

min_pairw_dist_ratio.ipynb Open In Colab Open In Deepnote Open In Kaggle Open In Gradient Open In SageMaker Studio Lab Powered by AMPL

Description: Minimize the pairwise distance ratio of N points with FICO Xpress

Tags: AMPLPY, highlights, nonlinear, quadratic, global optimization, local optimization, trigonometric, xpress

Notebook author: Gleb Belov <gleb@ampl.com>

Reference:

  1. FICO Xpress nonlinear examples. https://www.fico.com/fico-xpress-optimization/docs/latest/examples/mosel/NonLinear/, accessed Feb 27, 2026.

  2. AMPL Xpress documentation. https://dev.ampl.com/solvers/xpress.

# Install dependencies
%pip install -q amplpy pandas matplotlib
# Google Colab & Kaggle integration
from amplpy import AMPL, ampl_notebook

ampl = ampl_notebook(
    modules=["xpress"],  # modules to install
    license_uuid="default",  # license to use
)  # instantiate AMPL object and register magics

Overview#

We consider a minimum pairwise distance ratio problem from [1]. We shell solve it with the Xpress local and global optimizers. For the local optimizer we will see how important it is to provide a reasonable starting point.

Use %%ampl_eval to evaluate AMPL commands and declarations#

%%ampl_eval

# Parameters
param N default 12;       # Number of points to be placed, eg 12, 14 or 16
param D default 3;        # Number of dimensions: 2, 3, ...

# Public declarations
set POINTS := 1..N;
set DIMS := 1..D;

# Variables
var x {POINTS, DIMS} >=0 <=1;   # N points in D-dimensional space
var t_min >=0 <=1;              # Variable for min squared distance
 
# Constraints on distances
s.t. DistLB {i in POINTS, j in POINTS: i<j}:
    sum {k in DIMS} (x[i, k] - x[j,k])^2 >= t_min;
s.t. DistUB {i in POINTS, j in POINTS: i<j}:
    sum {k in DIMS} (x[i, k] - x[j,k])^2 <= 1;

# We wish to minimize 1/t_min, which is invariant for scaling.
# Instead, we can improve the formulation by
# maximizing t_min (with this reformulation we are turning the problem 
# from a general nonlinear problem into a non-convex quadratic programming 
# problem).
maximize Obj: t_min;

Load data directly from Python data structures using amplpy#

N = 12
D = 3

ampl.param["N"] = N
ampl.param["D"] = D

Local optimization: solve with Xpress SLP#

ampl.option["solver"] = "xpress"
ampl.option["mp_options"] = "outlev=1 alg:nlpsolver=1 alg:localsolver=0"

ampl.snapshot(
    "min_pairw_snapshot_0.run"
)  # Debug feature, saves AMPL state including the model

ampl.solve()
XPRESS 9.8.0 (46.01.01):   tech:outlev = 1
  alg:nlpsolver = 1
  alg:localsolver = 0

AMPL MP initial flat model has 37 variables (0 integer, 0 binary);
Objectives: 1 linear; 
Constraints:  132 quadratic;

AMPL MP final model has 37 variables (0 integer, 0 binary);
Objectives: 1 linear; 
Constraints:  132 quadratic;


Original problem size
   linear:    132 rows, 37 columns, 66 linear coefficients
   quadratic: 0 in obj, 132 rows, 1188 in rows
Nonlinear presolve
   converted 66 quadratic matrices to formulas
   simplify removed 792 tokens
   creating 66 '+' clusters removed 396 tokens
Presolved problem size
   linear:    132 rows, 38 columns, 66 linear coefficients
   quadratic: 0 in obj, 66 rows, 594 in rows
   nonlinear: 66 coefficients, 2310 tokens
             396 mul             0 div         0 sqrt
               0 exp             0 log       396 pow
Problem is nonlinear presolved
FICO Xpress v9.8.0, Hyper, solve started 17:29:47, Mar 3, 2026
Control settings used:
INPUTTOL = 0
LOCALSOLVER = 0
NLPSOLVER = 1
Maximum expanded nl-formula size: 35  (row 'R67')
Total tokens: 2310
Quadratic formula size: 594
  8  parallel calculation threads
  Jacobian: symbolic differentiation
          66 base AD formula, 28 average complexity
         396 in the Jacobian, 7 average complexity
Initial point objective:     1.0000
Absolute / relative validation:           1.000  /     1.000
Maximizing problem using Xpress-SLP
Xpress-SLP Augmentation Statistics:
  Columns:
          36 implicit SLP variables
          36 delta vectors
          66 penalty error vectors (66 positive, 0 negative)
  Rows:
          66 nonlinear constraints
          36 update rows
           1 penalty error rows
  Coefficients:
         528 non-constant coefficients

 It LP    NetObj   ValObj ErrorSum ErrorCost Validate   KKT Unconv  Ext Action T
  1 O  2.999E-05  2.9E-05      .00 -2.5E-11  2.9E-05             0    0 *      0
  2 O  5.998E-05  5.9E-05      .00 -8.9E-10  5.9E-05             0    0 *      0
  3 O  5.999E-05  5.9E-05      .00 -1.1E-11  5.9E-05             0    0 *      0
  4 O  5.998E-05  5.9E-05      .00 -8.9E-10  5.9E-05             0    0 *      0
  5 O  5.999E-05  5.9E-05      .00 -1.1E-11  5.9E-05             0    0 V*     0
  6 O  5.998E-05  5.9E-05      .00 -8.9E-10  5.9E-05             0    0 V*     0
  7 O  5.999E-05  5.9E-05      .00 -1.1E-11  5.9E-05             0    0 V*     0
  8 O  5.998E-05  5.9E-05      .00 -8.9E-10  5.9E-05             0    0 V*     0
  9 O  5.999E-05  5.9E-05      .00 -1.1E-11  5.9E-05      .00    0    0 *      0
Returning final converged solution

Xpress-SLP stopped after 9 iterations. 0 unconverged items
Problem solved using Xpress-NLP SLP
Converged on objective function with no unconverged values in active constraints
No unconverged values in active constraints
Problem is nonlinear postsolved
Heap usage: 1274KB (peak 7751KB, 96KB system)
Observed Lipschitz constant:  1.00E-05

Final NLP objective (local optimum)   : 5.999487782228242e-05
  Max validation error      (abs/rel) :  5.99E-05 /  5.99E-05
  Max primal violation      (abs/rel) : 5.999e-05 / 5.999e-05
  Observed primal integral            :   34.416%
  Total / SLP / LP time               :     .077s /      .065s /      .058s
  Work / work units per second        :      0.00 /      0.06
*** Search completed ***
XPRESS 9.8.0 (46.01.01): limit, feasible solution; objective 5.999486616e-05
6 barrier iterations
 
------------ WARNINGS ------------
WARNING:  "Tolerance violations"
  Type                         MaxAbs [Name]   MaxRel [Name]
* quadratic con(s)             6E-05           -             
*: Using the solver's aux variable values.
Documentation: mp.ampl.com/modeling-tools.html#automatic-solution-check.

Retrieve solution and visualize#

import matplotlib.pyplot as plt
import numpy as np


def display_solution(ampl):
    print("\nAMPL solve result:", ampl.solve_result, " code:", ampl.solve_result_num)
    print("Objective value:", ampl.get_objective("Obj").value(), "\n")
    df_x = ampl.var["x"].to_pandas().unstack().transpose()
    display(df_x)

    fig = plt.figure()
    ax = fig.add_subplot(projection="3d")

    ax.scatter(df_x.iloc[0, :], df_x.iloc[1, :], df_x.iloc[2, :])

    ax.set_xlabel("X")
    ax.set_ylabel("Y")
    ax.set_zlabel("Z")

    plt.show()
display_solution(ampl)
AMPL solve result: limit  code: 400
Objective value: 5.999487782228242e-05 
index0 1 2 3 4 5 6 7 8 9 10 11 12
index1
x.val 1 0.000014 0.000014 0.000014 0.000014 0.000014 0.000014 0.000014 0.000014 0.000014 0.000014 0.000014 0.000014
2 0.000014 0.000014 0.000014 0.000014 0.000014 0.000014 0.000014 0.000014 0.000014 0.000014 0.000014 0.000014
3 0.000014 0.000014 0.000014 0.000014 0.000014 0.000014 0.000014 0.000014 0.000014 0.000014 0.000014 0.000014
../_images/673900e25be4e596bdf1f3a8ec5de6b4165fc48178648041441cb998123cfd5b.png

Provide a starting point to escape the local optimum#

import random
import numpy as np
import pandas as pd

random.seed(42)
start = np.random.rand(N, D)

start_df = pd.DataFrame(start, index=range(1, N + 1), columns=range(1, D + 1))
start_df.transpose()
1 2 3 4 5 6 7 8 9 10 11 12
1 0.309670 0.816174 0.072489 0.788642 0.573822 0.766945 0.127842 0.617298 0.238040 0.819574 0.517516 0.908738
2 0.247674 0.360498 0.616121 0.555726 0.606850 0.398702 0.438036 0.954704 0.680294 0.025726 0.412743 0.436167
3 0.001503 0.812331 0.767304 0.032685 0.373634 0.522982 0.186059 0.567483 0.924209 0.857128 0.339448 0.973921
ampl.get_variable("x").set_values(start_df)

ampl.option["mp_options"] = "outlev=1 alg:nlpsolver=1 alg:localsolver=0"
# ampl.snapshot('min_pairw_snapshot_1__with_random_start.run')

ampl.solve()
XPRESS 9.8.0 (46.01.01):   tech:outlev = 1
  alg:nlpsolver = 1
  alg:localsolver = 0

AMPL MP initial flat model has 37 variables (0 integer, 0 binary);
Objectives: 1 linear; 
Constraints:  132 quadratic;

AMPL MP final model has 37 variables (0 integer, 0 binary);
Objectives: 1 linear; 
Constraints:  132 quadratic;


User solution (AMPL_initial_guess) stored.
Original problem size
   linear:    132 rows, 37 columns, 66 linear coefficients
   quadratic: 0 in obj, 132 rows, 1188 in rows
Nonlinear presolve
   converted 66 quadratic matrices to formulas
   simplify removed 792 tokens
   creating 66 '+' clusters removed 396 tokens
Presolved problem size
   linear:    132 rows, 38 columns, 66 linear coefficients
   quadratic: 0 in obj, 66 rows, 594 in rows
   nonlinear: 66 coefficients, 2310 tokens
             396 mul             0 div         0 sqrt
               0 exp             0 log       396 pow
Problem is nonlinear presolved
FICO Xpress v9.8.0, Hyper, solve started 17:29:47, Mar 3, 2026
Control settings used:
INPUTTOL = 0
LOCALSOLVER = 0
NLPSOLVER = 1
Maximum expanded nl-formula size: 35  (row 'R67')
Total tokens: 2310
Quadratic formula size: 594
  8  parallel calculation threads
  Jacobian: symbolic differentiation
          66 base AD formula, 28 average complexity
         396 in the Jacobian, 7 average complexity
Initial point objective:  5.999E-05
Absolute / relative validation:            .340  /      .160
Maximizing problem using Xpress-SLP
Xpress-SLP Augmentation Statistics:
  Columns:
          36 implicit SLP variables
          37 delta vectors
          66 penalty error vectors (66 positive, 0 negative)
  Rows:
          66 nonlinear constraints
          37 update rows
           1 penalty error rows
  Coefficients:
         528 non-constant coefficients

 It LP    NetObj   ValObj ErrorSum ErrorCost Validate   KKT Unconv  Ext Action T
User solution (AMPL_initial_guess) dropped.
  1 O      .1157               .00 -3.2E-10                     37    0 *      0
  2 O      .1918               .00 -8.8E-08                     34    0 *      0
  3 O      .2497               .00 -1.5E-10                     35    0 *      0
  4 O      .2549      .25      .00 -2.9E-06  9.3E-05            35    0 *      0
  5 O      .2587      .25      .00 -3.2E-11      .00            35    0 *      0
  6 O      .2668      .26      .00 -2.0E-06      .00            35    0 *      0
  7 O      .2695      .26      .00 -8.8E-11      .00             0    0 *      0
  8 O      .2696      .26      .00 -2.2E-10      .00             0    0 *      0
  9 O      .2696      .26      .00 -2.1E-10      .00             0    0 *      0
 10 O      .2696      .26      .00 -2.1E-10      .00             0    0 *      0
 11 O      .2696      .26      .00 -2.1E-10      .00      .00    0    0 *      0
Returning final converged solution

Xpress-SLP stopped after 11 iterations. 0 unconverged items
Problem solved using Xpress-NLP SLP
Converged on objective function with no unconverged values in active constraints
No unconverged values in active constraints
Problem is nonlinear postsolved
Heap usage: 1274KB (peak 8058KB, 96KB system)
Observed Lipschitz constant:     1.998

Final NLP objective (local optimum)   : 2.696777840853675e-01
  Max validation error      (abs/rel) :      .000 /      .000
  Max primal violation      (abs/rel) : 4.093e-09 / 1.902e-09
  Observed primal integral            :   22.735%
  Total / SLP / LP time               :     .170s /      .162s /      .158s
  Work / work units per second        :      0.01 /      0.03
*** Search completed ***
XPRESS 9.8.0 (46.01.01): limit, feasible solution; objective 0.2696777839
13 barrier iterations

Retrieve the improved local solution#

display_solution(ampl)
AMPL solve result: limit  code: 400
Objective value: 0.2696777840853675 
index0 1 2 3 4 5 6 7 8 9 10 11 12
index1
x.val 1 0.320639 0.951813 0.053109 0.664496 0.858774 0.817438 0.179595 0.351550 0.392611 0.457261 0.580566 0.894054
2 0.083250 0.159550 0.361453 0.661393 0.914987 0.163964 0.570608 0.943895 0.563611 0.078762 0.482232 0.653852
3 0.294013 0.667730 0.641445 0.021066 0.430485 0.166131 0.183261 0.571597 0.978415 0.804002 0.501206 0.877969
../_images/2828acd88fb885943720115084f1ed570c95a3e526f083c097fa45dcb94a8a28.png

Solve with Xpress Global (reusing previous solution)#

This invokes the global optimizer.

ampl.option["solver"] = "xpress"
ampl.option["mp_options"] = "outlev=1 lim:time=30"
ampl.solve()
XPRESS 9.8.0 (46.01.01):   tech:outlev = 1
  lim:time = 30

AMPL MP initial flat model has 37 variables (0 integer, 0 binary);
Objectives: 1 linear; 
Constraints:  132 quadratic;

AMPL MP final model has 37 variables (0 integer, 0 binary);
Objectives: 1 linear; 
Constraints:  132 quadratic;


User solution (AMPL_initial_guess) stored.
Original problem size
   linear:    132 rows, 37 columns, 66 linear coefficients
   quadratic: 0 in obj, 132 rows, 1188 in rows
Nonlinear presolve
   converted 66 quadratic matrices to formulas
   simplify removed 792 tokens
   creating 66 '+' clusters removed 396 tokens
Presolved problem size
   linear:    132 rows, 38 columns, 66 linear coefficients
   quadratic: 0 in obj, 66 rows, 594 in rows
   nonlinear: 66 coefficients, 2310 tokens
             396 mul             0 div         0 sqrt
               0 exp             0 log       396 pow
Problem is nonlinear presolved
FICO Xpress v9.8.0, Hyper, solve started 17:29:47, Mar 3, 2026
Control settings used:
INPUTTOL = 0
TIMELIMIT = 30
Maximum expanded nl-formula size: 35  (row 'R67')
Total tokens: 2310
Quadratic formula size: 594
  8  parallel calculation threads
  Jacobian: symbolic differentiation
          66 base AD formula, 28 average complexity
         396 in the Jacobian, 7 average complexity
Initial point is within initial feasibility target with objective:      .2696
Absolute / relative validation:            .000  /      .000
User solution (initial point) stored.
 ------------------- Calling global solver ----------------- 
FICO Xpress v9.8.0, Hyper, solve started 17:29:47, Mar 3, 2026
Heap usage: 225KB (peak 225KB, 211KB system)
Maximizing Nonconvex-QCP  using up to 8 threads and up to 16GB memory
Original problem has:
       132 rows           38 cols           66 elements         0 entities
        66 qrows         594 qrowelem
Presolved problem has:
       132 rows          271 cols          660 elements         0 entities
        66 qrows         594 qrowelem
Presolve finished in 0 seconds
Heap usage: 1586KB (peak 1946KB, 211KB system)

Coefficient range                    original                 solved        
  Coefficients   [min,max] : [ 1.00e+00,  1.00e+00] / [ 5.00e-01,  1.00e+00]
  RHS and bounds [min,max] : [ 1.00e+00,  1.00e+00] / [ 5.00e-01,  1.00e+00]
  Objective      [min,max] : [ 1.00e+00,  1.00e+00] / [ 2.00e+00,  2.00e+00]
  Quadratic      [min,max] : [ 2.00e+00,  2.00e+00] / [ 1.00e+00,  1.00e+00]
Autoscaling applied standard scaling

Will try to keep branch and bound tree memory usage below 15.1GB
 *** Solution found:      .269678   Time:   0.01    Heuristic: U ***
User solution (AMPL_initial_guess) accepted: Feasible solution.
User solution (initial point) rejected: Solution is worse than current cutoff value.
Not using SSE2/AVX
Cores per CPU (CORESPERCPU): 8
Barrier starts after 0 seconds, using up to 8 threads, 8 cores
Matrix ordering - Dense cols.:    271   NZ(L):      9612   Flops:       242202
 
  Its   P.inf      D.inf      U.inf      Primal obj.     Dual obj.      Compl.
   0   4.00e+00   6.46e+00   3.75e+00   4.0000000e+00   1.5879871e+03   1.7e+04
   1   1.43e-01   1.80e+00   1.34e-01   5.4693066e-01   4.4540987e+01   4.8e+03
   2   5.00e-03   6.87e-02   4.69e-03   7.3894232e-01   2.3783853e+00   2.0e+02
   3   4.50e-03   6.18e-02   4.22e-03   1.0076088e+00   2.4881146e+00   1.9e+02
   4   7.58e-03   5.52e-02   3.80e-03   9.4465829e-04   1.3584647e+00   1.8e+02
   5   1.24e-02   2.99e-02   2.01e-03   8.1878734e-01   1.6269962e+00   2.1e+02
   6   2.80e-04   6.29e-04   3.76e-05   9.8948890e-01   1.0056135e+00   4.2e+00
   7   7.35e-07   7.27e-07   4.00e-08   9.9998896e-01   1.0000061e+00   4.4e-03
   8   7.35e-10   7.27e-10   4.00e-11   9.9999999e-01   1.0000000e+00   4.4e-06
Barrier method finished in 0 seconds
Crossover crash basis containing 0 structurals form 234 candidates
Crossover starts
 
   Its         Obj Value      S   Ninf  Nneg        Sum Inf  Time
   112          1.000000      P      0     0        .000000     0
     0          1.000000      N      0     0        .000000     0
     0          1.000000      D      0     0        .000000     0
Crossover successful
Objective function value:     1.000000 time: 0
     0          1.000000      P      0     0        .000000     0
     0          1.000000      D      3     0        .000000     0
    21          1.000000      D      0     0        .000000     0
Optimal solution found
Barrier solved problem
  8 barrier and 133 simplex iterations in 0.01 seconds at time 0

Final objective                       : 1.000000000000000e+00
  Max primal violation      (abs/rel) :       0.0 /       0.0
  Max dual violation        (abs/rel) :       0.0 /       0.0
  Max complementarity viol. (abs/rel) :       0.0 /       0.0

Starting root cutting & heuristics
Deterministic mode with up to 1 additional thread
 
 Its Type    BestSoln    BestBound   Sols    Add    Del     Gap     GInf   Time
   1  O       .269678     1.000000      1    377    726   73.03%      63      0
   2          .269678     1.000000      1    296    392   73.03%      57      0
c             .276393     1.000000      2                 72.36%       0      0
   3          .276393     1.000000      2    211    306   72.36%      66      0
   4          .276393     1.000000      2    174    231   72.36%      66      1
   5          .276393     1.000000      2    162    178   72.36%      66      1
   6          .276393     1.000000      2    252    163   72.36%      66      1
   7          .276393     1.000000      2    202    241   72.36%      66      1
   8          .276393     1.000000      2    236    192   72.36%      65      1
   9          .276393     1.000000      2    251    236   72.36%      54      1
  10          .276393     1.000000      2    277    255   72.36%      61      2
  11          .276393     1.000000      2    179    283   72.36%      63      2
  12          .276393     1.000000      2    180    187   72.36%      61      2
  13          .276393     1.000000      2    333    187   72.36%      54      2
  14          .276393     1.000000      2    186    329   72.36%      55      2
  15          .276393     1.000000      2    216    192   72.36%      52      2
  16          .276393     1.000000      2    225    205   72.36%      55      3
  17          .276393     1.000000      2    267    230   72.36%      55      3
  18          .276393     1.000000      2    273    266   72.36%      48      3
  19          .276393     1.000000      2    304    282   72.36%      48      3
  20          .276393     1.000000      2    266    558   72.36%      48      3
 
Cuts in the matrix         : 68
Cut elements in the matrix : 396

Starting tree search.
Deterministic mode with up to 8 running threads and up to 16 tasks.
Heap usage: 10MB (peak 11MB, 399KB system)
 
    Node     BestSoln    BestBound   Sols Active  Depth     Gap     GInf   Time
       1      .276393     1.000000      2      2      1   72.36%      23      4
       2      .276393     1.000000      2      2      2   72.36%      40      4
       3      .276393     1.000000      2      2      2   72.36%      60      4
       4      .276393     1.000000      2      2      3   72.36%      48      4
       5      .276393     1.000000      2      2      4   72.36%      54      4
       6      .276393     1.000000      2      5      3   72.36%      60      4
       7      .276393     1.000000      2      5      5   72.36%      43      4
       8      .276393     1.000000      2      5      5   72.36%      52      4
       9      .276393     1.000000      2      5      4   72.36%      52      4
      10      .276393     1.000000      2      5      4   72.36%      38      4
      22      .276393     1.000000      2     20      8   72.36%      50      4
      32      .276393     1.000000      2     20     11   72.36%      31      4
      42      .276393     1.000000      2     20     14   72.36%      37      4
      54      .276393     1.000000      2     20     18   72.36%      42      4
      66      .276393     1.000000      2     20     21   72.36%      51      4
      77      .276393     1.000000      2     20     23   72.36%      56      4
      87      .276393     1.000000      2     20     25   72.36%      57      4
      98      .276393     1.000000      2     20     27   72.36%      38      4
     108      .276393     1.000000      2     20     28   72.36%      45      4
Elapsed time (sec): 5, estimated tree completion: 0.00000
Heap usage: 68MB (peak 68MB, 730KB system)
B&B tree size: 3.4MB total
 
    Node     BestSoln    BestBound   Sols Active  Depth     Gap     GInf   Time
     212      .276393     1.000000      2     20     49   72.36%      19      5
     313      .276393     1.000000      2     82     26   72.36%      53      5
     415      .276393     1.000000      2    144     86   72.36%      13      6
     515      .276393     1.000000      2    296     29   72.36%      55      6
     616      .276393     1.000000      2    296     33   72.36%      49      6
     718      .276393     1.000000      2    296     37   72.36%      50      7
     819      .276393     1.000000      2    296     37   72.36%      48      7
     919      .276393     1.000000      2    296     64   72.36%      16      7
    1021      .276393     1.000000      2    296     37   72.36%      38      8
    1121      .276393     1.000000      2    296     63   72.36%      36      8
    1221      .276393     1.000000      2    296     62   72.36%      26      8
    1322      .276393     1.000000      2    296     66   72.36%      22      9
    1422      .276393     1.000000      2    296     80   72.36%      17      9
    1523      .276393     1.000000      2    296     43   72.36%      49      9
    1625      .276393     1.000000      2    296     35   72.36%      37     10
    1728      .276393     1.000000      2    296     67   72.36%      24     10
    1829      .276393     1.000000      2    296     30   72.36%      53     10
    1931      .276393     1.000000      2    296     51   72.36%      25     11
    2032      .276393     1.000000      2    296     45   72.36%      28     11
    2132      .276393     1.000000      2    296     67   72.36%      22     11
Elapsed time (sec): 12, estimated tree completion: 0.00000
Heap usage: 165MB (peak 165MB, 1153KB system)
B&B tree size: 39MB total
 
    Node     BestSoln    BestBound   Sols Active  Depth     Gap     GInf   Time
    2232      .276393     1.000000      2    296     62   72.36%      33     12
    2332      .276393     1.000000      2    553     22   72.36%      53     12
    2433      .276393     1.000000      2    553     34   72.36%      39     12
    2535      .276393     1.000000      2    553     65   72.36%      22     13
    2637      .276393     1.000000      2    553     82   72.36%      29     13
    2738      .276393     1.000000      2    553     36   72.36%      51     14
    2840      .276393     1.000000      2    553     32   72.36%      49     14
    2940      .276393     1.000000      2    553     48   72.36%      30     14
    3042      .276393     1.000000      2    553     37   72.36%      51     15
    3144      .276393     1.000000      2    553     44   72.36%      22     15
    3246      .276393     1.000000      2    864     38   72.36%      32     15
    3348      .276393     1.000000      2    864     37   72.36%      63     16
    3448      .276393     1.000000      2    864     38   72.36%      43     16
    3548      .276393     1.000000      2    864     50   72.36%      34     16
    3650      .276393     1.000000      2    864     52   72.36%      32     17
    3750      .276393     1.000000      2    864     45   72.36%      51     17
    3851      .276393     1.000000      2    864     44   72.36%      42     17
    3951      .276393     1.000000      2    864     33   72.36%      34     18
    4053      .276393     1.000000      2    864     25   72.36%      37     18
    4155      .276393     1.000000      2    864     47   72.36%      39     18
Elapsed time (sec): 19, estimated tree completion: 0.00000
Heap usage: 278MB (peak 278MB, 1742KB system)
B&B tree size: 75MB total
 
    Node     BestSoln    BestBound   Sols Active  Depth     Gap     GInf   Time
    4257      .276393     1.000000      2    864     39   72.36%      42     19
    4357      .276393     1.000000      2    864     34   72.36%      48     19
    4457      .276393     1.000000      2    864     46   72.36%      28     19
    4558      .276393     1.000000      2    864     35   72.36%      37     20
    4659      .276393     1.000000      2    864     35   72.36%      44     20
    4759      .276393     1.000000      2    864     37   72.36%      42     20
    4859      .276393     1.000000      2    864     33   72.36%      45     21
    4959      .276393     1.000000      2    864     35   72.36%      54     21
    5061      .276393     1.000000      2    864     61   72.36%      28     21
    5163      .276393     1.000000      2    864     64   72.36%      13     22
    5264      .276393     1.000000      2    864     51   72.36%      39     22
    5365      .276393     1.000000      2    864     46   72.36%      48     22
    5466      .276393     1.000000      2    864     85   72.36%      15     23
    5566      .276393     1.000000      2    864     78   72.36%      23     23
    5668      .276393     1.000000      2    864     34   72.36%      30     23
    5769      .276393     1.000000      2    864     36   72.36%      32     24
    5870      .276393     1.000000      2    864     49   72.36%      38     24
    5972      .276393     1.000000      2    864     80   72.36%      11     24
    6072      .276393     1.000000      2    864     30   72.36%      58     25
    6174      .276393     1.000000      2    864     47   72.36%      21     25
Elapsed time (sec): 25, estimated tree completion: 0.00000
Heap usage: 311MB (peak 311MB, 1742KB system)
B&B tree size: 112MB total
 
    Node     BestSoln    BestBound   Sols Active  Depth     Gap     GInf   Time
    6275      .276393     1.000000      2    864     37   72.36%      35     25
    6375      .276393     1.000000      2    864     40   72.36%      46     26
    6475      .276393     1.000000      2    864     44   72.36%      25     26
    6577      .276393     1.000000      2    864     39   72.36%      45     26
    6679      .276393     1.000000      2    864     57   72.36%      20     27
    6779      .276393     1.000000      2    864     67   72.36%      19     27
    6882      .276393     1.000000      2    864     20   72.36%      40     27
    6982      .276393     1.000000      2    864     44   72.36%      45     28
    7084      .276393     1.000000      2    864     56   72.36%      26     28
    7184      .276393     1.000000      2    864     45   72.36%      47     28
    7287      .276393     1.000000      2    864     53   72.36%      23     29
    7389      .276393     1.000000      2    864     40   72.36%      40     29
    7490      .276393     1.000000      2    864     41   72.36%      39     29
STOPPING - MAXTIME limit reached (TIMELIMIT=30.00  time=30.00).
STOPPING - MAXTIME limit reached (TIMELIMIT=30.00  time=30.08).
 *** Search unfinished ***    Time:    30.08 Nodes:       7541
Heap usage: 36MB (peak 311MB, 444KB system)
Final MINLP objective (feasible sol.) : 2.763932056861722e-01
Final MINLP bound                     : 1.000000000000000e+00
  Max validation error      (abs/rel) :      .000 /      .000
  Max primal violation      (abs/rel) :       0.0 /       0.0
  Max integer violation     (abs    ) :       0.0
  Number of solutions found / nodes   :         2 /      7541
  Observed primal integral            :     .090%
  Solution time / primaldual integral :     30.08s/ 72.385065%
  Work / work units per second        :     21.70 /      0.72
*** Time limit reached ***
XPRESS 9.8.0 (46.01.01): limit, feasible solution; objective 0.2763932057
7541 branching nodes

Retrieve the solution from Xpress Global#

display_solution(ampl)
AMPL solve result: limit  code: 400
Objective value: 0.2763932056861722 
index0 1 2 3 4 5 6 7 8 9 10 11 12
index1
x.val 1 0.532567 0.721104 0.114947 0.885053 0.278896 0.045381 0.579993 0.797842 0.467433 0.420007 0.954619 0.202158
2 0.908340 0.443782 0.818349 0.181651 0.556218 0.298173 0.933322 0.484204 0.091660 0.066678 0.701827 0.515796
3 0.786701 0.944919 0.480289 0.519711 0.055081 0.449133 0.263710 0.098701 0.213299 0.736290 0.550867 0.901299
../_images/cf0eb07428aac36676744b10ad603666767b0553d0e586afb8fb7e20194d6a33.png

Conclusion#

We observed that local optimization (e.g., Xpress SLP) can quickly provide good solutions to nonlinear problems, but may require “reasonable” starting points. Xpress Global Optimizer can improve the result, taking longer time.