from dataclasses import dataclass
def expected_return(mu, weights):
return sum(m * w for m, w in zip(mu, weights, strict=True))
def risk(sigma, weights):
indices = range(len(weights))
return sum(sigma[i][j] * weights[i] * weights[j] for i in indices for j in indices)
@dataclass
class Market:
name: str
names: list
returns: list
covariance: list
@property
def num_assets(self):
return len(self.names)
@property
def assets(self):
return range(self.num_assets)
@dataclass
class Portfolio:
weights: list
expected_return: float
risk: floatPortfolio Optimization
Allocate capital across assets to minimize risk at a target return, the convex Markowitz model, then extend it with diversification, cardinality and transaction-cost constraints.
Introduction
We consider the portfolio optimization problem, where an investor aims to allocate capital among \(N\) assets within a single period. Portfolio optimization is a fundamental concept in finance that focuses on balancing risk and return. The objective is to determine the optimal weights to assign to each asset in the portfolio.
The curve on the left is the best risk attainable at each desired return, and the bars on the right show the allocation the model picks at one point on it.
Problem description
There are multiple variants of portfolio optimization problems. We start with the most fundamental one, the Markowitz model, and take the others in turn, each one adding to the last.
Input
- \(N\) assets; for each asset \(i\), its expected return \(\mu_i\)
- A desired return \(R\)
- For each pair of assets \((i, j)\), their covariance \(\Sigma_{ij}\)
Problem: find for each asset, the proportion of the capital invested in it, such that the desired return is met.
Objective: minimize the risk \(w^\top \Sigma w\), where \(w\) represents the vector of allocations.
Input data
We retrieve realistic input data from nasdaq.com. A Market holds a name for each asset, its expected return, and the covariance between every pair. A Portfolio holds the weight given to each asset, together with the return and the risk that follow from it.
A market too large to write out lives in a file. load_market reads one CSV from shared/data with one row per asset, holding its name, its expected return, and then its covariance with every asset in turn. That is where the hundred-asset market at the end of the page comes from.
import csv
from pathlib import Path
from plot import draw_comparison, draw_frontier, draw_market, draw_portfolio
DATA_DIR = Path("shared") / "data"
def load_market(file_name, name):
with (DATA_DIR / file_name).open(encoding="utf-8") as handle:
reader = csv.reader(handle)
next(reader)
rows = [row for row in reader if row]
names = [row[0] for row in rows]
returns = [float(row[1]) for row in rows]
covariance = [[float(value) for value in row[2:]] for row in rows]
return Market(name, names, returns, covariance)The worked example is ten companies from the NASDAQ. It is small enough to write out in full, so the numbers the model is given stay in plain sight.
names = [
"Facebook",
"Intel",
"Frontier",
"Micron",
"Apple",
"Qualcomm",
"Sirius",
"App. Mat.",
"Cisco",
"Yahoo",
]
mu = [
8.68097,
-6.08624,
-66.84089,
-69.02419,
-0.61631,
10.46047,
7.63278,
20.49615,
-0.257636,
19.25747,
]
sigma = [
[1.75, 0.38, 0.54, 0.63, -0.14, 0.29, -0.15, -0.19, 0.06, 0.10],
[0.38, 1.74, 0.75, 2.13, -0.14, 0.30, 0.86, 0.24, 0.28, 0.47],
[0.54, 0.75, 6.85, 0.31, -0.01, 0.84, -0.14, 0.71, 0.50, 0.95],
[0.63, 2.13, 0.31, 10.31, 0.48, 0.27, 0.23, 0.50, -0.02, 0.47],
[-0.14, -0.14, -0.01, 0.48, 1.24, -0.02, 0.12, 0.15, -0.10, 0.46],
[0.29, 0.30, 0.84, 0.27, -0.02, 1.08, 0.54, 0.38, 0.54, 0.75],
[-0.15, 0.86, -0.14, 0.23, 0.12, 0.54, 0.97, 0.49, 0.44, 0.60],
[-0.19, 0.24, 0.71, 0.50, 0.15, 0.38, 0.49, 2.35, 0.46, 0.86],
[0.06, 0.28, 0.50, -0.02, -0.10, 0.54, 0.44, 0.46, 0.84, 0.37],
[0.10, 0.47, 0.95, 0.47, 0.46, 0.75, 0.60, 0.86, 0.37, 3.16],
]
nasdaq = Market("Ten companies from the NASDAQ", names, mu, sigma)Five of the ten have a negative expected return. A model free to leave them out will, and the ones it does hold are those whose covariances let them offset each other.
draw_market(nasdaq, "Ten companies from the NASDAQ")The bars are \(\mu\) and the grid is \(\Sigma\), over the same assets in the same order. The diagonal of \(\Sigma\) is each asset’s own variance, not the risk \(w^\top \Sigma w\) the model minimizes. Micron and Frontier swing hardest by a wide margin, so the color scale is set by the off-diagonal pairs and clips on the diagonal. Those two are also the worst on the left. The assets that move most are the ones the model is being asked to leave out. Off the diagonal, the red cells are the pairs that move against each other, and diversification is built from those.
Solving a model
Each model below has a function of its own. It assembles the model and returns it together with the weight variables, without solving anything. solve takes any one of them, runs Knitro through the AMPL interface, and turns the weights into a Portfolio.
import pyomo.environ as pyo
SOLVER_NAME = "knitroampl"
def solve(market, build, **kwargs):
model, w = build(market, **kwargs)
pyo.SolverFactory(SOLVER_NAME).solve(model, tee=True)
weights = [w[i]() for i in market.assets]
expected = expected_return(market.returns, weights)
return Portfolio(weights, expected, risk(market.covariance, weights))The Markowitz model
The fundamental model minimizes the risk under a fixed return.
Variables
- \(w_i \in [0, 1]\), \(i = 1, \dots, N\): proportion of capital invested in asset \(i\)
Objective: minimize the risk
\[ \min \sum_{i=1}^N \sum_{j=1}^N \Sigma_{ij} w_i w_j \]
Constraints
- Expected return
\[ \sum_{i=1}^N \mu_i w_i \geq R \]
- Sum of proportions equals 1
\[ \sum_{i=1}^N w_i = 1 \]
The model has the following properties:
- Continuous variables only
- Quadratic objective
- Convex, since a covariance matrix is positive semi-definite
- Therefore, it is a convex QP
markowitz writes the model above, with the quadratic objective handed to Objective as the double sum it is written with.
def markowitz(market, *, desired_return):
mu, sigma = market.returns, market.covariance
model = pyo.ConcreteModel()
model.assets = pyo.RangeSet(0, market.num_assets - 1)
model.w = pyo.Var(model.assets, bounds=(0, 1))
assets, w = model.assets, model.w
variance = pyo.quicksum(sigma[i][j] * w[i] * w[j] for i in assets for j in assets)
model.obj = pyo.Objective(expr=variance, sense=pyo.minimize)
model.budget = pyo.Constraint(expr=pyo.quicksum(w[i] for i in assets) == 1)
expected = pyo.quicksum(mu[i] * w[i] for i in assets)
model.return_floor = pyo.Constraint(expr=expected >= desired_return)
return model, model.wSolving for a desired return of 10:
portfolio = solve(nasdaq, markowitz, desired_return=10)Artelys Knitro 16.0.0:
=======================================
Commercial License
Artelys Knitro 16.0.0
=======================================
Knitro using 1 thread.
No start point provided -- Knitro computing one.
Knitro presolve eliminated 0 variables (0%) and 0 constraints (0%) in 0.00s.
concurrent_evals 0
datacheck 0
feastol 1e-06
feastol_abs 0.001
findiff_numthreads 1
hessian_no_f 1
hessopt 1
opttol 1e-06
opttol_abs 0.001
Knitro running advanced initialization strategy specified by initpt_strategy.
Problem Characteristics | Presolved
-----------------------
Problem type: convex QP
Objective: minimize / quadratic
Number of variables: 10 | 10
bounds: lower upper range | lower upper range
0 0 10 | 2 0 8
free fixed | free fixed
0 0 | 0 0
Number of constraints: 2 | 2
eq. ineq. range | eq. ineq. range
linear: 1 1 0 | 1 1 0
quadratic: 0 0 0 | 0 0 0
Number of nonzeros:
objective Jacobian Hessian | objective Jacobian Hessian
linear: 0 20 | 0 20
quadratic: 10 0 55 | 10 0 55
total: 10 20 55 | 10 20 55
Coefficient range:
linear objective: [0e+00, 0e+00] | [0e+00, 0e+00]
linear constraints: [3e-01, 7e+01] | [3e-01, 7e+01]
quadratic objective: [2e-02, 1e+01] | [2e-02, 1e+01]
quadratic constraints: [0e+00, 0e+00] | [0e+00, 0e+00]
variable bounds: [1e+00, 1e+00] | [1e+00, 1e+00]
constraint bounds: [1e+00, 1e+01] | [1e+00, 1e+01]
Knitro using the Interior-Point/Barrier Direct algorithm.
Iter Objective FeasError OptError ||Step|| Time
-------- -------------- --------- --------- --------- --------
0 1.087150e+00 6.79e-01
6 4.289111e-01 1.11e-16 2.13e-08 4.61e-04 0.01
EXIT: Optimal solution found.
HINT: Knitro spent 1.7% of solution time (0.000120 secs) checking model
convexity. To skip the automatic convexity checker for QPs and QCQPs,
explicity set the user option convex=0 or convex=1.
Final Statistics
----------------
Final objective value = 4.28911054277269e-01
Final feasibility error (abs / rel) = 1.11e-16 / 1.93e-18
Final optimality error (abs / rel) = 2.13e-08 / 1.68e-08
# of iterations = 6
# of CG iterations = 0
# of function evaluations = 0
# of gradient evaluations = 0
# of Hessian evaluations = 0
Total program time (secs) = 0.00714 ( 0.004 CPU time)
Time spent in evaluations (secs) = 0.00000
================================================================================
Show the full outputHide the full output
draw_portfolio(portfolio, nasdaq.names, "Least risk at a desired return of 10")print(f"Total risk: {portfolio.risk:.2f}")Total risk: 0.43
Here for a desired return of 10, it seems better to diversify to reduce the portfolio risk.
Varying the desired return
In the previous section, we considered a single fixed return. Now let’s consider the optimization for different levels of return.
returns = [5, 7.5, 10, 15]base = [solve(nasdaq, markowitz, desired_return=r) for r in returns]Show the full outputHide the full output
Artelys Knitro 16.0.0:
=======================================
Commercial License
Artelys Knitro 16.0.0
=======================================
Knitro using 1 thread.
No start point provided -- Knitro computing one.
Knitro presolve eliminated 0 variables (0%) and 0 constraints (0%) in 0.00s.
concurrent_evals 0
datacheck 0
feastol 1e-06
feastol_abs 0.001
findiff_numthreads 1
hessian_no_f 1
hessopt 1
opttol 1e-06
opttol_abs 0.001
Knitro running advanced initialization strategy specified by initpt_strategy.
Problem Characteristics | Presolved
-----------------------
Problem type: convex QP
Objective: minimize / quadratic
Number of variables: 10 | 10
bounds: lower upper range | lower upper range
0 0 10 | 2 0 8
free fixed | free fixed
0 0 | 0 0
Number of constraints: 2 | 2
eq. ineq. range | eq. ineq. range
linear: 1 1 0 | 1 1 0
quadratic: 0 0 0 | 0 0 0
Number of nonzeros:
objective Jacobian Hessian | objective Jacobian Hessian
linear: 0 20 | 0 20
quadratic: 10 0 55 | 10 0 55
total: 10 20 55 | 10 20 55
Coefficient range:
linear objective: [0e+00, 0e+00] | [0e+00, 0e+00]
linear constraints: [3e-01, 7e+01] | [3e-01, 7e+01]
quadratic objective: [2e-02, 1e+01] | [2e-02, 1e+01]
quadratic constraints: [0e+00, 0e+00] | [0e+00, 0e+00]
variable bounds: [1e+00, 1e+00] | [1e+00, 1e+00]
constraint bounds: [1e+00, 5e+00] | [1e+00, 5e+00]
Knitro using the Interior-Point/Barrier Direct algorithm.
Iter Objective FeasError OptError ||Step|| Time
-------- -------------- --------- --------- --------- --------
0 1.113473e+00 2.37e-01
7 3.231341e-01 0.00e+00 2.56e-11 1.59e-04 0.01
EXIT: Optimal solution found.
HINT: Knitro spent 1.4% of solution time (0.000107 secs) checking model
convexity. To skip the automatic convexity checker for QPs and QCQPs,
explicity set the user option convex=0 or convex=1.
Final Statistics
----------------
Final objective value = 3.23134092792703e-01
Final feasibility error (abs / rel) = 0.00e+00 / 0.00e+00
Final optimality error (abs / rel) = 2.56e-11 / 2.56e-11
# of iterations = 7
# of CG iterations = 0
# of function evaluations = 0
# of gradient evaluations = 0
# of Hessian evaluations = 0
Total program time (secs) = 0.00759 ( 0.005 CPU time)
Time spent in evaluations (secs) = 0.00000
================================================================================
Artelys Knitro 16.0.0:
=======================================
Commercial License
Artelys Knitro 16.0.0
=======================================
Knitro using 1 thread.
No start point provided -- Knitro computing one.
Knitro presolve eliminated 0 variables (0%) and 0 constraints (0%) in 0.00s.
concurrent_evals 0
datacheck 0
feastol 1e-06
feastol_abs 0.001
findiff_numthreads 1
hessian_no_f 1
hessopt 1
opttol 1e-06
opttol_abs 0.001
Knitro running advanced initialization strategy specified by initpt_strategy.
Problem Characteristics | Presolved
-----------------------
Problem type: convex QP
Objective: minimize / quadratic
Number of variables: 10 | 10
bounds: lower upper range | lower upper range
0 0 10 | 2 0 8
free fixed | free fixed
0 0 | 0 0
Number of constraints: 2 | 2
eq. ineq. range | eq. ineq. range
linear: 1 1 0 | 1 1 0
quadratic: 0 0 0 | 0 0 0
Number of nonzeros:
objective Jacobian Hessian | objective Jacobian Hessian
linear: 0 20 | 0 20
quadratic: 10 0 55 | 10 0 55
total: 10 20 55 | 10 20 55
Coefficient range:
linear objective: [0e+00, 0e+00] | [0e+00, 0e+00]
linear constraints: [3e-01, 7e+01] | [3e-01, 7e+01]
quadratic objective: [2e-02, 1e+01] | [2e-02, 1e+01]
quadratic constraints: [0e+00, 0e+00] | [0e+00, 0e+00]
variable bounds: [1e+00, 1e+00] | [1e+00, 1e+00]
constraint bounds: [1e+00, 8e+00] | [1e+00, 8e+00]
Knitro using the Interior-Point/Barrier Direct algorithm.
Iter Objective FeasError OptError ||Step|| Time
-------- -------------- --------- --------- --------- --------
0 1.096865e+00 2.32e-01
8 3.577912e-01 2.22e-16 6.51e-08 5.03e-04 0.01
EXIT: Optimal solution found.
HINT: Knitro spent 1.2% of solution time (0.000082 secs) checking model
convexity. To skip the automatic convexity checker for QPs and QCQPs,
explicity set the user option convex=0 or convex=1.
Final Statistics
----------------
Final objective value = 3.57791213002902e-01
Final feasibility error (abs / rel) = 2.22e-16 / 4.03e-18
Final optimality error (abs / rel) = 6.51e-08 / 6.51e-08
# of iterations = 8
# of CG iterations = 0
# of function evaluations = 0
# of gradient evaluations = 0
# of Hessian evaluations = 0
Total program time (secs) = 0.00712 ( 0.004 CPU time)
Time spent in evaluations (secs) = 0.00000
================================================================================
Artelys Knitro 16.0.0:
=======================================
Commercial License
Artelys Knitro 16.0.0
=======================================
Knitro using 1 thread.
No start point provided -- Knitro computing one.
Knitro presolve eliminated 0 variables (0%) and 0 constraints (0%) in 0.00s.
concurrent_evals 0
datacheck 0
feastol 1e-06
feastol_abs 0.001
findiff_numthreads 1
hessian_no_f 1
hessopt 1
opttol 1e-06
opttol_abs 0.001
Knitro running advanced initialization strategy specified by initpt_strategy.
Problem Characteristics | Presolved
-----------------------
Problem type: convex QP
Objective: minimize / quadratic
Number of variables: 10 | 10
bounds: lower upper range | lower upper range
0 0 10 | 2 0 8
free fixed | free fixed
0 0 | 0 0
Number of constraints: 2 | 2
eq. ineq. range | eq. ineq. range
linear: 1 1 0 | 1 1 0
quadratic: 0 0 0 | 0 0 0
Number of nonzeros:
objective Jacobian Hessian | objective Jacobian Hessian
linear: 0 20 | 0 20
quadratic: 10 0 55 | 10 0 55
total: 10 20 55 | 10 20 55
Coefficient range:
linear objective: [0e+00, 0e+00] | [0e+00, 0e+00]
linear constraints: [3e-01, 7e+01] | [3e-01, 7e+01]
quadratic objective: [2e-02, 1e+01] | [2e-02, 1e+01]
quadratic constraints: [0e+00, 0e+00] | [0e+00, 0e+00]
variable bounds: [1e+00, 1e+00] | [1e+00, 1e+00]
constraint bounds: [1e+00, 1e+01] | [1e+00, 1e+01]
Knitro using the Interior-Point/Barrier Direct algorithm.
Iter Objective FeasError OptError ||Step|| Time
-------- -------------- --------- --------- --------- --------
0 1.087150e+00 6.79e-01
6 4.289111e-01 1.11e-16 2.13e-08 4.61e-04 0.01
EXIT: Optimal solution found.
Final Statistics
----------------
Final objective value = 4.28911054277269e-01
Final feasibility error (abs / rel) = 1.11e-16 / 1.93e-18
Final optimality error (abs / rel) = 2.13e-08 / 1.68e-08
# of iterations = 6
# of CG iterations = 0
# of function evaluations = 0
# of gradient evaluations = 0
# of Hessian evaluations = 0
Total program time (secs) = 0.00744 ( 0.005 CPU time)
Time spent in evaluations (secs) = 0.00000
================================================================================
Artelys Knitro 16.0.0:
=======================================
Commercial License
Artelys Knitro 16.0.0
=======================================
Knitro using 1 thread.
No start point provided -- Knitro computing one.
Knitro presolve eliminated 0 variables (0%) and 0 constraints (0%) in 0.00s.
concurrent_evals 0
datacheck 0
feastol 1e-06
feastol_abs 0.001
findiff_numthreads 1
hessian_no_f 1
hessopt 1
opttol 1e-06
opttol_abs 0.001
Knitro running advanced initialization strategy specified by initpt_strategy.
Problem Characteristics | Presolved
-----------------------
Problem type: convex QP
Objective: minimize / quadratic
Number of variables: 10 | 10
bounds: lower upper range | lower upper range
0 0 10 | 2 0 8
free fixed | free fixed
0 0 | 0 0
Number of constraints: 2 | 2
eq. ineq. range | eq. ineq. range
linear: 1 1 0 | 1 1 0
quadratic: 0 0 0 | 0 0 0
Number of nonzeros:
objective Jacobian Hessian | objective Jacobian Hessian
linear: 0 20 | 0 20
quadratic: 10 0 55 | 10 0 55
total: 10 20 55 | 10 20 55
Coefficient range:
linear objective: [0e+00, 0e+00] | [0e+00, 0e+00]
linear constraints: [3e-01, 7e+01] | [3e-01, 7e+01]
quadratic objective: [2e-02, 1e+01] | [2e-02, 1e+01]
quadratic constraints: [0e+00, 0e+00] | [0e+00, 0e+00]
variable bounds: [1e+00, 1e+00] | [1e+00, 1e+00]
constraint bounds: [1e+00, 2e+01] | [1e+00, 2e+01]
Knitro using the Interior-Point/Barrier Direct algorithm.
Iter Objective FeasError OptError ||Step|| Time
-------- -------------- --------- --------- --------- --------
0 1.101172e+00 3.92e+00
6 7.666828e-01 0.00e+00 4.52e-11 2.11e-05 0.01
EXIT: Optimal solution found.
Final Statistics
----------------
Final objective value = 7.66682814832761e-01
Final feasibility error (abs / rel) = 0.00e+00 / 0.00e+00
Final optimality error (abs / rel) = 4.52e-11 / 2.14e-11
# of iterations = 6
# of CG iterations = 0
# of function evaluations = 0
# of gradient evaluations = 0
# of Hessian evaluations = 0
Total program time (secs) = 0.01359 ( 0.004 CPU time)
Time spent in evaluations (secs) = 0.00000
================================================================================
draw_comparison(
base,
[f"Return {r}, Risk {s.risk:.2f}" for r, s in zip(returns, base)],
nasdaq.names,
"Least risk for varying desired returns",
)Sweeping the desired return over a finer grid traces the efficient frontier: the best risk attainable at each level of return. Every point on it is a solve.
grid = [4 + 0.5 * k for k in range(23)]frontier = [solve(nasdaq, markowitz, desired_return=r) for r in grid]Show the full outputHide the full output
Artelys Knitro 16.0.0:
=======================================
Commercial License
Artelys Knitro 16.0.0
=======================================
Knitro using 1 thread.
No start point provided -- Knitro computing one.
Knitro presolve eliminated 0 variables (0%) and 0 constraints (0%) in 0.00s.
concurrent_evals 0
datacheck 0
feastol 1e-06
feastol_abs 0.001
findiff_numthreads 1
hessian_no_f 1
hessopt 1
opttol 1e-06
opttol_abs 0.001
Knitro running advanced initialization strategy specified by initpt_strategy.
Problem Characteristics | Presolved
-----------------------
Problem type: convex QP
Objective: minimize / quadratic
Number of variables: 10 | 10
bounds: lower upper range | lower upper range
0 0 10 | 2 0 8
free fixed | free fixed
0 0 | 0 0
Number of constraints: 2 | 2
eq. ineq. range | eq. ineq. range
linear: 1 1 0 | 1 1 0
quadratic: 0 0 0 | 0 0 0
Number of nonzeros:
objective Jacobian Hessian | objective Jacobian Hessian
linear: 0 20 | 0 20
quadratic: 10 0 55 | 10 0 55
total: 10 20 55 | 10 20 55
Coefficient range:
linear objective: [0e+00, 0e+00] | [0e+00, 0e+00]
linear constraints: [3e-01, 7e+01] | [3e-01, 7e+01]
quadratic objective: [2e-02, 1e+01] | [2e-02, 1e+01]
quadratic constraints: [0e+00, 0e+00] | [0e+00, 0e+00]
variable bounds: [1e+00, 1e+00] | [1e+00, 1e+00]
constraint bounds: [1e+00, 4e+00] | [1e+00, 4e+00]
Knitro using the Interior-Point/Barrier Direct algorithm.
Iter Objective FeasError OptError ||Step|| Time
-------- -------------- --------- --------- --------- --------
0 1.120086e+00 2.38e-01
8 3.187773e-01 0.00e+00 3.04e-11 3.89e-05 0.02
EXIT: Optimal solution found.
Final Statistics
----------------
Final objective value = 3.18777275782998e-01
Final feasibility error (abs / rel) = 0.00e+00 / 0.00e+00
Final optimality error (abs / rel) = 3.04e-11 / 3.04e-11
# of iterations = 8
# of CG iterations = 0
# of function evaluations = 0
# of gradient evaluations = 0
# of Hessian evaluations = 0
Total program time (secs) = 0.01849 ( 0.005 CPU time)
Time spent in evaluations (secs) = 0.00000
================================================================================
Artelys Knitro 16.0.0:
=======================================
Commercial License
Artelys Knitro 16.0.0
=======================================
Knitro using 1 thread.
No start point provided -- Knitro computing one.
Knitro presolve eliminated 0 variables (0%) and 0 constraints (0%) in 0.00s.
concurrent_evals 0
datacheck 0
feastol 1e-06
feastol_abs 0.001
findiff_numthreads 1
hessian_no_f 1
hessopt 1
opttol 1e-06
opttol_abs 0.001
Knitro running advanced initialization strategy specified by initpt_strategy.
Problem Characteristics | Presolved
-----------------------
Problem type: convex QP
Objective: minimize / quadratic
Number of variables: 10 | 10
bounds: lower upper range | lower upper range
0 0 10 | 2 0 8
free fixed | free fixed
0 0 | 0 0
Number of constraints: 2 | 2
eq. ineq. range | eq. ineq. range
linear: 1 1 0 | 1 1 0
quadratic: 0 0 0 | 0 0 0
Number of nonzeros:
objective Jacobian Hessian | objective Jacobian Hessian
linear: 0 20 | 0 20
quadratic: 10 0 55 | 10 0 55
total: 10 20 55 | 10 20 55
Coefficient range:
linear objective: [0e+00, 0e+00] | [0e+00, 0e+00]
linear constraints: [3e-01, 7e+01] | [3e-01, 7e+01]
quadratic objective: [2e-02, 1e+01] | [2e-02, 1e+01]
quadratic constraints: [0e+00, 0e+00] | [0e+00, 0e+00]
variable bounds: [1e+00, 1e+00] | [1e+00, 1e+00]
constraint bounds: [1e+00, 4e+00] | [1e+00, 4e+00]
Knitro using the Interior-Point/Barrier Direct algorithm.
Iter Objective FeasError OptError ||Step|| Time
-------- -------------- --------- --------- --------- --------
0 1.117635e+00 2.38e-01
7 3.204971e-01 1.11e-16 6.11e-10 5.36e-04 0.02
EXIT: Optimal solution found.
Final Statistics
----------------
Final objective value = 3.20497086140137e-01
Final feasibility error (abs / rel) = 1.11e-16 / 2.13e-18
Final optimality error (abs / rel) = 6.11e-10 / 6.11e-10
# of iterations = 7
# of CG iterations = 0
# of function evaluations = 0
# of gradient evaluations = 0
# of Hessian evaluations = 0
Total program time (secs) = 0.01650 ( 0.004 CPU time)
Time spent in evaluations (secs) = 0.00000
================================================================================
Artelys Knitro 16.0.0:
=======================================
Commercial License
Artelys Knitro 16.0.0
=======================================
Knitro using 1 thread.
No start point provided -- Knitro computing one.
Knitro presolve eliminated 0 variables (0%) and 0 constraints (0%) in 0.00s.
concurrent_evals 0
datacheck 0
feastol 1e-06
feastol_abs 0.001
findiff_numthreads 1
hessian_no_f 1
hessopt 1
opttol 1e-06
opttol_abs 0.001
Knitro running advanced initialization strategy specified by initpt_strategy.
Problem Characteristics | Presolved
-----------------------
Problem type: convex QP
Objective: minimize / quadratic
Number of variables: 10 | 10
bounds: lower upper range | lower upper range
0 0 10 | 2 0 8
free fixed | free fixed
0 0 | 0 0
Number of constraints: 2 | 2
eq. ineq. range | eq. ineq. range
linear: 1 1 0 | 1 1 0
quadratic: 0 0 0 | 0 0 0
Number of nonzeros:
objective Jacobian Hessian | objective Jacobian Hessian
linear: 0 20 | 0 20
quadratic: 10 0 55 | 10 0 55
total: 10 20 55 | 10 20 55
Coefficient range:
linear objective: [0e+00, 0e+00] | [0e+00, 0e+00]
linear constraints: [3e-01, 7e+01] | [3e-01, 7e+01]
quadratic objective: [2e-02, 1e+01] | [2e-02, 1e+01]
quadratic constraints: [0e+00, 0e+00] | [0e+00, 0e+00]
variable bounds: [1e+00, 1e+00] | [1e+00, 1e+00]
constraint bounds: [1e+00, 5e+00] | [1e+00, 5e+00]
Knitro using the Interior-Point/Barrier Direct algorithm.
Iter Objective FeasError OptError ||Step|| Time
-------- -------------- --------- --------- --------- --------
0 1.113473e+00 2.37e-01
7 3.231341e-01 0.00e+00 2.56e-11 1.59e-04 0.01
EXIT: Optimal solution found.
Final Statistics
----------------
Final objective value = 3.23134092792703e-01
Final feasibility error (abs / rel) = 0.00e+00 / 0.00e+00
Final optimality error (abs / rel) = 2.56e-11 / 2.56e-11
# of iterations = 7
# of CG iterations = 0
# of function evaluations = 0
# of gradient evaluations = 0
# of Hessian evaluations = 0
Total program time (secs) = 0.00908 ( 0.006 CPU time)
Time spent in evaluations (secs) = 0.00000
================================================================================
Artelys Knitro 16.0.0:
=======================================
Commercial License
Artelys Knitro 16.0.0
=======================================
Knitro using 1 thread.
No start point provided -- Knitro computing one.
Knitro presolve eliminated 0 variables (0%) and 0 constraints (0%) in 0.00s.
concurrent_evals 0
datacheck 0
feastol 1e-06
feastol_abs 0.001
findiff_numthreads 1
hessian_no_f 1
hessopt 1
opttol 1e-06
opttol_abs 0.001
Knitro running advanced initialization strategy specified by initpt_strategy.
Problem Characteristics | Presolved
-----------------------
Problem type: convex QP
Objective: minimize / quadratic
Number of variables: 10 | 10
bounds: lower upper range | lower upper range
0 0 10 | 2 0 8
free fixed | free fixed
0 0 | 0 0
Number of constraints: 2 | 2
eq. ineq. range | eq. ineq. range
linear: 1 1 0 | 1 1 0
quadratic: 0 0 0 | 0 0 0
Number of nonzeros:
objective Jacobian Hessian | objective Jacobian Hessian
linear: 0 20 | 0 20
quadratic: 10 0 55 | 10 0 55
total: 10 20 55 | 10 20 55
Coefficient range:
linear objective: [0e+00, 0e+00] | [0e+00, 0e+00]
linear constraints: [3e-01, 7e+01] | [3e-01, 7e+01]
quadratic objective: [2e-02, 1e+01] | [2e-02, 1e+01]
quadratic constraints: [0e+00, 0e+00] | [0e+00, 0e+00]
variable bounds: [1e+00, 1e+00] | [1e+00, 1e+00]
constraint bounds: [1e+00, 6e+00] | [1e+00, 6e+00]
Knitro using the Interior-Point/Barrier Direct algorithm.
Iter Objective FeasError OptError ||Step|| Time
-------- -------------- --------- --------- --------- --------
0 1.109591e+00 2.36e-01
7 3.271836e-01 0.00e+00 7.73e-12 2.51e-05 0.01
EXIT: Optimal solution found.
HINT: Knitro spent 1.4% of solution time (0.000092 secs) checking model
convexity. To skip the automatic convexity checker for QPs and QCQPs,
explicity set the user option convex=0 or convex=1.
Final Statistics
----------------
Final objective value = 3.27183571757067e-01
Final feasibility error (abs / rel) = 0.00e+00 / 0.00e+00
Final optimality error (abs / rel) = 7.73e-12 / 7.73e-12
# of iterations = 7
# of CG iterations = 0
# of function evaluations = 0
# of gradient evaluations = 0
# of Hessian evaluations = 0
Total program time (secs) = 0.00681 ( 0.004 CPU time)
Time spent in evaluations (secs) = 0.00000
================================================================================
Artelys Knitro 16.0.0:
=======================================
Commercial License
Artelys Knitro 16.0.0
=======================================
Knitro using 1 thread.
No start point provided -- Knitro computing one.
Knitro presolve eliminated 0 variables (0%) and 0 constraints (0%) in 0.00s.
concurrent_evals 0
datacheck 0
feastol 1e-06
feastol_abs 0.001
findiff_numthreads 1
hessian_no_f 1
hessopt 1
opttol 1e-06
opttol_abs 0.001
Knitro running advanced initialization strategy specified by initpt_strategy.
Problem Characteristics | Presolved
-----------------------
Problem type: convex QP
Objective: minimize / quadratic
Number of variables: 10 | 10
bounds: lower upper range | lower upper range
0 0 10 | 2 0 8
free fixed | free fixed
0 0 | 0 0
Number of constraints: 2 | 2
eq. ineq. range | eq. ineq. range
linear: 1 1 0 | 1 1 0
quadratic: 0 0 0 | 0 0 0
Number of nonzeros:
objective Jacobian Hessian | objective Jacobian Hessian
linear: 0 20 | 0 20
quadratic: 10 0 55 | 10 0 55
total: 10 20 55 | 10 20 55
Coefficient range:
linear objective: [0e+00, 0e+00] | [0e+00, 0e+00]
linear constraints: [3e-01, 7e+01] | [3e-01, 7e+01]
quadratic objective: [2e-02, 1e+01] | [2e-02, 1e+01]
quadratic constraints: [0e+00, 0e+00] | [0e+00, 0e+00]
variable bounds: [1e+00, 1e+00] | [1e+00, 1e+00]
constraint bounds: [1e+00, 6e+00] | [1e+00, 6e+00]
Knitro using the Interior-Point/Barrier Direct algorithm.
Iter Objective FeasError OptError ||Step|| Time
-------- -------------- --------- --------- --------- --------
0 1.105989e+00 2.35e-01
7 3.326742e-01 1.11e-16 1.63e-10 8.08e-05 0.02
EXIT: Optimal solution found.
Final Statistics
----------------
Final objective value = 3.32674176212433e-01
Final feasibility error (abs / rel) = 1.11e-16 / 2.07e-18
Final optimality error (abs / rel) = 1.63e-10 / 1.63e-10
# of iterations = 7
# of CG iterations = 0
# of function evaluations = 0
# of gradient evaluations = 0
# of Hessian evaluations = 0
Total program time (secs) = 0.02119 ( 0.004 CPU time)
Time spent in evaluations (secs) = 0.00000
================================================================================
Artelys Knitro 16.0.0:
=======================================
Commercial License
Artelys Knitro 16.0.0
=======================================
Knitro using 1 thread.
No start point provided -- Knitro computing one.
Knitro presolve eliminated 0 variables (0%) and 0 constraints (0%) in 0.00s.
concurrent_evals 0
datacheck 0
feastol 1e-06
feastol_abs 0.001
findiff_numthreads 1
hessian_no_f 1
hessopt 1
opttol 1e-06
opttol_abs 0.001
Knitro running advanced initialization strategy specified by initpt_strategy.
Problem Characteristics | Presolved
-----------------------
Problem type: convex QP
Objective: minimize / quadratic
Number of variables: 10 | 10
bounds: lower upper range | lower upper range
0 0 10 | 2 0 8
free fixed | free fixed
0 0 | 0 0
Number of constraints: 2 | 2
eq. ineq. range | eq. ineq. range
linear: 1 1 0 | 1 1 0
quadratic: 0 0 0 | 0 0 0
Number of nonzeros:
objective Jacobian Hessian | objective Jacobian Hessian
linear: 0 20 | 0 20
quadratic: 10 0 55 | 10 0 55
total: 10 20 55 | 10 20 55
Coefficient range:
linear objective: [0e+00, 0e+00] | [0e+00, 0e+00]
linear constraints: [3e-01, 7e+01] | [3e-01, 7e+01]
quadratic objective: [2e-02, 1e+01] | [2e-02, 1e+01]
quadratic constraints: [0e+00, 0e+00] | [0e+00, 0e+00]
variable bounds: [1e+00, 1e+00] | [1e+00, 1e+00]
constraint bounds: [1e+00, 6e+00] | [1e+00, 6e+00]
Knitro using the Interior-Point/Barrier Direct algorithm.
Iter Objective FeasError OptError ||Step|| Time
-------- -------------- --------- --------- --------- --------
0 1.102667e+00 2.34e-01
7 3.396059e-01 0.00e+00 1.06e-09 3.37e-04 0.01
EXIT: Optimal solution found.
HINT: Knitro spent 1.3% of solution time (0.000086 secs) checking model
convexity. To skip the automatic convexity checker for QPs and QCQPs,
explicity set the user option convex=0 or convex=1.
Final Statistics
----------------
Final objective value = 3.39605906702465e-01
Final feasibility error (abs / rel) = 0.00e+00 / 0.00e+00
Final optimality error (abs / rel) = 1.06e-09 / 1.06e-09
# of iterations = 7
# of CG iterations = 0
# of function evaluations = 0
# of gradient evaluations = 0
# of Hessian evaluations = 0
Total program time (secs) = 0.00669 ( 0.004 CPU time)
Time spent in evaluations (secs) = 0.00000
================================================================================
Artelys Knitro 16.0.0:
=======================================
Commercial License
Artelys Knitro 16.0.0
=======================================
Knitro using 1 thread.
No start point provided -- Knitro computing one.
Knitro presolve eliminated 0 variables (0%) and 0 constraints (0%) in 0.00s.
concurrent_evals 0
datacheck 0
feastol 1e-06
feastol_abs 0.001
findiff_numthreads 1
hessian_no_f 1
hessopt 1
opttol 1e-06
opttol_abs 0.001
Knitro running advanced initialization strategy specified by initpt_strategy.
Problem Characteristics | Presolved
-----------------------
Problem type: convex QP
Objective: minimize / quadratic
Number of variables: 10 | 10
bounds: lower upper range | lower upper range
0 0 10 | 2 0 8
free fixed | free fixed
0 0 | 0 0
Number of constraints: 2 | 2
eq. ineq. range | eq. ineq. range
linear: 1 1 0 | 1 1 0
quadratic: 0 0 0 | 0 0 0
Number of nonzeros:
objective Jacobian Hessian | objective Jacobian Hessian
linear: 0 20 | 0 20
quadratic: 10 0 55 | 10 0 55
total: 10 20 55 | 10 20 55
Coefficient range:
linear objective: [0e+00, 0e+00] | [0e+00, 0e+00]
linear constraints: [3e-01, 7e+01] | [3e-01, 7e+01]
quadratic objective: [2e-02, 1e+01] | [2e-02, 1e+01]
quadratic constraints: [0e+00, 0e+00] | [0e+00, 0e+00]
variable bounds: [1e+00, 1e+00] | [1e+00, 1e+00]
constraint bounds: [1e+00, 7e+00] | [1e+00, 7e+00]
Knitro using the Interior-Point/Barrier Direct algorithm.
Iter Objective FeasError OptError ||Step|| Time
-------- -------------- --------- --------- --------- --------
0 1.099626e+00 2.33e-01
7 3.479790e-01 0.00e+00 2.58e-07 1.27e-03 0.02
EXIT: Optimal solution found.
Final Statistics
----------------
Final objective value = 3.47979026747516e-01
Final feasibility error (abs / rel) = 0.00e+00 / 0.00e+00
Final optimality error (abs / rel) = 2.58e-07 / 2.58e-07
# of iterations = 7
# of CG iterations = 0
# of function evaluations = 0
# of gradient evaluations = 0
# of Hessian evaluations = 0
Total program time (secs) = 0.01814 ( 0.004 CPU time)
Time spent in evaluations (secs) = 0.00000
================================================================================
Artelys Knitro 16.0.0:
=======================================
Commercial License
Artelys Knitro 16.0.0
=======================================
Knitro using 1 thread.
No start point provided -- Knitro computing one.
Knitro presolve eliminated 0 variables (0%) and 0 constraints (0%) in 0.00s.
concurrent_evals 0
datacheck 0
feastol 1e-06
feastol_abs 0.001
findiff_numthreads 1
hessian_no_f 1
hessopt 1
opttol 1e-06
opttol_abs 0.001
Knitro running advanced initialization strategy specified by initpt_strategy.
Problem Characteristics | Presolved
-----------------------
Problem type: convex QP
Objective: minimize / quadratic
Number of variables: 10 | 10
bounds: lower upper range | lower upper range
0 0 10 | 2 0 8
free fixed | free fixed
0 0 | 0 0
Number of constraints: 2 | 2
eq. ineq. range | eq. ineq. range
linear: 1 1 0 | 1 1 0
quadratic: 0 0 0 | 0 0 0
Number of nonzeros:
objective Jacobian Hessian | objective Jacobian Hessian
linear: 0 20 | 0 20
quadratic: 10 0 55 | 10 0 55
total: 10 20 55 | 10 20 55
Coefficient range:
linear objective: [0e+00, 0e+00] | [0e+00, 0e+00]
linear constraints: [3e-01, 7e+01] | [3e-01, 7e+01]
quadratic objective: [2e-02, 1e+01] | [2e-02, 1e+01]
quadratic constraints: [0e+00, 0e+00] | [0e+00, 0e+00]
variable bounds: [1e+00, 1e+00] | [1e+00, 1e+00]
constraint bounds: [1e+00, 8e+00] | [1e+00, 8e+00]
Knitro using the Interior-Point/Barrier Direct algorithm.
Iter Objective FeasError OptError ||Step|| Time
-------- -------------- --------- --------- --------- --------
0 1.096865e+00 2.32e-01
8 3.577912e-01 2.22e-16 6.51e-08 5.03e-04 0.01
EXIT: Optimal solution found.
Final Statistics
----------------
Final objective value = 3.57791213002902e-01
Final feasibility error (abs / rel) = 2.22e-16 / 4.03e-18
Final optimality error (abs / rel) = 6.51e-08 / 6.51e-08
# of iterations = 8
# of CG iterations = 0
# of function evaluations = 0
# of gradient evaluations = 0
# of Hessian evaluations = 0
Total program time (secs) = 0.01418 ( 0.004 CPU time)
Time spent in evaluations (secs) = 0.00000
================================================================================
Artelys Knitro 16.0.0:
=======================================
Commercial License
Artelys Knitro 16.0.0
=======================================
Knitro using 1 thread.
No start point provided -- Knitro computing one.
Knitro presolve eliminated 0 variables (0%) and 0 constraints (0%) in 0.00s.
concurrent_evals 0
datacheck 0
feastol 1e-06
feastol_abs 0.001
findiff_numthreads 1
hessian_no_f 1
hessopt 1
opttol 1e-06
opttol_abs 0.001
Knitro running advanced initialization strategy specified by initpt_strategy.
Problem Characteristics | Presolved
-----------------------
Problem type: convex QP
Objective: minimize / quadratic
Number of variables: 10 | 10
bounds: lower upper range | lower upper range
0 0 10 | 2 0 8
free fixed | free fixed
0 0 | 0 0
Number of constraints: 2 | 2
eq. ineq. range | eq. ineq. range
linear: 1 1 0 | 1 1 0
quadratic: 0 0 0 | 0 0 0
Number of nonzeros:
objective Jacobian Hessian | objective Jacobian Hessian
linear: 0 20 | 0 20
quadratic: 10 0 55 | 10 0 55
total: 10 20 55 | 10 20 55
Coefficient range:
linear objective: [0e+00, 0e+00] | [0e+00, 0e+00]
linear constraints: [3e-01, 7e+01] | [3e-01, 7e+01]
quadratic objective: [2e-02, 1e+01] | [2e-02, 1e+01]
quadratic constraints: [0e+00, 0e+00] | [0e+00, 0e+00]
variable bounds: [1e+00, 1e+00] | [1e+00, 1e+00]
constraint bounds: [1e+00, 8e+00] | [1e+00, 8e+00]
Knitro using the Interior-Point/Barrier Direct algorithm.
Iter Objective FeasError OptError ||Step|| Time
-------- -------------- --------- --------- --------- --------
0 1.094384e+00 2.31e-01
7 3.689799e-01 2.22e-16 2.18e-08 6.91e-04 0.01
EXIT: Optimal solution found.
Final Statistics
----------------
Final objective value = 3.68979871227832e-01
Final feasibility error (abs / rel) = 2.22e-16 / 4.00e-18
Final optimality error (abs / rel) = 2.18e-08 / 2.11e-08
# of iterations = 7
# of CG iterations = 0
# of function evaluations = 0
# of gradient evaluations = 0
# of Hessian evaluations = 0
Total program time (secs) = 0.01006 ( 0.004 CPU time)
Time spent in evaluations (secs) = 0.00000
================================================================================
Artelys Knitro 16.0.0:
=======================================
Commercial License
Artelys Knitro 16.0.0
=======================================
Knitro using 1 thread.
No start point provided -- Knitro computing one.
Knitro presolve eliminated 0 variables (0%) and 0 constraints (0%) in 0.00s.
concurrent_evals 0
datacheck 0
feastol 1e-06
feastol_abs 0.001
findiff_numthreads 1
hessian_no_f 1
hessopt 1
opttol 1e-06
opttol_abs 0.001
Knitro running advanced initialization strategy specified by initpt_strategy.
Problem Characteristics | Presolved
-----------------------
Problem type: convex QP
Objective: minimize / quadratic
Number of variables: 10 | 10
bounds: lower upper range | lower upper range
0 0 10 | 2 0 8
free fixed | free fixed
0 0 | 0 0
Number of constraints: 2 | 2
eq. ineq. range | eq. ineq. range
linear: 1 1 0 | 1 1 0
quadratic: 0 0 0 | 0 0 0
Number of nonzeros:
objective Jacobian Hessian | objective Jacobian Hessian
linear: 0 20 | 0 20
quadratic: 10 0 55 | 10 0 55
total: 10 20 55 | 10 20 55
Coefficient range:
linear objective: [0e+00, 0e+00] | [0e+00, 0e+00]
linear constraints: [3e-01, 7e+01] | [3e-01, 7e+01]
quadratic objective: [2e-02, 1e+01] | [2e-02, 1e+01]
quadratic constraints: [0e+00, 0e+00] | [0e+00, 0e+00]
variable bounds: [1e+00, 1e+00] | [1e+00, 1e+00]
constraint bounds: [1e+00, 8e+00] | [1e+00, 8e+00]
Knitro using the Interior-Point/Barrier Direct algorithm.
Iter Objective FeasError OptError ||Step|| Time
-------- -------------- --------- --------- --------- --------
0 1.092163e+00 2.30e-01
7 3.815114e-01 7.79e-11 5.99e-11 1.92e-04 0.01
EXIT: Optimal solution found.
HINT: Knitro spent 1.0% of solution time (0.000073 secs) checking model
convexity. To skip the automatic convexity checker for QPs and QCQPs,
explicity set the user option convex=0 or convex=1.
Final Statistics
----------------
Final objective value = 3.81511437462774e-01
Final feasibility error (abs / rel) = 7.79e-11 / 1.39e-12
Final optimality error (abs / rel) = 5.99e-11 / 5.54e-11
# of iterations = 7
# of CG iterations = 0
# of function evaluations = 0
# of gradient evaluations = 0
# of Hessian evaluations = 0
Total program time (secs) = 0.00716 ( 0.004 CPU time)
Time spent in evaluations (secs) = 0.00000
================================================================================
Artelys Knitro 16.0.0:
=======================================
Commercial License
Artelys Knitro 16.0.0
=======================================
Knitro using 1 thread.
No start point provided -- Knitro computing one.
Knitro presolve eliminated 0 variables (0%) and 0 constraints (0%) in 0.00s.
concurrent_evals 0
datacheck 0
feastol 1e-06
feastol_abs 0.001
findiff_numthreads 1
hessian_no_f 1
hessopt 1
opttol 1e-06
opttol_abs 0.001
Knitro running advanced initialization strategy specified by initpt_strategy.
Problem Characteristics | Presolved
-----------------------
Problem type: convex QP
Objective: minimize / quadratic
Number of variables: 10 | 10
bounds: lower upper range | lower upper range
0 0 10 | 2 0 8
free fixed | free fixed
0 0 | 0 0
Number of constraints: 2 | 2
eq. ineq. range | eq. ineq. range
linear: 1 1 0 | 1 1 0
quadratic: 0 0 0 | 0 0 0
Number of nonzeros:
objective Jacobian Hessian | objective Jacobian Hessian
linear: 0 20 | 0 20
quadratic: 10 0 55 | 10 0 55
total: 10 20 55 | 10 20 55
Coefficient range:
linear objective: [0e+00, 0e+00] | [0e+00, 0e+00]
linear constraints: [3e-01, 7e+01] | [3e-01, 7e+01]
quadratic objective: [2e-02, 1e+01] | [2e-02, 1e+01]
quadratic constraints: [0e+00, 0e+00] | [0e+00, 0e+00]
variable bounds: [1e+00, 1e+00] | [1e+00, 1e+00]
constraint bounds: [1e+00, 9e+00] | [1e+00, 9e+00]
Knitro using the Interior-Point/Barrier Direct algorithm.
Iter Objective FeasError OptError ||Step|| Time
-------- -------------- --------- --------- --------- --------
0 1.090213e+00 2.39e-01
7 3.953859e-01 8.66e-11 7.93e-11 1.86e-04 0.01
EXIT: Optimal solution found.
Final Statistics
----------------
Final objective value = 3.95385911757145e-01
Final feasibility error (abs / rel) = 8.66e-11 / 1.53e-12
Final optimality error (abs / rel) = 7.93e-11 / 7.05e-11
# of iterations = 7
# of CG iterations = 0
# of function evaluations = 0
# of gradient evaluations = 0
# of Hessian evaluations = 0
Total program time (secs) = 0.00962 ( 0.004 CPU time)
Time spent in evaluations (secs) = 0.00000
================================================================================
Artelys Knitro 16.0.0:
=======================================
Commercial License
Artelys Knitro 16.0.0
=======================================
Knitro using 1 thread.
No start point provided -- Knitro computing one.
Knitro presolve eliminated 0 variables (0%) and 0 constraints (0%) in 0.00s.
concurrent_evals 0
datacheck 0
feastol 1e-06
feastol_abs 0.001
findiff_numthreads 1
hessian_no_f 1
hessopt 1
opttol 1e-06
opttol_abs 0.001
Knitro running advanced initialization strategy specified by initpt_strategy.
Problem Characteristics | Presolved
-----------------------
Problem type: convex QP
Objective: minimize / quadratic
Number of variables: 10 | 10
bounds: lower upper range | lower upper range
0 0 10 | 2 0 8
free fixed | free fixed
0 0 | 0 0
Number of constraints: 2 | 2
eq. ineq. range | eq. ineq. range
linear: 1 1 0 | 1 1 0
quadratic: 0 0 0 | 0 0 0
Number of nonzeros:
objective Jacobian Hessian | objective Jacobian Hessian
linear: 0 20 | 0 20
quadratic: 10 0 55 | 10 0 55
total: 10 20 55 | 10 20 55
Coefficient range:
linear objective: [0e+00, 0e+00] | [0e+00, 0e+00]
linear constraints: [3e-01, 7e+01] | [3e-01, 7e+01]
quadratic objective: [2e-02, 1e+01] | [2e-02, 1e+01]
quadratic constraints: [0e+00, 0e+00] | [0e+00, 0e+00]
variable bounds: [1e+00, 1e+00] | [1e+00, 1e+00]
constraint bounds: [1e+00, 1e+01] | [1e+00, 1e+01]
Knitro using the Interior-Point/Barrier Direct algorithm.
Iter Objective FeasError OptError ||Step|| Time
-------- -------------- --------- --------- --------- --------
0 1.088542e+00 4.59e-01
6 4.108481e-01 0.00e+00 5.35e-07 3.64e-03 0.01
EXIT: Optimal solution found.
HINT: Knitro spent 1.6% of solution time (0.000119 secs) checking model
convexity. To skip the automatic convexity checker for QPs and QCQPs,
explicity set the user option convex=0 or convex=1.
Final Statistics
----------------
Final objective value = 4.10848097034628e-01
Final feasibility error (abs / rel) = 0.00e+00 / 0.00e+00
Final optimality error (abs / rel) = 5.35e-07 / 4.50e-07
# of iterations = 6
# of CG iterations = 0
# of function evaluations = 0
# of gradient evaluations = 0
# of Hessian evaluations = 0
Total program time (secs) = 0.00766 ( 0.005 CPU time)
Time spent in evaluations (secs) = 0.00000
================================================================================
Artelys Knitro 16.0.0:
=======================================
Commercial License
Artelys Knitro 16.0.0
=======================================
Knitro using 1 thread.
No start point provided -- Knitro computing one.
Knitro presolve eliminated 0 variables (0%) and 0 constraints (0%) in 0.00s.
concurrent_evals 0
datacheck 0
feastol 1e-06
feastol_abs 0.001
findiff_numthreads 1
hessian_no_f 1
hessopt 1
opttol 1e-06
opttol_abs 0.001
Knitro running advanced initialization strategy specified by initpt_strategy.
Problem Characteristics | Presolved
-----------------------
Problem type: convex QP
Objective: minimize / quadratic
Number of variables: 10 | 10
bounds: lower upper range | lower upper range
0 0 10 | 2 0 8
free fixed | free fixed
0 0 | 0 0
Number of constraints: 2 | 2
eq. ineq. range | eq. ineq. range
linear: 1 1 0 | 1 1 0
quadratic: 0 0 0 | 0 0 0
Number of nonzeros:
objective Jacobian Hessian | objective Jacobian Hessian
linear: 0 20 | 0 20
quadratic: 10 0 55 | 10 0 55
total: 10 20 55 | 10 20 55
Coefficient range:
linear objective: [0e+00, 0e+00] | [0e+00, 0e+00]
linear constraints: [3e-01, 7e+01] | [3e-01, 7e+01]
quadratic objective: [2e-02, 1e+01] | [2e-02, 1e+01]
quadratic constraints: [0e+00, 0e+00] | [0e+00, 0e+00]
variable bounds: [1e+00, 1e+00] | [1e+00, 1e+00]
constraint bounds: [1e+00, 1e+01] | [1e+00, 1e+01]
Knitro using the Interior-Point/Barrier Direct algorithm.
Iter Objective FeasError OptError ||Step|| Time
-------- -------------- --------- --------- --------- --------
0 1.087150e+00 6.79e-01
6 4.289111e-01 1.11e-16 2.13e-08 4.61e-04 0.01
EXIT: Optimal solution found.
HINT: Knitro spent 1.3% of solution time (0.000087 secs) checking model
convexity. To skip the automatic convexity checker for QPs and QCQPs,
explicity set the user option convex=0 or convex=1.
Final Statistics
----------------
Final objective value = 4.28911054277269e-01
Final feasibility error (abs / rel) = 1.11e-16 / 1.93e-18
Final optimality error (abs / rel) = 2.13e-08 / 1.68e-08
# of iterations = 6
# of CG iterations = 0
# of function evaluations = 0
# of gradient evaluations = 0
# of Hessian evaluations = 0
Total program time (secs) = 0.00690 ( 0.004 CPU time)
Time spent in evaluations (secs) = 0.00000
================================================================================
Artelys Knitro 16.0.0:
=======================================
Commercial License
Artelys Knitro 16.0.0
=======================================
Knitro using 1 thread.
No start point provided -- Knitro computing one.
Knitro presolve eliminated 0 variables (0%) and 0 constraints (0%) in 0.00s.
concurrent_evals 0
datacheck 0
feastol 1e-06
feastol_abs 0.001
findiff_numthreads 1
hessian_no_f 1
hessopt 1
opttol 1e-06
opttol_abs 0.001
Knitro running advanced initialization strategy specified by initpt_strategy.
Problem Characteristics | Presolved
-----------------------
Problem type: convex QP
Objective: minimize / quadratic
Number of variables: 10 | 10
bounds: lower upper range | lower upper range
0 0 10 | 2 0 8
free fixed | free fixed
0 0 | 0 0
Number of constraints: 2 | 2
eq. ineq. range | eq. ineq. range
linear: 1 1 0 | 1 1 0
quadratic: 0 0 0 | 0 0 0
Number of nonzeros:
objective Jacobian Hessian | objective Jacobian Hessian
linear: 0 20 | 0 20
quadratic: 10 0 55 | 10 0 55
total: 10 20 55 | 10 20 55
Coefficient range:
linear objective: [0e+00, 0e+00] | [0e+00, 0e+00]
linear constraints: [3e-01, 7e+01] | [3e-01, 7e+01]
quadratic objective: [2e-02, 1e+01] | [2e-02, 1e+01]
quadratic constraints: [0e+00, 0e+00] | [0e+00, 0e+00]
variable bounds: [1e+00, 1e+00] | [1e+00, 1e+00]
constraint bounds: [1e+00, 1e+01] | [1e+00, 1e+01]
Knitro using the Interior-Point/Barrier Direct algorithm.
Iter Objective FeasError OptError ||Step|| Time
-------- -------------- --------- --------- --------- --------
0 1.086037e+00 8.99e-01
6 4.496874e-01 0.00e+00 1.17e-10 7.54e-05 0.01
EXIT: Optimal solution found.
HINT: Knitro spent 1.4% of solution time (0.000096 secs) checking model
convexity. To skip the automatic convexity checker for QPs and QCQPs,
explicity set the user option convex=0 or convex=1.
Final Statistics
----------------
Final objective value = 4.49687421120634e-01
Final feasibility error (abs / rel) = 0.00e+00 / 0.00e+00
Final optimality error (abs / rel) = 1.17e-10 / 8.75e-11
# of iterations = 6
# of CG iterations = 0
# of function evaluations = 0
# of gradient evaluations = 0
# of Hessian evaluations = 0
Total program time (secs) = 0.00700 ( 0.004 CPU time)
Time spent in evaluations (secs) = 0.00000
================================================================================
Artelys Knitro 16.0.0:
=======================================
Commercial License
Artelys Knitro 16.0.0
=======================================
Knitro using 1 thread.
No start point provided -- Knitro computing one.
Knitro presolve eliminated 0 variables (0%) and 0 constraints (0%) in 0.00s.
concurrent_evals 0
datacheck 0
feastol 1e-06
feastol_abs 0.001
findiff_numthreads 1
hessian_no_f 1
hessopt 1
opttol 1e-06
opttol_abs 0.001
Knitro running advanced initialization strategy specified by initpt_strategy.
Problem Characteristics | Presolved
-----------------------
Problem type: convex QP
Objective: minimize / quadratic
Number of variables: 10 | 10
bounds: lower upper range | lower upper range
0 0 10 | 2 0 8
free fixed | free fixed
0 0 | 0 0
Number of constraints: 2 | 2
eq. ineq. range | eq. ineq. range
linear: 1 1 0 | 1 1 0
quadratic: 0 0 0 | 0 0 0
Number of nonzeros:
objective Jacobian Hessian | objective Jacobian Hessian
linear: 0 20 | 0 20
quadratic: 10 0 55 | 10 0 55
total: 10 20 55 | 10 20 55
Coefficient range:
linear objective: [0e+00, 0e+00] | [0e+00, 0e+00]
linear constraints: [3e-01, 7e+01] | [3e-01, 7e+01]
quadratic objective: [2e-02, 1e+01] | [2e-02, 1e+01]
quadratic constraints: [0e+00, 0e+00] | [0e+00, 0e+00]
variable bounds: [1e+00, 1e+00] | [1e+00, 1e+00]
constraint bounds: [1e+00, 1e+01] | [1e+00, 1e+01]
Knitro using the Interior-Point/Barrier Direct algorithm.
Iter Objective FeasError OptError ||Step|| Time
-------- -------------- --------- --------- --------- --------
0 1.085204e+00 1.12e+00
6 4.731767e-01 2.22e-16 1.69e-11 1.63e-05 0.02
EXIT: Optimal solution found.
Final Statistics
----------------
Final objective value = 4.73176703650771e-01
Final feasibility error (abs / rel) = 2.22e-16 / 3.79e-18
Final optimality error (abs / rel) = 1.69e-11 / 1.19e-11
# of iterations = 6
# of CG iterations = 0
# of function evaluations = 0
# of gradient evaluations = 0
# of Hessian evaluations = 0
Total program time (secs) = 0.01618 ( 0.005 CPU time)
Time spent in evaluations (secs) = 0.00000
================================================================================
Artelys Knitro 16.0.0:
=======================================
Commercial License
Artelys Knitro 16.0.0
=======================================
Knitro using 1 thread.
No start point provided -- Knitro computing one.
Knitro presolve eliminated 0 variables (0%) and 0 constraints (0%) in 0.00s.
concurrent_evals 0
datacheck 0
feastol 1e-06
feastol_abs 0.001
findiff_numthreads 1
hessian_no_f 1
hessopt 1
opttol 1e-06
opttol_abs 0.001
Knitro running advanced initialization strategy specified by initpt_strategy.
Problem Characteristics | Presolved
-----------------------
Problem type: convex QP
Objective: minimize / quadratic
Number of variables: 10 | 10
bounds: lower upper range | lower upper range
0 0 10 | 2 0 8
free fixed | free fixed
0 0 | 0 0
Number of constraints: 2 | 2
eq. ineq. range | eq. ineq. range
linear: 1 1 0 | 1 1 0
quadratic: 0 0 0 | 0 0 0
Number of nonzeros:
objective Jacobian Hessian | objective Jacobian Hessian
linear: 0 20 | 0 20
quadratic: 10 0 55 | 10 0 55
total: 10 20 55 | 10 20 55
Coefficient range:
linear objective: [0e+00, 0e+00] | [0e+00, 0e+00]
linear constraints: [3e-01, 7e+01] | [3e-01, 7e+01]
quadratic objective: [2e-02, 1e+01] | [2e-02, 1e+01]
quadratic constraints: [0e+00, 0e+00] | [0e+00, 0e+00]
variable bounds: [1e+00, 1e+00] | [1e+00, 1e+00]
constraint bounds: [1e+00, 1e+01] | [1e+00, 1e+01]
Knitro using the Interior-Point/Barrier Direct algorithm.
Iter Objective FeasError OptError ||Step|| Time
-------- -------------- --------- --------- --------- --------
0 1.084650e+00 1.34e+00
5 4.993811e-01 0.00e+00 1.07e-06 7.43e-03 0.03
EXIT: Optimal solution found.
Final Statistics
----------------
Final objective value = 4.99381056261065e-01
Final feasibility error (abs / rel) = 0.00e+00 / 0.00e+00
Final optimality error (abs / rel) = 1.07e-06 / 7.14e-07
# of iterations = 5
# of CG iterations = 0
# of function evaluations = 0
# of gradient evaluations = 0
# of Hessian evaluations = 0
Total program time (secs) = 0.02629 ( 0.005 CPU time)
Time spent in evaluations (secs) = 0.00000
================================================================================
Artelys Knitro 16.0.0:
=======================================
Commercial License
Artelys Knitro 16.0.0
=======================================
Knitro using 1 thread.
No start point provided -- Knitro computing one.
Knitro presolve eliminated 0 variables (0%) and 0 constraints (0%) in 0.00s.
concurrent_evals 0
datacheck 0
feastol 1e-06
feastol_abs 0.001
findiff_numthreads 1
hessian_no_f 1
hessopt 1
opttol 1e-06
opttol_abs 0.001
Knitro running advanced initialization strategy specified by initpt_strategy.
Problem Characteristics | Presolved
-----------------------
Problem type: convex QP
Objective: minimize / quadratic
Number of variables: 10 | 10
bounds: lower upper range | lower upper range
0 0 10 | 2 0 8
free fixed | free fixed
0 0 | 0 0
Number of constraints: 2 | 2
eq. ineq. range | eq. ineq. range
linear: 1 1 0 | 1 1 0
quadratic: 0 0 0 | 0 0 0
Number of nonzeros:
objective Jacobian Hessian | objective Jacobian Hessian
linear: 0 20 | 0 20
quadratic: 10 0 55 | 10 0 55
total: 10 20 55 | 10 20 55
Coefficient range:
linear objective: [0e+00, 0e+00] | [0e+00, 0e+00]
linear constraints: [3e-01, 7e+01] | [3e-01, 7e+01]
quadratic objective: [2e-02, 1e+01] | [2e-02, 1e+01]
quadratic constraints: [0e+00, 0e+00] | [0e+00, 0e+00]
variable bounds: [1e+00, 1e+00] | [1e+00, 1e+00]
constraint bounds: [1e+00, 1e+01] | [1e+00, 1e+01]
Knitro using the Interior-Point/Barrier Direct algorithm.
Iter Objective FeasError OptError ||Step|| Time
-------- -------------- --------- --------- --------- --------
0 1.084375e+00 1.56e+00
5 5.282955e-01 1.11e-16 8.20e-07 6.15e-03 0.01
EXIT: Optimal solution found.
HINT: Knitro spent 1.0% of solution time (0.000116 secs) checking model
convexity. To skip the automatic convexity checker for QPs and QCQPs,
explicity set the user option convex=0 or convex=1.
Final Statistics
----------------
Final objective value = 5.28295468844518e-01
Final feasibility error (abs / rel) = 1.11e-16 / 1.86e-18
Final optimality error (abs / rel) = 8.20e-07 / 5.22e-07
# of iterations = 5
# of CG iterations = 0
# of function evaluations = 0
# of gradient evaluations = 0
# of Hessian evaluations = 0
Total program time (secs) = 0.01147 ( 0.004 CPU time)
Time spent in evaluations (secs) = 0.00000
================================================================================
Artelys Knitro 16.0.0:
=======================================
Commercial License
Artelys Knitro 16.0.0
=======================================
Knitro using 1 thread.
No start point provided -- Knitro computing one.
Knitro presolve eliminated 0 variables (0%) and 0 constraints (0%) in 0.00s.
concurrent_evals 0
datacheck 0
feastol 1e-06
feastol_abs 0.001
findiff_numthreads 1
hessian_no_f 1
hessopt 1
opttol 1e-06
opttol_abs 0.001
Knitro running advanced initialization strategy specified by initpt_strategy.
Problem Characteristics | Presolved
-----------------------
Problem type: convex QP
Objective: minimize / quadratic
Number of variables: 10 | 10
bounds: lower upper range | lower upper range
0 0 10 | 2 0 8
free fixed | free fixed
0 0 | 0 0
Number of constraints: 2 | 2
eq. ineq. range | eq. ineq. range
linear: 1 1 0 | 1 1 0
quadratic: 0 0 0 | 0 0 0
Number of nonzeros:
objective Jacobian Hessian | objective Jacobian Hessian
linear: 0 20 | 0 20
quadratic: 10 0 55 | 10 0 55
total: 10 20 55 | 10 20 55
Coefficient range:
linear objective: [0e+00, 0e+00] | [0e+00, 0e+00]
linear constraints: [3e-01, 7e+01] | [3e-01, 7e+01]
quadratic objective: [2e-02, 1e+01] | [2e-02, 1e+01]
quadratic constraints: [0e+00, 0e+00] | [0e+00, 0e+00]
variable bounds: [1e+00, 1e+00] | [1e+00, 1e+00]
constraint bounds: [1e+00, 1e+01] | [1e+00, 1e+01]
Knitro using the Interior-Point/Barrier Direct algorithm.
Iter Objective FeasError OptError ||Step|| Time
-------- -------------- --------- --------- --------- --------
0 1.084380e+00 1.78e+00
6 5.599220e-01 0.00e+00 2.17e-11 1.10e-05 0.02
EXIT: Optimal solution found.
Final Statistics
----------------
Final objective value = 5.59922033425558e-01
Final feasibility error (abs / rel) = 0.00e+00 / 0.00e+00
Final optimality error (abs / rel) = 2.17e-11 / 1.32e-11
# of iterations = 6
# of CG iterations = 0
# of function evaluations = 0
# of gradient evaluations = 0
# of Hessian evaluations = 0
Total program time (secs) = 0.01648 ( 0.005 CPU time)
Time spent in evaluations (secs) = 0.00000
================================================================================
Artelys Knitro 16.0.0:
=======================================
Commercial License
Artelys Knitro 16.0.0
=======================================
Knitro using 1 thread.
No start point provided -- Knitro computing one.
Knitro presolve eliminated 0 variables (0%) and 0 constraints (0%) in 0.00s.
concurrent_evals 0
datacheck 0
feastol 1e-06
feastol_abs 0.001
findiff_numthreads 1
hessian_no_f 1
hessopt 1
opttol 1e-06
opttol_abs 0.001
Knitro running advanced initialization strategy specified by initpt_strategy.
Problem Characteristics | Presolved
-----------------------
Problem type: convex QP
Objective: minimize / quadratic
Number of variables: 10 | 10
bounds: lower upper range | lower upper range
0 0 10 | 2 0 8
free fixed | free fixed
0 0 | 0 0
Number of constraints: 2 | 2
eq. ineq. range | eq. ineq. range
linear: 1 1 0 | 1 1 0
quadratic: 0 0 0 | 0 0 0
Number of nonzeros:
objective Jacobian Hessian | objective Jacobian Hessian
linear: 0 20 | 0 20
quadratic: 10 0 55 | 10 0 55
total: 10 20 55 | 10 20 55
Coefficient range:
linear objective: [0e+00, 0e+00] | [0e+00, 0e+00]
linear constraints: [3e-01, 7e+01] | [3e-01, 7e+01]
quadratic objective: [2e-02, 1e+01] | [2e-02, 1e+01]
quadratic constraints: [0e+00, 0e+00] | [0e+00, 0e+00]
variable bounds: [1e+00, 1e+00] | [1e+00, 1e+00]
constraint bounds: [1e+00, 1e+01] | [1e+00, 1e+01]
Knitro using the Interior-Point/Barrier Direct algorithm.
Iter Objective FeasError OptError ||Step|| Time
-------- -------------- --------- --------- --------- --------
0 1.084664e+00 2.00e+00
6 5.942630e-01 0.00e+00 2.48e-09 1.93e-04 0.01
EXIT: Optimal solution found.
HINT: Knitro spent 1.2% of solution time (0.000083 secs) checking model
convexity. To skip the automatic convexity checker for QPs and QCQPs,
explicity set the user option convex=0 or convex=1.
Final Statistics
----------------
Final objective value = 5.94262971067329e-01
Final feasibility error (abs / rel) = 0.00e+00 / 0.00e+00
Final optimality error (abs / rel) = 2.48e-09 / 1.44e-09
# of iterations = 6
# of CG iterations = 0
# of function evaluations = 0
# of gradient evaluations = 0
# of Hessian evaluations = 0
Total program time (secs) = 0.00702 ( 0.004 CPU time)
Time spent in evaluations (secs) = 0.00000
================================================================================
Artelys Knitro 16.0.0:
=======================================
Commercial License
Artelys Knitro 16.0.0
=======================================
Knitro using 1 thread.
No start point provided -- Knitro computing one.
Knitro presolve eliminated 0 variables (0%) and 0 constraints (0%) in 0.00s.
concurrent_evals 0
datacheck 0
feastol 1e-06
feastol_abs 0.001
findiff_numthreads 1
hessian_no_f 1
hessopt 1
opttol 1e-06
opttol_abs 0.001
Knitro running advanced initialization strategy specified by initpt_strategy.
Problem Characteristics | Presolved
-----------------------
Problem type: convex QP
Objective: minimize / quadratic
Number of variables: 10 | 10
bounds: lower upper range | lower upper range
0 0 10 | 2 0 8
free fixed | free fixed
0 0 | 0 0
Number of constraints: 2 | 2
eq. ineq. range | eq. ineq. range
linear: 1 1 0 | 1 1 0
quadratic: 0 0 0 | 0 0 0
Number of nonzeros:
objective Jacobian Hessian | objective Jacobian Hessian
linear: 0 20 | 0 20
quadratic: 10 0 55 | 10 0 55
total: 10 20 55 | 10 20 55
Coefficient range:
linear objective: [0e+00, 0e+00] | [0e+00, 0e+00]
linear constraints: [3e-01, 7e+01] | [3e-01, 7e+01]
quadratic objective: [2e-02, 1e+01] | [2e-02, 1e+01]
quadratic constraints: [0e+00, 0e+00] | [0e+00, 0e+00]
variable bounds: [1e+00, 1e+00] | [1e+00, 1e+00]
constraint bounds: [1e+00, 1e+01] | [1e+00, 1e+01]
Knitro using the Interior-Point/Barrier Direct algorithm.
Iter Objective FeasError OptError ||Step|| Time
-------- -------------- --------- --------- --------- --------
0 1.088670e+00 2.47e+00
7 6.313168e-01 8.36e-11 1.27e-11 5.78e-05 0.01
EXIT: Optimal solution found.
HINT: Knitro spent 1.3% of solution time (0.000098 secs) checking model
convexity. To skip the automatic convexity checker for QPs and QCQPs,
explicity set the user option convex=0 or convex=1.
Final Statistics
----------------
Final objective value = 6.31316820917614e-01
Final feasibility error (abs / rel) = 8.36e-11 / 1.37e-12
Final optimality error (abs / rel) = 1.27e-11 / 7.05e-12
# of iterations = 7
# of CG iterations = 0
# of function evaluations = 0
# of gradient evaluations = 0
# of Hessian evaluations = 0
Total program time (secs) = 0.00751 ( 0.004 CPU time)
Time spent in evaluations (secs) = 0.00000
================================================================================
Artelys Knitro 16.0.0:
=======================================
Commercial License
Artelys Knitro 16.0.0
=======================================
Knitro using 1 thread.
No start point provided -- Knitro computing one.
Knitro presolve eliminated 0 variables (0%) and 0 constraints (0%) in 0.00s.
concurrent_evals 0
datacheck 0
feastol 1e-06
feastol_abs 0.001
findiff_numthreads 1
hessian_no_f 1
hessopt 1
opttol 1e-06
opttol_abs 0.001
Knitro running advanced initialization strategy specified by initpt_strategy.
Problem Characteristics | Presolved
-----------------------
Problem type: convex QP
Objective: minimize / quadratic
Number of variables: 10 | 10
bounds: lower upper range | lower upper range
0 0 10 | 2 0 8
free fixed | free fixed
0 0 | 0 0
Number of constraints: 2 | 2
eq. ineq. range | eq. ineq. range
linear: 1 1 0 | 1 1 0
quadratic: 0 0 0 | 0 0 0
Number of nonzeros:
objective Jacobian Hessian | objective Jacobian Hessian
linear: 0 20 | 0 20
quadratic: 10 0 55 | 10 0 55
total: 10 20 55 | 10 20 55
Coefficient range:
linear objective: [0e+00, 0e+00] | [0e+00, 0e+00]
linear constraints: [3e-01, 7e+01] | [3e-01, 7e+01]
quadratic objective: [2e-02, 1e+01] | [2e-02, 1e+01]
quadratic constraints: [0e+00, 0e+00] | [0e+00, 0e+00]
variable bounds: [1e+00, 1e+00] | [1e+00, 1e+00]
constraint bounds: [1e+00, 1e+01] | [1e+00, 1e+01]
Knitro using the Interior-Point/Barrier Direct algorithm.
Iter Objective FeasError OptError ||Step|| Time
-------- -------------- --------- --------- --------- --------
0 1.092828e+00 2.95e+00
6 6.713871e-01 0.00e+00 9.09e-08 1.23e-03 0.02
EXIT: Optimal solution found.
Final Statistics
----------------
Final objective value = 6.71387134348436e-01
Final feasibility error (abs / rel) = 0.00e+00 / 0.00e+00
Final optimality error (abs / rel) = 9.09e-08 / 4.80e-08
# of iterations = 6
# of CG iterations = 0
# of function evaluations = 0
# of gradient evaluations = 0
# of Hessian evaluations = 0
Total program time (secs) = 0.01950 ( 0.004 CPU time)
Time spent in evaluations (secs) = 0.00000
================================================================================
Artelys Knitro 16.0.0:
=======================================
Commercial License
Artelys Knitro 16.0.0
=======================================
Knitro using 1 thread.
No start point provided -- Knitro computing one.
Knitro presolve eliminated 0 variables (0%) and 0 constraints (0%) in 0.00s.
concurrent_evals 0
datacheck 0
feastol 1e-06
feastol_abs 0.001
findiff_numthreads 1
hessian_no_f 1
hessopt 1
opttol 1e-06
opttol_abs 0.001
Knitro running advanced initialization strategy specified by initpt_strategy.
Problem Characteristics | Presolved
-----------------------
Problem type: convex QP
Objective: minimize / quadratic
Number of variables: 10 | 10
bounds: lower upper range | lower upper range
0 0 10 | 2 0 8
free fixed | free fixed
0 0 | 0 0
Number of constraints: 2 | 2
eq. ineq. range | eq. ineq. range
linear: 1 1 0 | 1 1 0
quadratic: 0 0 0 | 0 0 0
Number of nonzeros:
objective Jacobian Hessian | objective Jacobian Hessian
linear: 0 20 | 0 20
quadratic: 10 0 55 | 10 0 55
total: 10 20 55 | 10 20 55
Coefficient range:
linear objective: [0e+00, 0e+00] | [0e+00, 0e+00]
linear constraints: [3e-01, 7e+01] | [3e-01, 7e+01]
quadratic objective: [2e-02, 1e+01] | [2e-02, 1e+01]
quadratic constraints: [0e+00, 0e+00] | [0e+00, 0e+00]
variable bounds: [1e+00, 1e+00] | [1e+00, 1e+00]
constraint bounds: [1e+00, 1e+01] | [1e+00, 1e+01]
Knitro using the Interior-Point/Barrier Direct algorithm.
Iter Objective FeasError OptError ||Step|| Time
-------- -------------- --------- --------- --------- --------
0 1.096995e+00 3.44e+00
6 7.163964e-01 0.00e+00 3.61e-10 5.63e-05 0.01
EXIT: Optimal solution found.
HINT: Knitro spent 1.7% of solution time (0.000132 secs) checking model
convexity. To skip the automatic convexity checker for QPs and QCQPs,
explicity set the user option convex=0 or convex=1.
Final Statistics
----------------
Final objective value = 7.16396428775274e-01
Final feasibility error (abs / rel) = 0.00e+00 / 0.00e+00
Final optimality error (abs / rel) = 3.61e-10 / 1.80e-10
# of iterations = 6
# of CG iterations = 0
# of function evaluations = 0
# of gradient evaluations = 0
# of Hessian evaluations = 0
Total program time (secs) = 0.00797 ( 0.004 CPU time)
Time spent in evaluations (secs) = 0.00000
================================================================================
Artelys Knitro 16.0.0:
=======================================
Commercial License
Artelys Knitro 16.0.0
=======================================
Knitro using 1 thread.
No start point provided -- Knitro computing one.
Knitro presolve eliminated 0 variables (0%) and 0 constraints (0%) in 0.00s.
concurrent_evals 0
datacheck 0
feastol 1e-06
feastol_abs 0.001
findiff_numthreads 1
hessian_no_f 1
hessopt 1
opttol 1e-06
opttol_abs 0.001
Knitro running advanced initialization strategy specified by initpt_strategy.
Problem Characteristics | Presolved
-----------------------
Problem type: convex QP
Objective: minimize / quadratic
Number of variables: 10 | 10
bounds: lower upper range | lower upper range
0 0 10 | 2 0 8
free fixed | free fixed
0 0 | 0 0
Number of constraints: 2 | 2
eq. ineq. range | eq. ineq. range
linear: 1 1 0 | 1 1 0
quadratic: 0 0 0 | 0 0 0
Number of nonzeros:
objective Jacobian Hessian | objective Jacobian Hessian
linear: 0 20 | 0 20
quadratic: 10 0 55 | 10 0 55
total: 10 20 55 | 10 20 55
Coefficient range:
linear objective: [0e+00, 0e+00] | [0e+00, 0e+00]
linear constraints: [3e-01, 7e+01] | [3e-01, 7e+01]
quadratic objective: [2e-02, 1e+01] | [2e-02, 1e+01]
quadratic constraints: [0e+00, 0e+00] | [0e+00, 0e+00]
variable bounds: [1e+00, 1e+00] | [1e+00, 1e+00]
constraint bounds: [1e+00, 2e+01] | [1e+00, 2e+01]
Knitro using the Interior-Point/Barrier Direct algorithm.
Iter Objective FeasError OptError ||Step|| Time
-------- -------------- --------- --------- --------- --------
0 1.101172e+00 3.92e+00
6 7.666828e-01 0.00e+00 4.52e-11 2.11e-05 0.01
EXIT: Optimal solution found.
HINT: Knitro spent 1.3% of solution time (0.000109 secs) checking model
convexity. To skip the automatic convexity checker for QPs and QCQPs,
explicity set the user option convex=0 or convex=1.
Final Statistics
----------------
Final objective value = 7.66682814832761e-01
Final feasibility error (abs / rel) = 0.00e+00 / 0.00e+00
Final optimality error (abs / rel) = 4.52e-11 / 2.14e-11
# of iterations = 6
# of CG iterations = 0
# of function evaluations = 0
# of gradient evaluations = 0
# of Hessian evaluations = 0
Total program time (secs) = 0.00859 ( 0.005 CPU time)
Time spent in evaluations (secs) = 0.00000
================================================================================
draw_frontier(grid, frontier, "Efficient frontier", highlight=grid.index(10))Here we can observe the different assets and their weights based on the desired return. For low returns, it is advantageous to diversify the assets in which to allocate parts of the portfolio, to minimize the risk. On the other hand, as we aim for higher returns, and consequently accept higher risks, we end up investing in the asset that yields the most.
Adding diversification bounds
In portfolio optimization, diversification is a critical principle used to reduce risk by allocating investments among various financial assets, industries, and other categories. Diversification has multiple benefits:
- Risk Reduction: Diversification helps in spreading risk across different assets, reducing the impact of any single asset’s poor performance on the overall portfolio.
- Control Over Portfolio Composition: By setting bounds on asset weights and limiting the number of assets, investors can ensure that the portfolio remains manageable and aligned with investment objectives.
- Improved Returns: A well-diversified portfolio can improve the risk-adjusted returns by taking advantage of the benefits of diversification without excessive exposure to any single asset.
For each asset in the portfolio, we define a lower bound \(L_i\) and an upper bound \(U_i\) on the weight \(w_i\):
\[ \forall i = 1, \dots, N \qquad L_i \leq w_i \leq U_i \]
This constraint ensures that the weight of each asset remains within a specified range, promoting diversification by preventing over-concentration in any single asset. Nothing else changes, so the model is still a convex QP.
with_bounds calls markowitz and adds the two bounds per asset to what comes back.
def with_bounds(market, *, desired_return, lower, upper):
model, w = markowitz(market, desired_return=desired_return)
model.floor = pyo.Constraint(model.assets, rule=lambda model, i: w[i] >= lower[i])
model.ceiling = pyo.Constraint(model.assets, rule=lambda model, i: w[i] <= upper[i])
return model, wWe need to specify additional inputs for this extension. Each asset gets a floor of its own, and all of them share a ceiling of half the capital.
lower = [0.05, 0.05, 0.06, 0.07, 0.06, 0.05, 0.06, 0.07, 0.05, 0.06]
upper = [0.5] * nasdaq.num_assetsbounded = [
solve(nasdaq, with_bounds, desired_return=r, lower=lower, upper=upper)
for r in returns
]Show the full outputHide the full output
Artelys Knitro 16.0.0:
=======================================
Commercial License
Artelys Knitro 16.0.0
=======================================
Knitro using 1 thread.
No start point provided -- Knitro computing one.
Knitro presolve eliminated 0 variables (0%) and 20 constraints (91%) in 0.00s.
concurrent_evals 0
datacheck 0
feastol 1e-06
feastol_abs 0.001
findiff_numthreads 1
hessian_no_f 1
hessopt 1
opttol 1e-06
opttol_abs 0.001
Knitro running advanced initialization strategy specified by initpt_strategy.
Problem Characteristics | Presolved
-----------------------
Problem type: convex QP
Objective: minimize / quadratic
Number of variables: 10 | 10
bounds: lower upper range | lower upper range
0 0 10 | 10 0 0
free fixed | free fixed
0 0 | 0 0
Number of constraints: 22 | 2
eq. ineq. range | eq. ineq. range
linear: 1 21 0 | 1 1 0
quadratic: 0 0 0 | 0 0 0
Number of nonzeros:
objective Jacobian Hessian | objective Jacobian Hessian
linear: 0 40 | 0 20
quadratic: 10 0 55 | 10 0 55
total: 10 40 55 | 10 20 55
Coefficient range:
linear objective: [0e+00, 0e+00] | [0e+00, 0e+00]
linear constraints: [3e-01, 7e+01] | [3e-01, 7e+01]
quadratic objective: [2e-02, 1e+01] | [2e-02, 1e+01]
quadratic constraints: [0e+00, 0e+00] | [0e+00, 0e+00]
variable bounds: [1e+00, 1e+00] | [5e-02, 7e-02]
constraint bounds: [5e-02, 5e+00] | [1e+00, 5e+00]
Knitro using the Interior-Point/Barrier Direct algorithm.
Iter Objective FeasError OptError ||Step|| Time
-------- -------------- --------- --------- --------- --------
0 7.716469e-01 5.43e+00
10 1.005011e+00 1.65e-02 7.85e-03 2.83e-04 0.01
11 1.005012e+00 1.65e-02 7.85e-03 5.78e-07 0.01
EXIT: Convergence to an infeasible point. The problem is determined
to be infeasible.
HINT: Knitro spent 1.2% of solution time (0.000083 secs) checking model
convexity. To skip the automatic convexity checker for QPs and QCQPs,
explicity set the user option convex=0 or convex=1.
Final Statistics
----------------
Final objective value = 1.00501169801487e+00
Final feasibility error (abs / rel) = 1.65e-02 / 3.13e-04
Final optimality error (abs / rel) = 7.85e-03 / 2.78e-03
# of iterations = 11
# of CG iterations = 4
# of function evaluations = 0
# of gradient evaluations = 0
# of Hessian evaluations = 0
Total program time (secs) = 0.00716 ( 0.004 CPU time)
Time spent in evaluations (secs) = 0.00000
================================================================================
WARNING: Loading a SolverResults object with a warning status into
model.name="unknown";
- termination condition: infeasible
- message from solver: Knitro 16.0.0\x3a Convergence to an infeasible
point. Problem may be locally infeasible.; objective 1.0050116980148738;
feasibility error 0.0165; 11 iterations; 0 function evaluations
Artelys Knitro 16.0.0:
=======================================
Commercial License
Artelys Knitro 16.0.0
=======================================
Knitro using 1 thread.
No start point provided -- Knitro computing one.
Knitro presolve eliminated 0 variables (0%) and 20 constraints (91%) in 0.00s.
concurrent_evals 0
datacheck 0
feastol 1e-06
feastol_abs 0.001
findiff_numthreads 1
hessian_no_f 1
hessopt 1
opttol 1e-06
opttol_abs 0.001
Knitro running advanced initialization strategy specified by initpt_strategy.
Problem Characteristics | Presolved
-----------------------
Problem type: convex QP
Objective: minimize / quadratic
Number of variables: 10 | 10
bounds: lower upper range | lower upper range
0 0 10 | 10 0 0
free fixed | free fixed
0 0 | 0 0
Number of constraints: 22 | 2
eq. ineq. range | eq. ineq. range
linear: 1 21 0 | 1 1 0
quadratic: 0 0 0 | 0 0 0
Number of nonzeros:
objective Jacobian Hessian | objective Jacobian Hessian
linear: 0 40 | 0 20
quadratic: 10 0 55 | 10 0 55
total: 10 40 55 | 10 20 55
Coefficient range:
linear objective: [0e+00, 0e+00] | [0e+00, 0e+00]
linear constraints: [3e-01, 7e+01] | [3e-01, 7e+01]
quadratic objective: [2e-02, 1e+01] | [2e-02, 1e+01]
quadratic constraints: [0e+00, 0e+00] | [0e+00, 0e+00]
variable bounds: [1e+00, 1e+00] | [5e-02, 7e-02]
constraint bounds: [5e-02, 8e+00] | [1e+00, 8e+00]
Knitro using the Interior-Point/Barrier Direct algorithm.
Iter Objective FeasError OptError ||Step|| Time
-------- -------------- --------- --------- --------- --------
0 7.867780e-01 7.86e+00
10 1.068222e+00 5.82e-02 2.02e-02 2.34e-05 0.01
20 1.068314e+00 5.83e-02 2.02e-02 2.28e-03 0.01
29 1.068286e+00 5.82e-02 2.02e-02 1.50e-07 0.01
EXIT: Convergence to an infeasible point. The problem is determined
to be infeasible.
Final Statistics
----------------
Final objective value = 1.06828603559199e+00
Final feasibility error (abs / rel) = 5.82e-02 / 1.06e-03
Final optimality error (abs / rel) = 2.02e-02 / 6.78e-03
# of iterations = 29
# of CG iterations = 13
# of function evaluations = 0
# of gradient evaluations = 0
# of Hessian evaluations = 0
Total program time (secs) = 0.00959 ( 0.006 CPU time)
Time spent in evaluations (secs) = 0.00000
================================================================================
WARNING: Loading a SolverResults object with a warning status into
model.name="unknown";
- termination condition: infeasible
- message from solver: Knitro 16.0.0\x3a Convergence to an infeasible
point. Problem may be locally infeasible.; objective 1.068286035591987;
feasibility error 0.0582; 29 iterations; 0 function evaluations
Artelys Knitro 16.0.0:
=======================================
Commercial License
Artelys Knitro 16.0.0
=======================================
Knitro using 1 thread.
No start point provided -- Knitro computing one.
Knitro presolve eliminated 0 variables (0%) and 20 constraints (91%) in 0.00s.
concurrent_evals 0
datacheck 0
feastol 1e-06
feastol_abs 0.001
findiff_numthreads 1
hessian_no_f 1
hessopt 1
opttol 1e-06
opttol_abs 0.001
Knitro running advanced initialization strategy specified by initpt_strategy.
Problem Characteristics | Presolved
-----------------------
Problem type: convex QP
Objective: minimize / quadratic
Number of variables: 10 | 10
bounds: lower upper range | lower upper range
0 0 10 | 10 0 0
free fixed | free fixed
0 0 | 0 0
Number of constraints: 22 | 2
eq. ineq. range | eq. ineq. range
linear: 1 21 0 | 1 1 0
quadratic: 0 0 0 | 0 0 0
Number of nonzeros:
objective Jacobian Hessian | objective Jacobian Hessian
linear: 0 40 | 0 20
quadratic: 10 0 55 | 10 0 55
total: 10 40 55 | 10 20 55
Coefficient range:
linear objective: [0e+00, 0e+00] | [0e+00, 0e+00]
linear constraints: [3e-01, 7e+01] | [3e-01, 7e+01]
quadratic objective: [2e-02, 1e+01] | [2e-02, 1e+01]
quadratic constraints: [0e+00, 0e+00] | [0e+00, 0e+00]
variable bounds: [1e+00, 1e+00] | [5e-02, 7e-02]
constraint bounds: [5e-02, 1e+01] | [1e+00, 1e+01]
Knitro using the Interior-Point/Barrier Direct algorithm.
Iter Objective FeasError OptError ||Step|| Time
-------- -------------- --------- --------- --------- --------
0 8.867058e-01 9.23e+00
10 1.143000e+00 1.00e-01 3.26e-02 4.86e-03 0.01
18 1.143023e+00 1.00e-01 3.26e-02 1.19e-07 0.01
EXIT: Convergence to an infeasible point. The problem is determined
to be infeasible.
Final Statistics
----------------
Final objective value = 1.14302250322486e+00
Final feasibility error (abs / rel) = 1.00e-01 / 1.74e-03
Final optimality error (abs / rel) = 3.26e-02 / 1.04e-02
# of iterations = 18
# of CG iterations = 9
# of function evaluations = 0
# of gradient evaluations = 0
# of Hessian evaluations = 0
Total program time (secs) = 0.01203 ( 0.005 CPU time)
Time spent in evaluations (secs) = 0.00000
================================================================================
WARNING: Loading a SolverResults object with a warning status into
model.name="unknown";
- termination condition: infeasible
- message from solver: Knitro 16.0.0\x3a Convergence to an infeasible
point. Problem may be locally infeasible.; objective 1.143022503224856;
feasibility error 0.1; 18 iterations; 0 function evaluations
Artelys Knitro 16.0.0:
=======================================
Commercial License
Artelys Knitro 16.0.0
=======================================
Knitro using 1 thread.
No start point provided -- Knitro computing one.
Knitro presolve eliminated 0 variables (0%) and 20 constraints (91%) in 0.00s.
concurrent_evals 0
datacheck 0
feastol 1e-06
feastol_abs 0.001
findiff_numthreads 1
hessian_no_f 1
hessopt 1
opttol 1e-06
opttol_abs 0.001
Knitro running advanced initialization strategy specified by initpt_strategy.
Problem Characteristics | Presolved
-----------------------
Problem type: convex QP
Objective: minimize / quadratic
Number of variables: 10 | 10
bounds: lower upper range | lower upper range
0 0 10 | 10 0 0
free fixed | free fixed
0 0 | 0 0
Number of constraints: 22 | 2
eq. ineq. range | eq. ineq. range
linear: 1 21 0 | 1 1 0
quadratic: 0 0 0 | 0 0 0
Number of nonzeros:
objective Jacobian Hessian | objective Jacobian Hessian
linear: 0 40 | 0 20
quadratic: 10 0 55 | 10 0 55
total: 10 40 55 | 10 20 55
Coefficient range:
linear objective: [0e+00, 0e+00] | [0e+00, 0e+00]
linear constraints: [3e-01, 7e+01] | [3e-01, 7e+01]
quadratic objective: [2e-02, 1e+01] | [2e-02, 1e+01]
quadratic constraints: [0e+00, 0e+00] | [0e+00, 0e+00]
variable bounds: [1e+00, 1e+00] | [5e-02, 7e-02]
constraint bounds: [5e-02, 2e+01] | [1e+00, 2e+01]
Knitro using the Interior-Point/Barrier Direct algorithm.
Iter Objective FeasError OptError ||Step|| Time
-------- -------------- --------- --------- --------- --------
0 1.270330e+00 9.20e+00
10 9.724567e+00 1.49e+00 4.22e+00 1.38e+00 0.01
20 1.326475e+00 1.83e-01 5.75e-02 4.27e-02 0.01
30 1.326869e+00 1.84e-01 5.74e-02 1.74e-05 0.01
34 1.326885e+00 1.84e-01 5.74e-02 9.27e-08 0.01
EXIT: Convergence to an infeasible point. The problem is determined
to be infeasible.
HINT: Knitro spent 2.4% of solution time (0.000232 secs) checking model
convexity. To skip the automatic convexity checker for QPs and QCQPs,
explicity set the user option convex=0 or convex=1.
Final Statistics
----------------
Final objective value = 1.32688503054724e+00
Final feasibility error (abs / rel) = 1.84e-01 / 2.93e-03
Final optimality error (abs / rel) = 5.74e-02 / 1.66e-02
# of iterations = 34
# of CG iterations = 18
# of function evaluations = 0
# of gradient evaluations = 0
# of Hessian evaluations = 0
Total program time (secs) = 0.00962 ( 0.007 CPU time)
Time spent in evaluations (secs) = 0.00000
================================================================================
WARNING: Loading a SolverResults object with a warning status into
model.name="unknown";
- termination condition: infeasible
- message from solver: Knitro 16.0.0\x3a Convergence to an infeasible
point. Problem may be locally infeasible.; objective 1.3268850305472382;
feasibility error 0.184; 34 iterations; 0 function evaluations
draw_comparison(
bounded,
[f"Return {r}, Risk {s.risk:.2f}" for r, s in zip(returns, bounded)],
nasdaq.names,
"Least risk with every weight bounded",
)The floors force capital into assets the model had left out, including the ones with a negative expected return, so the same desired return has to be met from a worse starting position. Every portfolio here was already available to the model before and it did not choose one, so bounding the weights can only raise the risk.
Adding a cardinality limit
To further control the diversification, we introduce a cardinality constraint to ensure that exactly \(K\) assets are selected in the portfolio. For this, we introduce a new set of binary variables:
- \(x_i \in \{0, 1\}\), \(i = 1, \dots, N\): \(x_i = 1\) iff asset \(i\) is selected in the portfolio
The diversification constraints and the linking constraints between \(x_i\) and \(w_i\) merge into a single pair of bounds, alongside the cardinality constraint itself:
\[ \forall i = 1, \dots, N \qquad L_i x_i \leq w_i \leq U_i x_i, \qquad \sum_{i=1}^N x_i = K \]
This ensures that if an asset \(i\) is not selected (\(x_i = 0\)), its weight \(w_i\) will be zero. If an asset is selected (\(x_i = 1\)), its weight will lie between \(L_i\) and \(U_i\).
The binary variables make this a mixed-integer QP, harder than the two models before it.
Every bound here is multiplied by a binary, so with_cardinality builds on markowitz rather than on with_bounds.
def with_cardinality(market, *, desired_return, lower, upper, cardinality):
model, w = markowitz(market, desired_return=desired_return)
model.x = pyo.Var(model.assets, within=pyo.Binary)
assets, x = model.assets, model.x
model.floor = pyo.Constraint(assets, rule=lambda _, i: w[i] >= lower[i] * x[i])
model.ceiling = pyo.Constraint(assets, rule=lambda _, i: w[i] <= upper[i] * x[i])
held = pyo.quicksum(x[i] for i in assets)
model.cardinality = pyo.Constraint(expr=held == cardinality)
return model, wThe same bounds apply here, and exactly three assets may be held.
limited = [
solve(
nasdaq,
with_cardinality,
desired_return=r,
lower=lower,
upper=upper,
cardinality=3,
)
for r in returns
]Show the full outputHide the full output
Artelys Knitro 16.0.0:
=======================================
Commercial License
Artelys Knitro 16.0.0
=======================================
Knitro changing mip_method from AUTO to 1.
No start point provided -- Knitro computing one.
Knitro presolve eliminated 0 variables (0%) and 0 constraints (0%) in 0.00s.
concurrent_evals 0
datacheck 0
feastol 1e-06
feastol_abs 1e-06
findiff_numthreads 1
hessian_no_f 1
hessopt 1
opttol 1e-06
opttol_abs 0.001
Knitro changing mip_root_nlpalg from AUTO to 1.
Knitro changing mip_node_nlpalg from AUTO to 1.
Knitro changing mip_branchrule from AUTO to 2.
Knitro changing mip_selectrule from AUTO to 2.
Knitro changing mip_mir from AUTO to 2.
Knitro changing mip_clique from AUTO to 0.
Knitro changing mip_zerohalf from AUTO to 0.
Knitro changing mip_liftproject from AUTO to 0.
Knitro changing mip_knapsack from AUTO to 2.
Knitro changing mip_gomory from AUTO to 1.
Knitro changing mip_cut_flowcover from AUTO to 2.
Knitro changing mip_cut_probing from AUTO to 1.
Knitro changing mip_rounding from AUTO to 3.
Knitro changing mip_heuristic_strategy from AUTO to 1.
Knitro changing mip_heuristic_feaspump from AUTO to 1.
Knitro changing mip_heuristic_misqp from AUTO to 0.
Knitro changing mip_heuristic_mpec from AUTO to 1.
Knitro changing mip_heuristic_diving from AUTO to 1926.
Knitro changing mip_heuristic_fixpropagate from AUTO to 62.
Knitro changing mip_heuristic_lns from AUTO to 0.
Knitro changing mip_heuristic_localsearch from AUTO to 1.
Knitro changing mip_pseudoinit from AUTO to 1.
Problem Characteristics | Presolved
-----------------------
Problem type: convex MIQP
Objective: minimize / quadratic
Number of variables: 20 | 20
bounds: lower upper range | lower upper range
0 0 20 | 5 0 15
free fixed | free fixed
0 0 | 0 0
cont. binary integer | cont. binary integer
10 10 0 | 10 10 0
Number of constraints: 23 | 23
eq. ineq. range | eq. ineq. range
linear: 2 21 0 | 2 21 0
quadratic: 0 0 0 | 0 0 0
Number of nonzeros:
objective Jacobian Hessian | objective Jacobian Hessian
linear: 0 70 | 0 70
quadratic: 10 0 55 | 10 0 55
total: 10 70 55 | 10 70 55
Knitro using Branch and Bound method with 8 threads.
Initial points
--------------
No initial point provided for the root node relaxation.
No primal point provided for the MIP.
Coefficient range:
linear objective: [0e+00, 0e+00] | [0e+00, 0e+00]
linear constraints: [5e-02, 7e+01] | [5e-02, 7e+01]
quadratic objective: [2e-02, 1e+01] | [2e-02, 1e+01]
quadratic constraints: [0e+00, 0e+00] | [0e+00, 0e+00]
variable bounds: [1e+00, 1e+00] | [1e+00, 1e+00]
constraint bounds: [1e+00, 5e+00] | [1e+00, 5e+00]
Root node relaxation
--------------------
Iter Objective Feasibility Optimality Time
error error (secs)
---- --------- ----------- ---------- ------
0 0.430856 2.59006 0.156436 0.082
1 0.430856 2.59006 0.156436 0.082
2 0.503552 4.44089e-16 0.182691 0.082
3 0.417456 4.44089e-16 2.07379e-02 0.082
4 0.347627 8.88178e-16 3.10890e-03 0.082
5 0.328335 2.22045e-16 5.61765e-04 0.082
6 0.323952 8.88178e-16 7.84677e-05 0.082
7 0.323144 4.44089e-16 2.05361e-06 0.082
8 0.323134 7.80792e-12 1.78962e-10 0.082
9 0.323134 7.80792e-12 1.78962e-10 0.082
10 0.323134 4.44089e-16 2.43939e-08 0.084
Tree search
-----------
Nodes Best solution Best bound Gap Time
Expl | Unexpl value value (secs)
--------------- ------------- ---------- --- ------
1 2 0.505370 LS 0.323134 18.22% 0.085
3 4 0.495263 LS 0.323134 17.21% 0.089
5 6 0.485357 LS 0.329103 15.63% 0.094
8 9 0.391153 MPEC 0.329103 6.20% 0.097
25 0 0.391153 0.391114 0.00% 0.104
EXIT: Optimal solution found.
Final Statistics for MIP
------------------------
Final objective value = 3.91152827306554263e-01
Final bound value = 3.91113712023823612e-01
Final optimality gap (abs / rel) = 3.91153e-05 / 3.91153e-05 (0.00%)
# of root cutting plane rounds = 1
# of restarts = 0
# of nodes processed = 25 (0.136s)
# of strong branching evaluations = 0 (0.000s)
# of function evaluations = 0 (0.000s)
# of gradient evaluations = 0 (0.000s)
# of hessian evaluations = 0 (0.000s)
# of hessian-vector evaluations = 0
# of subproblems processed = 32 (0.144s)
Total program time (secs) = 0.10391 (0.108 CPU time)
Time spent in evaluations (secs) = 0.00000
Cuts statistics (gen / add)
---------------------------
Knapsack cuts = 0 / 0
Mixed-integer rounding cuts = 2 / 2
Gomory cuts = 0 / 0
Flow-cover cuts = 0 / 0
Probing cuts = 0 / 0
Heuristics statistics (calls / successes / time)
------------------------------------------------
Feasibility pump = 1 / 1 / 0.005s
Rounding heuristic = 1 / 0 / 0.000s
MPEC heuristic = 1 / 1 / 0.004s
Local search heuristic = 9 / 4 / 0.025s
===========================================================================
Artelys Knitro 16.0.0:
=======================================
Commercial License
Artelys Knitro 16.0.0
=======================================
Knitro changing mip_method from AUTO to 1.
No start point provided -- Knitro computing one.
Knitro presolve eliminated 0 variables (0%) and 0 constraints (0%) in 0.00s.
concurrent_evals 0
datacheck 0
feastol 1e-06
feastol_abs 1e-06
findiff_numthreads 1
hessian_no_f 1
hessopt 1
opttol 1e-06
opttol_abs 0.001
Knitro changing mip_root_nlpalg from AUTO to 1.
Knitro changing mip_node_nlpalg from AUTO to 1.
Knitro changing mip_branchrule from AUTO to 2.
Knitro changing mip_selectrule from AUTO to 2.
Knitro changing mip_mir from AUTO to 2.
Knitro changing mip_clique from AUTO to 0.
Knitro changing mip_zerohalf from AUTO to 0.
Knitro changing mip_liftproject from AUTO to 0.
Knitro changing mip_knapsack from AUTO to 2.
Knitro changing mip_gomory from AUTO to 1.
Knitro changing mip_cut_flowcover from AUTO to 2.
Knitro changing mip_cut_probing from AUTO to 1.
Knitro changing mip_rounding from AUTO to 3.
Knitro changing mip_heuristic_strategy from AUTO to 1.
Knitro changing mip_heuristic_feaspump from AUTO to 1.
Knitro changing mip_heuristic_misqp from AUTO to 0.
Knitro changing mip_heuristic_mpec from AUTO to 1.
Knitro changing mip_heuristic_diving from AUTO to 1926.
Knitro changing mip_heuristic_fixpropagate from AUTO to 62.
Knitro changing mip_heuristic_lns from AUTO to 0.
Knitro changing mip_heuristic_localsearch from AUTO to 1.
Knitro changing mip_pseudoinit from AUTO to 1.
Problem Characteristics | Presolved
-----------------------
Problem type: convex MIQP
Objective: minimize / quadratic
Number of variables: 20 | 20
bounds: lower upper range | lower upper range
0 0 20 | 5 0 15
free fixed | free fixed
0 0 | 0 0
cont. binary integer | cont. binary integer
10 10 0 | 10 10 0
Number of constraints: 23 | 23
eq. ineq. range | eq. ineq. range
linear: 2 21 0 | 2 21 0
quadratic: 0 0 0 | 0 0 0
Number of nonzeros:
objective Jacobian Hessian | objective Jacobian Hessian
linear: 0 70 | 0 70
quadratic: 10 0 55 | 10 0 55
total: 10 70 55 | 10 70 55
Knitro using Branch and Bound method with 8 threads.
Initial points
--------------
No initial point provided for the root node relaxation.
No primal point provided for the MIP.
Coefficient range:
linear objective: [0e+00, 0e+00] | [0e+00, 0e+00]
linear constraints: [5e-02, 7e+01] | [5e-02, 7e+01]
quadratic objective: [2e-02, 1e+01] | [2e-02, 1e+01]
quadratic constraints: [0e+00, 0e+00] | [0e+00, 0e+00]
variable bounds: [1e+00, 1e+00] | [1e+00, 1e+00]
constraint bounds: [1e+00, 8e+00] | [1e+00, 8e+00]
Root node relaxation
--------------------
Iter Objective Feasibility Optimality Time
error error (secs)
---- --------- ----------- ---------- ------
0 0.401827 3.61497 0.157052 0.080
1 0.401827 3.61497 0.157052 0.080
2 0.496356 8.51961e-03 0.187828 0.080
3 0.477358 1.45431e-04 2.25667e-02 0.081
4 0.376725 4.44089e-16 8.12537e-03 0.081
5 0.361378 4.44089e-16 4.98045e-04 0.081
6 0.357859 4.44089e-16 6.43383e-05 0.081
7 0.357795 8.88178e-16 3.68238e-06 0.081
8 0.357791 4.44089e-16 2.80556e-07 0.081
9 0.357791 4.44089e-16 2.80556e-07 0.081
10 0.357791 4.44089e-16 8.57410e-07 0.083
Tree search
-----------
Nodes Best solution Best bound Gap Time
Expl | Unexpl value value (secs)
--------------- ------------- ---------- --- ------
1 2 0.506866 FCRD 0.357791 14.91% 0.085
31 0 0.506866 0.506816 0.01% 0.104
EXIT: Optimal solution found.
Final Statistics for MIP
------------------------
Final objective value = 5.06866190634101987e-01
Final bound value = 5.06815504015038609e-01
Final optimality gap (abs / rel) = 5.06866e-05 / 5.06866e-05 (0.01%)
# of root cutting plane rounds = 1
# of restarts = 0
# of nodes processed = 31 (0.153s)
# of strong branching evaluations = 0 (0.000s)
# of function evaluations = 0 (0.000s)
# of gradient evaluations = 0 (0.000s)
# of hessian evaluations = 0 (0.000s)
# of hessian-vector evaluations = 0
# of subproblems processed = 34 (0.164s)
Total program time (secs) = 0.10417 (0.122 CPU time)
Time spent in evaluations (secs) = 0.00000
Cuts statistics (gen / add)
---------------------------
Knapsack cuts = 0 / 0
Mixed-integer rounding cuts = 0 / 0
Gomory cuts = 0 / 0
Flow-cover cuts = 0 / 0
Probing cuts = 0 / 0
Heuristics statistics (calls / successes / time)
------------------------------------------------
Feasibility pump = 1 / 0 / 0.005s
Rounding heuristic = 1 / 1 / 0.001s
MPEC heuristic = 1 / 0 / 0.005s
Local search heuristic = 7 / 3 / 0.018s
===========================================================================
Artelys Knitro 16.0.0:
=======================================
Commercial License
Artelys Knitro 16.0.0
=======================================
Knitro changing mip_method from AUTO to 1.
No start point provided -- Knitro computing one.
Knitro presolve eliminated 0 variables (0%) and 0 constraints (0%) in 0.00s.
concurrent_evals 0
datacheck 0
feastol 1e-06
feastol_abs 1e-06
findiff_numthreads 1
hessian_no_f 1
hessopt 1
opttol 1e-06
opttol_abs 0.001
Knitro changing mip_root_nlpalg from AUTO to 1.
Knitro changing mip_node_nlpalg from AUTO to 1.
Knitro changing mip_branchrule from AUTO to 2.
Knitro changing mip_selectrule from AUTO to 2.
Knitro changing mip_mir from AUTO to 2.
Knitro changing mip_clique from AUTO to 0.
Knitro changing mip_zerohalf from AUTO to 0.
Knitro changing mip_liftproject from AUTO to 0.
Knitro changing mip_knapsack from AUTO to 2.
Knitro changing mip_gomory from AUTO to 1.
Knitro changing mip_cut_flowcover from AUTO to 2.
Knitro changing mip_cut_probing from AUTO to 1.
Knitro changing mip_rounding from AUTO to 3.
Knitro changing mip_heuristic_strategy from AUTO to 1.
Knitro changing mip_heuristic_feaspump from AUTO to 1.
Knitro changing mip_heuristic_misqp from AUTO to 0.
Knitro changing mip_heuristic_mpec from AUTO to 1.
Knitro changing mip_heuristic_diving from AUTO to 1926.
Knitro changing mip_heuristic_fixpropagate from AUTO to 62.
Knitro changing mip_heuristic_lns from AUTO to 0.
Knitro changing mip_heuristic_localsearch from AUTO to 1.
Knitro changing mip_pseudoinit from AUTO to 1.
Problem Characteristics | Presolved
-----------------------
Problem type: convex MIQP
Objective: minimize / quadratic
Number of variables: 20 | 20
bounds: lower upper range | lower upper range
0 0 20 | 5 0 15
free fixed | free fixed
0 0 | 0 0
cont. binary integer | cont. binary integer
10 10 0 | 10 10 0
Number of constraints: 23 | 23
eq. ineq. range | eq. ineq. range
linear: 2 21 0 | 2 21 0
quadratic: 0 0 0 | 0 0 0
Number of nonzeros:
objective Jacobian Hessian | objective Jacobian Hessian
linear: 0 70 | 0 70
quadratic: 10 0 55 | 10 0 55
total: 10 70 55 | 10 70 55
Knitro using Branch and Bound method with 8 threads.
Initial points
--------------
No initial point provided for the root node relaxation.
No primal point provided for the MIP.
Coefficient range:
linear objective: [0e+00, 0e+00] | [0e+00, 0e+00]
linear constraints: [5e-02, 7e+01] | [5e-02, 7e+01]
quadratic objective: [2e-02, 1e+01] | [2e-02, 1e+01]
quadratic constraints: [0e+00, 0e+00] | [0e+00, 0e+00]
variable bounds: [1e+00, 1e+00] | [1e+00, 1e+00]
constraint bounds: [1e+00, 1e+01] | [1e+00, 1e+01]
Root node relaxation
--------------------
Iter Objective Feasibility Optimality Time
error error (secs)
---- --------- ----------- ---------- ------
0 0.405243 3.56028 0.157915 0.080
1 0.405243 3.56028 0.157915 0.080
2 0.499915 2.14435e-02 0.186931 0.080
3 0.576766 0.00000e+00 2.17350e-02 0.080
4 0.476514 4.44089e-16 4.88309e-03 0.080
5 0.433684 4.44089e-16 6.66356e-04 0.080
6 0.429045 8.88178e-16 6.22491e-05 0.080
7 0.428911 2.22045e-16 4.11592e-08 0.080
8 0.428911 6.57219e-11 3.42538e-08 0.080
9 0.428911 2.22045e-16 1.83348e-08 0.082
Tree search
-----------
Nodes Best solution Best bound Gap Time
Expl | Unexpl value value (secs)
--------------- ------------- ---------- --- ------
1 2 0.891125 LS 0.428911 46.22% 0.083
2 3 0.728171 LS 0.428911 29.93% 0.089
9 10 0.511145 MPEC 0.428911 8.22% 0.097
21 0 0.511145 0.511093 0.01% 0.103
EXIT: Optimal solution found.
Final Statistics for MIP
------------------------
Final objective value = 5.11144529489658161e-01
Final bound value = 5.11093415036709242e-01
Final optimality gap (abs / rel) = 5.11145e-05 / 5.11145e-05 (0.01%)
# of root cutting plane rounds = 1
# of restarts = 0
# of nodes processed = 21 (0.118s)
# of strong branching evaluations = 0 (0.000s)
# of function evaluations = 0 (0.000s)
# of gradient evaluations = 0 (0.000s)
# of hessian evaluations = 0 (0.000s)
# of hessian-vector evaluations = 0
# of subproblems processed = 24 (0.131s)
Total program time (secs) = 0.10290 (0.086 CPU time)
Time spent in evaluations (secs) = 0.00000
Cuts statistics (gen / add)
---------------------------
Knapsack cuts = 0 / 0
Mixed-integer rounding cuts = 1 / 1
Gomory cuts = 0 / 0
Flow-cover cuts = 0 / 0
Probing cuts = 0 / 0
Heuristics statistics (calls / successes / time)
------------------------------------------------
Feasibility pump = 1 / 1 / 0.006s
Rounding heuristic = 2 / 1 / 0.003s
MPEC heuristic = 1 / 1 / 0.006s
Local search heuristic = 8 / 3 / 0.019s
===========================================================================
Artelys Knitro 16.0.0:
=======================================
Commercial License
Artelys Knitro 16.0.0
=======================================
Knitro changing mip_method from AUTO to 1.
No start point provided -- Knitro computing one.
Knitro presolve eliminated 0 variables (0%) and 0 constraints (0%) in 0.00s.
concurrent_evals 0
datacheck 0
feastol 1e-06
feastol_abs 1e-06
findiff_numthreads 1
hessian_no_f 1
hessopt 1
opttol 1e-06
opttol_abs 0.001
Knitro changing mip_root_nlpalg from AUTO to 1.
Knitro changing mip_node_nlpalg from AUTO to 1.
Knitro changing mip_branchrule from AUTO to 2.
Knitro changing mip_selectrule from AUTO to 2.
Knitro changing mip_mir from AUTO to 2.
Knitro changing mip_clique from AUTO to 0.
Knitro changing mip_zerohalf from AUTO to 0.
Knitro changing mip_liftproject from AUTO to 0.
Knitro changing mip_knapsack from AUTO to 2.
Knitro changing mip_gomory from AUTO to 1.
Knitro changing mip_cut_flowcover from AUTO to 2.
Knitro changing mip_cut_probing from AUTO to 1.
Knitro changing mip_rounding from AUTO to 3.
Knitro changing mip_heuristic_strategy from AUTO to 1.
Knitro changing mip_heuristic_feaspump from AUTO to 1.
Knitro changing mip_heuristic_misqp from AUTO to 0.
Knitro changing mip_heuristic_mpec from AUTO to 1.
Knitro changing mip_heuristic_diving from AUTO to 1926.
Knitro changing mip_heuristic_fixpropagate from AUTO to 62.
Knitro changing mip_heuristic_lns from AUTO to 0.
Knitro changing mip_heuristic_localsearch from AUTO to 1.
Knitro changing mip_pseudoinit from AUTO to 1.
Problem Characteristics | Presolved
-----------------------
Problem type: convex MIQP
Objective: minimize / quadratic
Number of variables: 20 | 20
bounds: lower upper range | lower upper range
0 0 20 | 5 0 15
free fixed | free fixed
0 0 | 0 0
cont. binary integer | cont. binary integer
10 10 0 | 10 10 0
Number of constraints: 23 | 23
eq. ineq. range | eq. ineq. range
linear: 2 21 0 | 2 21 0
quadratic: 0 0 0 | 0 0 0
Number of nonzeros:
objective Jacobian Hessian | objective Jacobian Hessian
linear: 0 70 | 0 70
quadratic: 10 0 55 | 10 0 55
total: 10 70 55 | 10 70 55
Knitro using Branch and Bound method with 8 threads.
Initial points
--------------
No initial point provided for the root node relaxation.
No primal point provided for the MIP.
Coefficient range:
linear objective: [0e+00, 0e+00] | [0e+00, 0e+00]
linear constraints: [5e-02, 7e+01] | [5e-02, 7e+01]
quadratic objective: [2e-02, 1e+01] | [2e-02, 1e+01]
quadratic constraints: [0e+00, 0e+00] | [0e+00, 0e+00]
variable bounds: [1e+00, 1e+00] | [1e+00, 1e+00]
constraint bounds: [1e+00, 2e+01] | [1e+00, 2e+01]
Root node relaxation
--------------------
Iter Objective Feasibility Optimality Time
error error (secs)
---- --------- ----------- ---------- ------
0 0.422045 8.42097 0.158771 0.080
1 0.422045 8.42097 0.158771 0.080
2 0.536720 4.94265e-02 0.201772 0.081
3 0.889723 4.89048e-03 0.142338 0.081
4 0.836220 0.00000e+00 9.98626e-03 0.081
5 0.780900 4.44089e-16 1.83991e-03 0.081
6 0.766963 4.44089e-16 2.00489e-04 0.081
7 0.766683 0.00000e+00 1.82529e-08 0.081
8 0.766683 8.42165e-11 1.54466e-08 0.081
9 0.766683 1.52462e-24 3.40515e-09 0.083
Tree search
-----------
Nodes Best solution Best bound Gap Time
Expl | Unexpl value value (secs)
--------------- ------------- ---------- --- ------
1 2 1.40466 LS 0.766683 45.42% 0.084
7 8 0.843554 FCRD 0.775295 6.83% 0.093
15 0 0.843554 0.843470 0.01% 0.099
EXIT: Optimal solution found.
Final Statistics for MIP
------------------------
Final objective value = 8.43554338298756701e-01
Final bound value = 8.43469982864926804e-01
Final optimality gap (abs / rel) = 8.43554e-05 / 8.43554e-05 (0.01%)
# of root cutting plane rounds = 1
# of restarts = 0
# of nodes processed = 15 (0.104s)
# of strong branching evaluations = 0 (0.000s)
# of function evaluations = 0 (0.000s)
# of gradient evaluations = 0 (0.000s)
# of hessian evaluations = 0 (0.000s)
# of hessian-vector evaluations = 0
# of subproblems processed = 17 (0.115s)
Total program time (secs) = 0.09908 (0.064 CPU time)
Time spent in evaluations (secs) = 0.00000
Cuts statistics (gen / add)
---------------------------
Knapsack cuts = 0 / 0
Mixed-integer rounding cuts = 0 / 0
Gomory cuts = 0 / 0
Flow-cover cuts = 0 / 0
Probing cuts = 0 / 0
Heuristics statistics (calls / successes / time)
------------------------------------------------
Feasibility pump = 1 / 1 / 0.005s
Rounding heuristic = 2 / 1 / 0.003s
MPEC heuristic = 1 / 1 / 0.004s
Local search heuristic = 7 / 1 / 0.014s
===========================================================================
draw_comparison(
limited,
[f"Return {r}, Risk {s.risk:.2f}" for r, s in zip(returns, limited)],
nasdaq.names,
"Least risk holding exactly three assets",
)By incorporating extensions related to diversification and cardinality constraints, some assets may no longer be included in the portfolio, while others may see their weights increase. This occurs because such constraints can limit the number of assets selected and enforce a more concentrated allocation, thereby intensifying the focus on a smaller set of high-performing assets.
The risks come out below the ones in the figure above. That looks wrong for a model carrying an extra constraint. The reason is that a floor now reads \(L_i x_i\), so it applies only to an asset that is actually held, and the seven that are dropped stop having to be paid for.
Rebalancing with transaction costs
Rebalancing a portfolio involves buying and selling securities to adjust its composition, leading to turnover. While the basic Markowitz model assumes there are no trading costs, in practice, turnover incurs expenses. There are two kinds of transaction costs:
- Fixed costs, which represent commissions or transfer fees
- Variable costs, which depend on the transaction volume, representing costs such as market impact or bid/ask spread
In the variant considered in this section, the objective is to maximize the return and the maximum risk is set as a constraint. To make the model more meaningful, we consider that a proportion of the capital is already invested in some assets.
Input
- \(W^0_i\): fraction of the portfolio value already invested in asset \(i\)
- \(\Gamma\): limited risk level
- \(F_i\): fixed cost if buying asset \(i\)
- \(V_i\): variable factor cost when buying asset \(i\)
Variables. We need two additional sets of variables to model the absolute value \(|w_i - W^0_i|\), the proportion of the capital moved from asset \(i\) (bought or sold):
- \(z^+_i \in [0, 1]\): positive part of \(w_i - W^0_i\)
- \(z^-_i \in [0, 1]\): negative part of \(w_i - W^0_i\)
Objective: maximize the return
\[ \max \sum_{i=1}^N \mu_i w_i \]
Constraints
\[ z^+_i - z^-_i = w_i - W^0_i, \qquad \sum_{i=1}^N \sum_{j=1}^N \Sigma_{ij} w_i w_j \leq \Gamma, \qquad \sum_{i=1}^N w_i + \sum_{i=1}^N \big( F_i x_i + V_i (z^+_i + z^-_i) \big) = \sum_{i=1}^N W^0_i \]
rebalance keeps nothing from markowitz. The objective and the risk have swapped places.
def rebalance(market, *, holdings, max_risk, fixed_cost, variable_cost):
mu, sigma = market.returns, market.covariance
model = pyo.ConcreteModel()
model.assets = pyo.RangeSet(0, market.num_assets - 1)
model.w = pyo.Var(model.assets, bounds=(0, 1))
model.x = pyo.Var(model.assets, within=pyo.Binary)
model.z_plus = pyo.Var(model.assets, within=pyo.NonNegativeReals)
model.z_minus = pyo.Var(model.assets, within=pyo.NonNegativeReals)
assets, w = model.assets, model.w
expected = pyo.quicksum(mu[i] * w[i] for i in assets)
model.obj = pyo.Objective(expr=expected, sense=pyo.maximize)
def move_rule(model, i):
return model.z_plus[i] - model.z_minus[i] == model.w[i] - holdings[i]
model.move = pyo.Constraint(model.assets, rule=move_rule)
variance = pyo.quicksum(sigma[i][j] * w[i] * w[j] for i in assets for j in assets)
model.risk = pyo.Constraint(expr=variance <= max_risk)
def budget_rule(model):
cost = pyo.quicksum(
fixed_cost[i] * model.x[i]
+ variable_cost[i] * (model.z_plus[i] + model.z_minus[i])
for i in model.assets
)
return pyo.quicksum(model.w[i] for i in model.assets) + cost == sum(holdings)
model.budget = pyo.Constraint(rule=budget_rule)
return model, model.wA high variable cost limits the changes we can make to our current portfolio. That’s why it’s important to vary this factor to observe the differences. We start from an equally weighted portfolio.
gamma = 0.7
w0 = [1 / nasdaq.num_assets] * nasdaq.num_assets
fixed_cost = [0.1] * nasdaq.num_assets
variable_costs = [1, 0.75, 0.5, 0.25, 0]
initial_return = expected_return(nasdaq.returns, w0)
initial = Portfolio(w0, initial_return, risk(nasdaq.covariance, w0))rebalanced = [
solve(
nasdaq,
rebalance,
holdings=w0,
max_risk=gamma,
fixed_cost=fixed_cost,
variable_cost=[v] * nasdaq.num_assets,
)
for v in variable_costs
]Show the full outputHide the full output
Artelys Knitro 16.0.0:
=======================================
Commercial License
Artelys Knitro 16.0.0
=======================================
Knitro changing mip_method from AUTO to 1.
No start point provided -- Knitro computing one.
Knitro presolve eliminated 0 variables (0%) and 0 constraints (0%) in 0.00s.
concurrent_evals 0
datacheck 0
feastol 1e-06
feastol_abs 1e-06
findiff_numthreads 1
hessian_no_f 1
hessopt 1
opttol 1e-06
opttol_abs 0.001
Knitro changing mip_root_nlpalg from AUTO to 1.
Knitro changing mip_node_nlpalg from AUTO to 1.
Knitro changing mip_branchrule from AUTO to 2.
Knitro changing mip_selectrule from AUTO to 2.
Knitro changing mip_mir from AUTO to 2.
Knitro changing mip_clique from AUTO to 0.
Knitro changing mip_zerohalf from AUTO to 0.
Knitro changing mip_liftproject from AUTO to 0.
Knitro changing mip_knapsack from AUTO to 2.
Knitro changing mip_gomory from AUTO to 1.
Knitro changing mip_cut_flowcover from AUTO to 2.
Knitro changing mip_cut_probing from AUTO to 1.
Knitro changing mip_rounding from AUTO to 3.
Knitro changing mip_heuristic_strategy from AUTO to 1.
Knitro changing mip_heuristic_feaspump from AUTO to 1.
Knitro changing mip_heuristic_misqp from AUTO to 0.
Knitro changing mip_heuristic_mpec from AUTO to 1.
Knitro changing mip_heuristic_diving from AUTO to 1926.
Knitro changing mip_heuristic_fixpropagate from AUTO to 62.
Knitro changing mip_heuristic_lns from AUTO to 0.
Knitro changing mip_heuristic_localsearch from AUTO to 1.
Knitro changing mip_pseudoinit from AUTO to 1.
Problem Characteristics | Presolved
-----------------------
Problem type: convex MIQCQP
Objective: maximize / linear
Number of variables: 40 | 40
bounds: lower upper range | lower upper range
20 0 20 | 20 0 20
free fixed | free fixed
0 0 | 0 0
cont. binary integer | cont. binary integer
30 10 0 | 30 10 0
Number of constraints: 12 | 12
eq. ineq. range | eq. ineq. range
linear: 11 0 0 | 11 0 0
quadratic: 0 1 0 | 0 1 0
Number of nonzeros:
objective Jacobian Hessian | objective Jacobian Hessian
linear: 10 70 | 10 70
quadratic: 0 10 55 | 0 10 55
total: 10 80 55 | 10 80 55
Knitro using Branch and Bound method with 8 threads.
Initial points
--------------
No initial point provided for the root node relaxation.
No primal point provided for the MIP.
Coefficient range:
linear objective: [3e-01, 7e+01] | [3e-01, 7e+01]
linear constraints: [1e-01, 1e+00] | [1e-01, 1e+00]
quadratic objective: [0e+00, 0e+00] | [0e+00, 0e+00]
quadratic constraints: [2e-02, 1e+01] | [2e-02, 1e+01]
variable bounds: [1e+00, 1e+00] | [1e+00, 1e+00]
constraint bounds: [1e-01, 1e+00] | [1e-01, 1e+00]
Root node relaxation
--------------------
Iter Objective Feasibility Optimality Time
error error (secs)
---- --------- ----------- ---------- ------
0 3.15768 0.407920 22.8595 0.071
1 7.38760 0.358942 0.512151 0.071
2 4.69313 6.86466e-02 0.212828 0.072
3 6.45994 5.79679e-04 2.04853e-02 0.072
4 6.65140 3.41900e-06 1.53874e-04 0.072
5 6.65278 5.49055e-10 2.75613e-08 0.072
6 6.65278 1.44329e-15 2.26422e-14 0.072
7 6.65278 1.44329e-15 2.26422e-14 0.074
Tree search
-----------
Nodes Best solution Best bound Gap Time
Expl | Unexpl value value (secs)
--------------- ------------- ---------- --- ------
1 0 6.65278 LEAF 6.65278 0.00% 0.074
EXIT: Optimal solution found.
Final Statistics for MIP
------------------------
Final objective value = 6.65278399999989922e+00
Final bound value = 6.65278399999989922e+00
Final optimality gap (abs / rel) = 0.00000e+00 / 0.00000e+00 (0.00%)
# of root cutting plane rounds = 0
# of restarts = 0
# of nodes processed = 1 (0.073s)
# of strong branching evaluations = 0 (0.000s)
# of function evaluations = 0 (0.000s)
# of gradient evaluations = 0 (0.000s)
# of hessian evaluations = 0 (0.000s)
# of hessian-vector evaluations = 0
# of subproblems processed = 1 (0.073s)
Total program time (secs) = 0.07403 (0.036 CPU time)
Time spent in evaluations (secs) = 0.00000
Cuts statistics (gen / add)
---------------------------
Knapsack cuts = 0 / 0
Mixed-integer rounding cuts = 0 / 0
Gomory cuts = 0 / 0
Flow-cover cuts = 0 / 0
Probing cuts = 0 / 0
Heuristics statistics (calls / successes / time)
------------------------------------------------
Feasibility pump = 0 / 0 / 0.000s
Rounding heuristic = 0 / 0 / 0.000s
MPEC heuristic = 0 / 0 / 0.000s
Local search heuristic = 1 / 1 / 0.003s
===========================================================================
Artelys Knitro 16.0.0:
=======================================
Commercial License
Artelys Knitro 16.0.0
=======================================
Knitro changing mip_method from AUTO to 1.
No start point provided -- Knitro computing one.
Knitro presolve eliminated 0 variables (0%) and 0 constraints (0%) in 0.00s.
concurrent_evals 0
datacheck 0
feastol 1e-06
feastol_abs 1e-06
findiff_numthreads 1
hessian_no_f 1
hessopt 1
opttol 1e-06
opttol_abs 0.001
Knitro changing mip_root_nlpalg from AUTO to 1.
Knitro changing mip_node_nlpalg from AUTO to 1.
Knitro changing mip_branchrule from AUTO to 2.
Knitro changing mip_selectrule from AUTO to 2.
Knitro changing mip_mir from AUTO to 2.
Knitro changing mip_clique from AUTO to 0.
Knitro changing mip_zerohalf from AUTO to 0.
Knitro changing mip_liftproject from AUTO to 0.
Knitro changing mip_knapsack from AUTO to 2.
Knitro changing mip_gomory from AUTO to 1.
Knitro changing mip_cut_flowcover from AUTO to 2.
Knitro changing mip_cut_probing from AUTO to 1.
Knitro changing mip_rounding from AUTO to 3.
Knitro changing mip_heuristic_strategy from AUTO to 1.
Knitro changing mip_heuristic_feaspump from AUTO to 1.
Knitro changing mip_heuristic_misqp from AUTO to 0.
Knitro changing mip_heuristic_mpec from AUTO to 1.
Knitro changing mip_heuristic_diving from AUTO to 1926.
Knitro changing mip_heuristic_fixpropagate from AUTO to 62.
Knitro changing mip_heuristic_lns from AUTO to 0.
Knitro changing mip_heuristic_localsearch from AUTO to 1.
Knitro changing mip_pseudoinit from AUTO to 1.
Problem Characteristics | Presolved
-----------------------
Problem type: convex MIQCQP
Objective: maximize / linear
Number of variables: 40 | 40
bounds: lower upper range | lower upper range
20 0 20 | 20 0 20
free fixed | free fixed
0 0 | 0 0
cont. binary integer | cont. binary integer
30 10 0 | 30 10 0
Number of constraints: 12 | 12
eq. ineq. range | eq. ineq. range
linear: 11 0 0 | 11 0 0
quadratic: 0 1 0 | 0 1 0
Number of nonzeros:
objective Jacobian Hessian | objective Jacobian Hessian
linear: 10 70 | 10 70
quadratic: 0 10 55 | 0 10 55
total: 10 80 55 | 10 80 55
Knitro using Branch and Bound method with 8 threads.
Initial points
--------------
No initial point provided for the root node relaxation.
No primal point provided for the MIP.
Coefficient range:
linear objective: [3e-01, 7e+01] | [3e-01, 7e+01]
linear constraints: [1e-01, 1e+00] | [1e-01, 1e+00]
quadratic objective: [0e+00, 0e+00] | [0e+00, 0e+00]
quadratic constraints: [2e-02, 1e+01] | [2e-02, 1e+01]
variable bounds: [1e+00, 1e+00] | [1e+00, 1e+00]
constraint bounds: [1e-01, 1e+00] | [1e-01, 1e+00]
Root node relaxation
--------------------
Iter Objective Feasibility Optimality Time
error error (secs)
---- --------- ----------- ---------- ------
0 -7.62974e-03 0.404080 22.0073 0.078
1 4.13907 0.364176 0.665296 0.078
2 4.40136 5.53411e-02 0.335451 0.078
3 7.39236 5.89156e-04 8.90825e-02 0.078
4 8.06402 1.38778e-17 1.01698e-02 0.078
5 8.11653 1.38778e-17 8.93734e-05 0.078
6 8.11679 4.44089e-16 8.45858e-09 0.078
7 8.11679 8.88178e-16 1.82104e-15 0.078
8 8.11679 4.44089e-16 1.77636e-15 0.080
Tree search
-----------
Nodes Best solution Best bound Gap Time
Expl | Unexpl value value (secs)
--------------- ------------- ---------- --- ------
1 0 8.11679 LEAF 8.11679 0.00% 0.080
EXIT: Optimal solution found.
Final Statistics for MIP
------------------------
Final objective value = 8.11679471428572263e+00
Final bound value = 8.11679471428572263e+00
Final optimality gap (abs / rel) = 0.00000e+00 / 0.00000e+00 (0.00%)
# of root cutting plane rounds = 0
# of restarts = 0
# of nodes processed = 1 (0.079s)
# of strong branching evaluations = 0 (0.000s)
# of function evaluations = 0 (0.000s)
# of gradient evaluations = 0 (0.000s)
# of hessian evaluations = 0 (0.000s)
# of hessian-vector evaluations = 0
# of subproblems processed = 1 (0.079s)
Total program time (secs) = 0.08021 (0.024 CPU time)
Time spent in evaluations (secs) = 0.00000
Cuts statistics (gen / add)
---------------------------
Knapsack cuts = 0 / 0
Mixed-integer rounding cuts = 0 / 0
Gomory cuts = 0 / 0
Flow-cover cuts = 0 / 0
Probing cuts = 0 / 0
Heuristics statistics (calls / successes / time)
------------------------------------------------
Feasibility pump = 0 / 0 / 0.000s
Rounding heuristic = 0 / 0 / 0.000s
MPEC heuristic = 0 / 0 / 0.000s
Local search heuristic = 4 / 0 / 0.005s
===========================================================================
Artelys Knitro 16.0.0:
=======================================
Commercial License
Artelys Knitro 16.0.0
=======================================
Knitro changing mip_method from AUTO to 1.
No start point provided -- Knitro computing one.
Knitro presolve eliminated 0 variables (0%) and 0 constraints (0%) in 0.00s.
concurrent_evals 0
datacheck 0
feastol 1e-06
feastol_abs 1e-06
findiff_numthreads 1
hessian_no_f 1
hessopt 1
opttol 1e-06
opttol_abs 0.001
Knitro changing mip_root_nlpalg from AUTO to 1.
Knitro changing mip_node_nlpalg from AUTO to 1.
Knitro changing mip_branchrule from AUTO to 2.
Knitro changing mip_selectrule from AUTO to 2.
Knitro changing mip_mir from AUTO to 2.
Knitro changing mip_clique from AUTO to 0.
Knitro changing mip_zerohalf from AUTO to 0.
Knitro changing mip_liftproject from AUTO to 0.
Knitro changing mip_knapsack from AUTO to 2.
Knitro changing mip_gomory from AUTO to 1.
Knitro changing mip_cut_flowcover from AUTO to 2.
Knitro changing mip_cut_probing from AUTO to 1.
Knitro changing mip_rounding from AUTO to 3.
Knitro changing mip_heuristic_strategy from AUTO to 1.
Knitro changing mip_heuristic_feaspump from AUTO to 1.
Knitro changing mip_heuristic_misqp from AUTO to 0.
Knitro changing mip_heuristic_mpec from AUTO to 1.
Knitro changing mip_heuristic_diving from AUTO to 1926.
Knitro changing mip_heuristic_fixpropagate from AUTO to 62.
Knitro changing mip_heuristic_lns from AUTO to 0.
Knitro changing mip_heuristic_localsearch from AUTO to 1.
Knitro changing mip_pseudoinit from AUTO to 1.
Problem Characteristics | Presolved
-----------------------
Problem type: convex MIQCQP
Objective: maximize / linear
Number of variables: 40 | 40
bounds: lower upper range | lower upper range
20 0 20 | 20 0 20
free fixed | free fixed
0 0 | 0 0
cont. binary integer | cont. binary integer
30 10 0 | 30 10 0
Number of constraints: 12 | 12
eq. ineq. range | eq. ineq. range
linear: 11 0 0 | 11 0 0
quadratic: 0 1 0 | 0 1 0
Number of nonzeros:
objective Jacobian Hessian | objective Jacobian Hessian
linear: 10 70 | 10 70
quadratic: 0 10 55 | 0 10 55
total: 10 80 55 | 10 80 55
Knitro using Branch and Bound method with 8 threads.
Initial points
--------------
No initial point provided for the root node relaxation.
No primal point provided for the MIP.
Coefficient range:
linear objective: [3e-01, 7e+01] | [3e-01, 7e+01]
linear constraints: [1e-01, 1e+00] | [1e-01, 1e+00]
quadratic objective: [0e+00, 0e+00] | [0e+00, 0e+00]
quadratic constraints: [2e-02, 1e+01] | [2e-02, 1e+01]
variable bounds: [1e+00, 1e+00] | [1e+00, 1e+00]
constraint bounds: [1e-01, 1e+00] | [1e-01, 1e+00]
Root node relaxation
--------------------
Iter Objective Feasibility Optimality Time
error error (secs)
---- --------- ----------- ---------- ------
0 -7.62974e-03 0.364187 19.4142 0.082
1 3.98992 0.333356 0.664342 0.082
2 5.94883 2.48582e-02 0.310294 0.083
3 9.59832 4.03893e-05 0.141280 0.083
4 10.0598 1.91230e-07 6.32686e-03 0.083
5 10.0688 9.55942e-10 4.22042e-05 0.083
6 10.0688 8.92619e-14 4.02706e-09 0.083
7 10.0688 2.77556e-17 1.77636e-15 0.085
Tree search
-----------
Nodes Best solution Best bound Gap Time
Expl | Unexpl value value (secs)
--------------- ------------- ---------- --- ------
1 0 10.0688 LEAF 10.0688 0.00% 0.085
EXIT: Optimal solution found.
Final Statistics for MIP
------------------------
Final objective value = 1.00688089999999981e+01
Final bound value = 1.00688089999999981e+01
Final optimality gap (abs / rel) = 0.00000e+00 / 0.00000e+00 (0.00%)
# of root cutting plane rounds = 0
# of restarts = 0
# of nodes processed = 1 (0.084s)
# of strong branching evaluations = 0 (0.000s)
# of function evaluations = 0 (0.000s)
# of gradient evaluations = 0 (0.000s)
# of hessian evaluations = 0 (0.000s)
# of hessian-vector evaluations = 0
# of subproblems processed = 1 (0.084s)
Total program time (secs) = 0.08503 (0.021 CPU time)
Time spent in evaluations (secs) = 0.00000
Cuts statistics (gen / add)
---------------------------
Knapsack cuts = 0 / 0
Mixed-integer rounding cuts = 0 / 0
Gomory cuts = 0 / 0
Flow-cover cuts = 0 / 0
Probing cuts = 0 / 0
Heuristics statistics (calls / successes / time)
------------------------------------------------
Feasibility pump = 0 / 0 / 0.000s
Rounding heuristic = 0 / 0 / 0.000s
MPEC heuristic = 0 / 0 / 0.000s
Local search heuristic = 5 / 1 / 0.009s
===========================================================================
Artelys Knitro 16.0.0:
=======================================
Commercial License
Artelys Knitro 16.0.0
=======================================
Knitro changing mip_method from AUTO to 1.
No start point provided -- Knitro computing one.
Knitro presolve eliminated 0 variables (0%) and 0 constraints (0%) in 0.00s.
concurrent_evals 0
datacheck 0
feastol 1e-06
feastol_abs 1e-06
findiff_numthreads 1
hessian_no_f 1
hessopt 1
opttol 1e-06
opttol_abs 0.001
Knitro changing mip_root_nlpalg from AUTO to 1.
Knitro changing mip_node_nlpalg from AUTO to 1.
Knitro changing mip_branchrule from AUTO to 2.
Knitro changing mip_selectrule from AUTO to 2.
Knitro changing mip_mir from AUTO to 2.
Knitro changing mip_clique from AUTO to 0.
Knitro changing mip_zerohalf from AUTO to 0.
Knitro changing mip_liftproject from AUTO to 0.
Knitro changing mip_knapsack from AUTO to 2.
Knitro changing mip_gomory from AUTO to 1.
Knitro changing mip_cut_flowcover from AUTO to 2.
Knitro changing mip_cut_probing from AUTO to 1.
Knitro changing mip_rounding from AUTO to 3.
Knitro changing mip_heuristic_strategy from AUTO to 1.
Knitro changing mip_heuristic_feaspump from AUTO to 1.
Knitro changing mip_heuristic_misqp from AUTO to 0.
Knitro changing mip_heuristic_mpec from AUTO to 1.
Knitro changing mip_heuristic_diving from AUTO to 1926.
Knitro changing mip_heuristic_fixpropagate from AUTO to 62.
Knitro changing mip_heuristic_lns from AUTO to 0.
Knitro changing mip_heuristic_localsearch from AUTO to 1.
Knitro changing mip_pseudoinit from AUTO to 1.
Problem Characteristics | Presolved
-----------------------
Problem type: convex MIQCQP
Objective: maximize / linear
Number of variables: 40 | 40
bounds: lower upper range | lower upper range
20 0 20 | 20 0 20
free fixed | free fixed
0 0 | 0 0
cont. binary integer | cont. binary integer
30 10 0 | 30 10 0
Number of constraints: 12 | 12
eq. ineq. range | eq. ineq. range
linear: 11 0 0 | 11 0 0
quadratic: 0 1 0 | 0 1 0
Number of nonzeros:
objective Jacobian Hessian | objective Jacobian Hessian
linear: 10 70 | 10 70
quadratic: 0 10 55 | 0 10 55
total: 10 80 55 | 10 80 55
Knitro using Branch and Bound method with 8 threads.
Initial points
--------------
No initial point provided for the root node relaxation.
No primal point provided for the MIP.
Coefficient range:
linear objective: [3e-01, 7e+01] | [3e-01, 7e+01]
linear constraints: [1e-01, 1e+00] | [1e-01, 1e+00]
quadratic objective: [0e+00, 0e+00] | [0e+00, 0e+00]
quadratic constraints: [2e-02, 1e+01] | [2e-02, 1e+01]
variable bounds: [1e+00, 1e+00] | [1e+00, 1e+00]
constraint bounds: [1e-01, 1e+00] | [1e-01, 1e+00]
Root node relaxation
--------------------
Iter Objective Feasibility Optimality Time
error error (secs)
---- --------- ----------- ---------- ------
0 -7.62974e-03 0.317184 10.7696 0.076
1 6.91462 0.260444 0.587992 0.076
2 11.3794 1.35052e-02 0.263147 0.076
3 12.8865 1.65538e-04 8.61060e-02 0.076
4 13.2485 8.32667e-16 4.30413e-02 0.076
5 13.3704 2.22045e-16 7.29059e-04 0.077
6 13.3722 8.88178e-16 8.92674e-07 0.077
7 13.3722 1.00108e-10 1.00108e-10 0.077
8 13.3722 2.77556e-17 2.75806e-11 0.078
Tree search
-----------
Nodes Best solution Best bound Gap Time
Expl | Unexpl value value (secs)
--------------- ------------- ---------- --- ------
1 0 13.3722 LEAF 13.3722 0.00% 0.078
EXIT: Optimal solution found.
Final Statistics for MIP
------------------------
Final objective value = 1.33721742807601309e+01
Final bound value = 1.33721742807601309e+01
Final optimality gap (abs / rel) = 0.00000e+00 / 0.00000e+00 (0.00%)
# of root cutting plane rounds = 0
# of restarts = 0
# of nodes processed = 1 (0.076s)
# of strong branching evaluations = 0 (0.000s)
# of function evaluations = 0 (0.000s)
# of gradient evaluations = 0 (0.000s)
# of hessian evaluations = 0 (0.000s)
# of hessian-vector evaluations = 0
# of subproblems processed = 1 (0.076s)
Total program time (secs) = 0.07796 (0.027 CPU time)
Time spent in evaluations (secs) = 0.00000
Cuts statistics (gen / add)
---------------------------
Knapsack cuts = 0 / 0
Mixed-integer rounding cuts = 0 / 0
Gomory cuts = 0 / 0
Flow-cover cuts = 0 / 0
Probing cuts = 0 / 0
Heuristics statistics (calls / successes / time)
------------------------------------------------
Feasibility pump = 0 / 0 / 0.000s
Rounding heuristic = 0 / 0 / 0.000s
MPEC heuristic = 0 / 0 / 0.000s
Local search heuristic = 4 / 0 / 0.006s
===========================================================================
Artelys Knitro 16.0.0:
=======================================
Commercial License
Artelys Knitro 16.0.0
=======================================
Knitro changing mip_method from AUTO to 1.
No start point provided -- Knitro computing one.
Knitro presolve eliminated 0 variables (0%) and 0 constraints (0%) in 0.00s.
concurrent_evals 0
datacheck 0
feastol 1e-06
feastol_abs 1e-06
findiff_numthreads 1
hessian_no_f 1
hessopt 1
opttol 1e-06
opttol_abs 0.001
Knitro changing mip_root_nlpalg from AUTO to 1.
Knitro changing mip_node_nlpalg from AUTO to 1.
Knitro changing mip_branchrule from AUTO to 2.
Knitro changing mip_selectrule from AUTO to 2.
Knitro changing mip_mir from AUTO to 2.
Knitro changing mip_clique from AUTO to 0.
Knitro changing mip_zerohalf from AUTO to 0.
Knitro changing mip_liftproject from AUTO to 0.
Knitro changing mip_knapsack from AUTO to 2.
Knitro changing mip_gomory from AUTO to 1.
Knitro changing mip_cut_flowcover from AUTO to 2.
Knitro changing mip_cut_probing from AUTO to 1.
Knitro changing mip_rounding from AUTO to 3.
Knitro changing mip_heuristic_strategy from AUTO to 1.
Knitro changing mip_heuristic_feaspump from AUTO to 1.
Knitro changing mip_heuristic_misqp from AUTO to 0.
Knitro changing mip_heuristic_mpec from AUTO to 1.
Knitro changing mip_heuristic_diving from AUTO to 1926.
Knitro changing mip_heuristic_fixpropagate from AUTO to 62.
Knitro changing mip_heuristic_lns from AUTO to 0.
Knitro changing mip_heuristic_localsearch from AUTO to 1.
Knitro changing mip_pseudoinit from AUTO to 1.
Problem Characteristics | Presolved
-----------------------
Problem type: convex MIQCQP
Objective: maximize / linear
Number of variables: 40 | 40
bounds: lower upper range | lower upper range
20 0 20 | 20 0 20
free fixed | free fixed
0 0 | 0 0
cont. binary integer | cont. binary integer
30 10 0 | 30 10 0
Number of constraints: 12 | 12
eq. ineq. range | eq. ineq. range
linear: 11 0 0 | 11 0 0
quadratic: 0 1 0 | 0 1 0
Number of nonzeros:
objective Jacobian Hessian | objective Jacobian Hessian
linear: 10 50 | 10 50
quadratic: 0 10 55 | 0 10 55
total: 10 60 55 | 10 60 55
Knitro using Branch and Bound method with 8 threads.
Initial points
--------------
No initial point provided for the root node relaxation.
No primal point provided for the MIP.
Coefficient range:
linear objective: [3e-01, 7e+01] | [3e-01, 7e+01]
linear constraints: [1e-01, 1e+00] | [1e-01, 1e+00]
quadratic objective: [0e+00, 0e+00] | [0e+00, 0e+00]
quadratic constraints: [2e-02, 1e+01] | [2e-02, 1e+01]
variable bounds: [1e+00, 1e+00] | [1e+00, 1e+00]
constraint bounds: [1e-01, 1e+00] | [1e-01, 1e+00]
Root node relaxation
--------------------
Iter Objective Feasibility Optimality Time
error error (secs)
---- --------- ----------- ---------- ------
0 1.07154 0.200051 7.50038 0.089
1 9.79002 0.120932 0.388346 0.090
2 14.2446 0.319891 0.408473 0.090
3 13.6138 2.13718e-15 2.40526 0.090
4 14.0610 1.99007e-14 0.748949 0.090
5 14.3271 1.76558e-03 0.319652 0.090
6 14.3338 1.99007e-14 9.79942e-03 0.090
7 14.3373 5.60835e-06 1.53343e-03 0.091
8 14.3373 7.62465e-09 3.17274e-06 0.091
9 14.3373 1.00077e-10 1.00077e-10 0.091
10 14.3373 2.27318e-14 1.51776e-09 0.093
Tree search
-----------
Nodes Best solution Best bound Gap Time
Expl | Unexpl value value (secs)
--------------- ------------- ---------- --- ------
1 2 14.3245 FCRD 14.3373 0.09% 0.097
7 2 14.3245 MPEC 14.3373 0.09% 0.110
21 0 14.3245 14.3260 0.01% 0.129
EXIT: Optimal solution found.
Final Statistics for MIP
------------------------
Final objective value = 1.43245316808270431e+01
Final bound value = 1.43259641331530698e+01
Final optimality gap (abs / rel) = 1.43245e-03 / 9.99999e-05 (0.01%)
# of root cutting plane rounds = 1
# of restarts = 0
# of nodes processed = 21 (0.138s)
# of strong branching evaluations = 0 (0.000s)
# of function evaluations = 0 (0.000s)
# of gradient evaluations = 0 (0.000s)
# of hessian evaluations = 0 (0.000s)
# of hessian-vector evaluations = 0
# of subproblems processed = 28 (0.157s)
Total program time (secs) = 0.12912 (0.161 CPU time)
Time spent in evaluations (secs) = 0.00000
Cuts statistics (gen / add)
---------------------------
Knapsack cuts = 0 / 0
Mixed-integer rounding cuts = 0 / 0
Gomory cuts = 0 / 0
Flow-cover cuts = 0 / 0
Probing cuts = 0 / 0
Heuristics statistics (calls / successes / time)
------------------------------------------------
Feasibility pump = 1 / 0 / 0.004s
Rounding heuristic = 1 / 1 / 0.003s
MPEC heuristic = 1 / 1 / 0.005s
Local search heuristic = 7 / 3 / 0.028s
===========================================================================
draw_comparison(
[initial] + rebalanced,
[f"Initial, Return {initial.expected_return:.2f}"]
+ [
f"Variable cost {v}, Return {s.expected_return:.2f}"
for v, s in zip(variable_costs, rebalanced)
],
nasdaq.names,
"Rebalancing an equally weighted portfolio",
)When transaction costs are taken into account, assets with negative expected returns are removed from the portfolio, because the costs associated with trading prevent extensive diversification, making it impractical to include assets that do not contribute positively to the portfolio’s overall return. The lower the variable cost, the further the portfolio can move from its initial allocation.
Optimizing portfolios with a large number of assets
In this section, we test the baseline model with a large number of assets. Despite the increased complexity, we expect to solve the optimization problem successfully using Knitro. The data is taken from the top 100 companies listed on the Australian Securities Exchange (ASX).
asx = load_market("asx.csv", "Top 100 of the Australian Securities Exchange")large = [solve(asx, markowitz, desired_return=r) for r in [5.0, 7.5, 10.0, 15.0]]Show the full outputHide the full output
Artelys Knitro 16.0.0:
=======================================
Commercial License
Artelys Knitro 16.0.0
=======================================
Knitro using 1 thread.
No start point provided -- Knitro computing one.
Knitro presolve eliminated 0 variables (0%) and 0 constraints (0%) in 0.00s.
concurrent_evals 0
datacheck 0
feastol 1e-06
feastol_abs 0.001
findiff_numthreads 1
hessian_no_f 1
hessopt 1
opttol 1e-06
opttol_abs 0.001
Knitro running advanced initialization strategy specified by initpt_strategy.
Problem Characteristics | Presolved
-----------------------
Problem type: convex QP
Objective: minimize / quadratic
Number of variables: 100 | 100
bounds: lower upper range | lower upper range
0 0 100 | 0 0 100
free fixed | free fixed
0 0 | 0 0
Number of constraints: 2 | 2
eq. ineq. range | eq. ineq. range
linear: 1 1 0 | 1 1 0
quadratic: 0 0 0 | 0 0 0
Number of nonzeros:
objective Jacobian Hessian | objective Jacobian Hessian
linear: 0 200 | 0 200
quadratic: 100 0 5050 | 100 0 5050
total: 100 200 5050 | 100 200 5050
Coefficient range:
linear objective: [0e+00, 0e+00] | [0e+00, 0e+00]
linear constraints: [3e-02, 2e+01] | [3e-02, 2e+01]
quadratic objective: [8e-04, 2e+01] | [8e-04, 2e+01]
quadratic constraints: [0e+00, 0e+00] | [0e+00, 0e+00]
variable bounds: [1e+00, 1e+00] | [1e+00, 1e+00]
constraint bounds: [1e+00, 5e+00] | [1e+00, 5e+00]
Knitro using the Interior-Point/Barrier Direct algorithm.
Iter Objective FeasError OptError ||Step|| Time
-------- -------------- --------- --------- --------- --------
0 3.247304e+00 3.37e+00
10 2.108031e-01 4.44e-16 5.25e-07 2.31e-03 0.02
EXIT: Optimal solution found.
HINT: Knitro spent 3.5% of solution time (0.000523 secs) checking model
convexity. To skip the automatic convexity checker for QPs and QCQPs,
explicity set the user option convex=0 or convex=1.
Final Statistics
----------------
Final objective value = 2.10803066843171e-01
Final feasibility error (abs / rel) = 4.44e-16 / 9.64e-18
Final optimality error (abs / rel) = 5.25e-07 / 4.10e-07
# of iterations = 10
# of CG iterations = 0
# of function evaluations = 0
# of gradient evaluations = 0
# of Hessian evaluations = 0
Total program time (secs) = 0.01517 ( 0.012 CPU time)
Time spent in evaluations (secs) = 0.00000
================================================================================
Artelys Knitro 16.0.0:
=======================================
Commercial License
Artelys Knitro 16.0.0
=======================================
Knitro using 1 thread.
No start point provided -- Knitro computing one.
Knitro presolve eliminated 0 variables (0%) and 0 constraints (0%) in 0.00s.
concurrent_evals 0
datacheck 0
feastol 1e-06
feastol_abs 0.001
findiff_numthreads 1
hessian_no_f 1
hessopt 1
opttol 1e-06
opttol_abs 0.001
Knitro running advanced initialization strategy specified by initpt_strategy.
Problem Characteristics | Presolved
-----------------------
Problem type: convex QP
Objective: minimize / quadratic
Number of variables: 100 | 100
bounds: lower upper range | lower upper range
0 0 100 | 0 0 100
free fixed | free fixed
0 0 | 0 0
Number of constraints: 2 | 2
eq. ineq. range | eq. ineq. range
linear: 1 1 0 | 1 1 0
quadratic: 0 0 0 | 0 0 0
Number of nonzeros:
objective Jacobian Hessian | objective Jacobian Hessian
linear: 0 200 | 0 200
quadratic: 100 0 5050 | 100 0 5050
total: 100 200 5050 | 100 200 5050
Coefficient range:
linear objective: [0e+00, 0e+00] | [0e+00, 0e+00]
linear constraints: [3e-02, 2e+01] | [3e-02, 2e+01]
quadratic objective: [8e-04, 2e+01] | [8e-04, 2e+01]
quadratic constraints: [0e+00, 0e+00] | [0e+00, 0e+00]
variable bounds: [1e+00, 1e+00] | [1e+00, 1e+00]
constraint bounds: [1e+00, 8e+00] | [1e+00, 8e+00]
Knitro using the Interior-Point/Barrier Direct algorithm.
Iter Objective FeasError OptError ||Step|| Time
-------- -------------- --------- --------- --------- --------
0 3.501597e+00 4.85e+00
10 2.412573e-01 2.22e-16 1.58e-06 1.35e-03 0.02
11 2.412571e-01 0.00e+00 1.45e-10 1.21e-04 0.02
EXIT: Optimal solution found.
HINT: Knitro spent 8.8% of solution time (0.001746 secs) checking model
convexity. To skip the automatic convexity checker for QPs and QCQPs,
explicity set the user option convex=0 or convex=1.
Final Statistics
----------------
Final objective value = 2.41257143933544e-01
Final feasibility error (abs / rel) = 0.00e+00 / 0.00e+00
Final optimality error (abs / rel) = 1.45e-10 / 1.27e-10
# of iterations = 11
# of CG iterations = 0
# of function evaluations = 0
# of gradient evaluations = 0
# of Hessian evaluations = 0
Total program time (secs) = 0.01983 ( 0.016 CPU time)
Time spent in evaluations (secs) = 0.00000
================================================================================
Artelys Knitro 16.0.0:
=======================================
Commercial License
Artelys Knitro 16.0.0
=======================================
Knitro using 1 thread.
No start point provided -- Knitro computing one.
Knitro presolve eliminated 0 variables (0%) and 0 constraints (0%) in 0.00s.
concurrent_evals 0
datacheck 0
feastol 1e-06
feastol_abs 0.001
findiff_numthreads 1
hessian_no_f 1
hessopt 1
opttol 1e-06
opttol_abs 0.001
Knitro running advanced initialization strategy specified by initpt_strategy.
Problem Characteristics | Presolved
-----------------------
Problem type: convex QP
Objective: minimize / quadratic
Number of variables: 100 | 100
bounds: lower upper range | lower upper range
0 0 100 | 0 0 100
free fixed | free fixed
0 0 | 0 0
Number of constraints: 2 | 2
eq. ineq. range | eq. ineq. range
linear: 1 1 0 | 1 1 0
quadratic: 0 0 0 | 0 0 0
Number of nonzeros:
objective Jacobian Hessian | objective Jacobian Hessian
linear: 0 200 | 0 200
quadratic: 100 0 5050 | 100 0 5050
total: 100 200 5050 | 100 200 5050
Coefficient range:
linear objective: [0e+00, 0e+00] | [0e+00, 0e+00]
linear constraints: [3e-02, 2e+01] | [3e-02, 2e+01]
quadratic objective: [8e-04, 2e+01] | [8e-04, 2e+01]
quadratic constraints: [0e+00, 0e+00] | [0e+00, 0e+00]
variable bounds: [1e+00, 1e+00] | [1e+00, 1e+00]
constraint bounds: [1e+00, 1e+01] | [1e+00, 1e+01]
Knitro using the Interior-Point/Barrier Direct algorithm.
Iter Objective FeasError OptError ||Step|| Time
-------- -------------- --------- --------- --------- --------
0 2.653082e+00 5.37e+00
9 3.220800e-01 6.66e-16 1.10e-07 9.30e-04 0.02
EXIT: Optimal solution found.
HINT: Knitro spent 4.0% of solution time (0.000791 secs) checking model
convexity. To skip the automatic convexity checker for QPs and QCQPs,
explicity set the user option convex=0 or convex=1.
Final Statistics
----------------
Final objective value = 3.22080025315401e-01
Final feasibility error (abs / rel) = 6.66e-16 / 1.45e-17
Final optimality error (abs / rel) = 1.10e-07 / 9.24e-08
# of iterations = 9
# of CG iterations = 0
# of function evaluations = 0
# of gradient evaluations = 0
# of Hessian evaluations = 0
Total program time (secs) = 0.01958 ( 0.015 CPU time)
Time spent in evaluations (secs) = 0.00000
================================================================================
Artelys Knitro 16.0.0:
=======================================
Commercial License
Artelys Knitro 16.0.0
=======================================
Knitro using 1 thread.
No start point provided -- Knitro computing one.
Knitro presolve eliminated 0 variables (0%) and 0 constraints (0%) in 0.00s.
concurrent_evals 0
datacheck 0
feastol 1e-06
feastol_abs 0.001
findiff_numthreads 1
hessian_no_f 1
hessopt 1
opttol 1e-06
opttol_abs 0.001
Knitro running advanced initialization strategy specified by initpt_strategy.
Problem Characteristics | Presolved
-----------------------
Problem type: convex QP
Objective: minimize / quadratic
Number of variables: 100 | 100
bounds: lower upper range | lower upper range
0 0 100 | 0 0 100
free fixed | free fixed
0 0 | 0 0
Number of constraints: 2 | 2
eq. ineq. range | eq. ineq. range
linear: 1 1 0 | 1 1 0
quadratic: 0 0 0 | 0 0 0
Number of nonzeros:
objective Jacobian Hessian | objective Jacobian Hessian
linear: 0 200 | 0 200
quadratic: 100 0 5050 | 100 0 5050
total: 100 200 5050 | 100 200 5050
Coefficient range:
linear objective: [0e+00, 0e+00] | [0e+00, 0e+00]
linear constraints: [3e-02, 2e+01] | [3e-02, 2e+01]
quadratic objective: [8e-04, 2e+01] | [8e-04, 2e+01]
quadratic constraints: [0e+00, 0e+00] | [0e+00, 0e+00]
variable bounds: [1e+00, 1e+00] | [1e+00, 1e+00]
constraint bounds: [1e+00, 2e+01] | [1e+00, 2e+01]
Knitro using the Interior-Point/Barrier Direct algorithm.
Iter Objective FeasError OptError ||Step|| Time
-------- -------------- --------- --------- --------- --------
0 2.367075e+00 5.36e+00
7 7.590161e-01 4.44e-16 5.27e-11 3.16e-05 0.01
EXIT: Optimal solution found.
HINT: Knitro spent 3.7% of solution time (0.000549 secs) checking model
convexity. To skip the automatic convexity checker for QPs and QCQPs,
explicity set the user option convex=0 or convex=1.
Final Statistics
----------------
Final objective value = 7.59016080822773e-01
Final feasibility error (abs / rel) = 4.44e-16 / 9.48e-18
Final optimality error (abs / rel) = 5.27e-11 / 2.36e-11
# of iterations = 7
# of CG iterations = 0
# of function evaluations = 0
# of gradient evaluations = 0
# of Hessian evaluations = 0
Total program time (secs) = 0.01480 ( 0.012 CPU time)
Time spent in evaluations (secs) = 0.00000
================================================================================
draw_comparison(
large,
[f"Return {r}, Risk {s.risk:.2f}" for r, s in zip([5.0, 7.5, 10.0, 15.0], large)],
asx.names,
"Selected assets among the 100 available",
threshold=0.05,
)As the figure shows, only a handful of assets are selected to minimize the risk for these desired returns, and the convex QP is still solved to global optimality.