LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
line_opt_solver.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2012-2026, QORE Lab, Imperial College London
3 * All rights reserved.
4 */
5#ifndef LINE_OPT_LINE_OPT_SOLVER_H
6#define LINE_OPT_LINE_OPT_SOLVER_H
7
8/**
9 * @file
10 * @ingroup line_opt
11 * The optimizer: search the variable space for the best feasible point.
12 *
13 * `LineOptSolver` drives an `OptimizationProblem` with the strategy named by
14 * `LineOptSolverOptions::optimizer` -- `evolution` (differential evolution, the
15 * default, over the normalized [0,1] box) or a gradient method that uses the
16 * derivatives of `sensitivity.h` where they exist and finite differences where
17 * they do not. Constraints enter through the penalty of
18 * `Objective::evaluate_with_penalty`.
19 *
20 * `LineOptSolverOptions` carries the usual DE controls (`strategy`, `popsize`,
21 * the `mutation_low`/`mutation_high` dither, `recombination`, `tolerance`,
22 * `max_iterations`, `seed`), the stopping `time_limit`, and the finite-difference
23 * steps, which are separate for the flat and layered cases (`fd_step`,
24 * `fd_step_layered`) because an LQN demand and a service rate are not of
25 * comparable scale. `scenario_aggregation` says how a multi-scenario objective
26 * is combined -- `worst` by default, so a design is judged by its worst load
27 * rather than its average one. Every setter returns `*this`.
28 */
29
30#include <algorithm>
31#include <chrono>
32#include <cmath>
33#include <cstddef>
34#include <cstdint>
35#include <limits>
36#include <map>
37#include <optional>
38#include <set>
39#include <string>
40#include <utility>
41#include <vector>
42
44#include "line/opt/problem.h"
46#include "line/util/error.h"
47
48namespace line {
49namespace opt {
50
52 std::string strategy = "best1bin";
53 std::size_t popsize = 15;
54 double mutation_low = 0.5;
55 double mutation_high = 1.0;
56 double recombination = 0.7;
57 double tolerance = 0.01;
58 std::size_t max_iterations = 100;
59 double time_limit = 300.0;
60 std::optional<std::uint64_t> seed;
61 bool verbose = false;
62 double penalty_weight = 1e6;
63 std::string scenario_aggregation = "worst";
64 std::string optimizer = "evolution";
65 double fd_step = 1e-6;
66 double fd_step_layered = 1e-4;
67 std::size_t gradient_restarts = 4;
68 std::string lqn_gradient = "fd";
69 std::size_t fd_refresh = 5;
70 std::vector<std::string> frozen_layers;
71 /**
72 * SolverLN options for every LayeredNetwork evaluation (for example
73 * `warmstart = "mol"`); unset solves with SolverLN's defaults. A warm start
74 * lets SolverLN stop at its own tolerance instead of iterating to its
75 * iter_min floor (ceil(iter_max/4) passes), which is most of a cold solve's
76 * cost.
77 */
78 std::optional<ln::LnOptions> lqn_solver_options;
79
80 LineOptSolverOptions& set_strategy(std::string value) {
81 strategy = std::move(value);
82 return *this;
83 }
84 LineOptSolverOptions& set_popsize(std::size_t value) {
85 popsize = value;
86 return *this;
87 }
88 LineOptSolverOptions& set_mutation(double low, double high) {
89 mutation_low = low;
90 mutation_high = high;
91 return *this;
92 }
94 recombination = value;
95 return *this;
96 }
98 tolerance = value;
99 return *this;
100 }
102 max_iterations = value;
103 return *this;
104 }
106 time_limit = value;
107 return *this;
108 }
109 LineOptSolverOptions& set_seed(std::uint64_t value) {
110 seed = value;
111 return *this;
112 }
114 seed.reset();
115 return *this;
116 }
118 verbose = value;
119 return *this;
120 }
122 penalty_weight = value;
123 return *this;
124 }
126 scenario_aggregation = std::move(value);
127 return *this;
128 }
130 optimizer = std::move(value);
131 return *this;
132 }
134 fd_step = value;
135 return *this;
136 }
138 fd_step_layered = value;
139 return *this;
140 }
142 gradient_restarts = value;
143 return *this;
144 }
146 if (value != "fd" && value != "partial_sens" && value != "partial_plus_fd")
147 throw InputError("lqn_gradient must be 'fd', 'partial_sens', or 'partial_plus_fd'");
148 lqn_gradient = std::move(value);
149 return *this;
150 }
152 fd_refresh = value;
153 return *this;
154 }
155 LineOptSolverOptions& set_frozen_layers(std::vector<std::string> value) {
156 frozen_layers = std::move(value);
157 return *this;
158 }
160 lqn_solver_options = std::move(value);
161 return *this;
162 }
163};
164
166public:
169 : problem_(problem), options_(std::move(options)), solve_(std::move(solve)) {
170 const std::vector<std::string> errors = problem_.validate();
171 if (!errors.empty()) throw InputError("LineOptSolver: invalid optimization problem");
172 free_variables_ = problem_.variables();
173 fixed_variables_ = problem_.fixed_variables();
174 freeze_layers();
175 for (const auto& item : fixed_variables_)
176 fixed_values_[item.first->name()] = item.second;
177
178 evaluators_.emplace_back(problem_.model_variant(), free_variables_, fixed_variables_, solve_);
179 scenario_weights_.push_back(1.0);
180 for (const Scenario& scenario : problem_.scenarios()) {
181 evaluators_.emplace_back(scenario.model, free_variables_, fixed_variables_, solve_);
182 scenario_weights_.push_back(scenario.weight);
183 }
184 if (options_.lqn_solver_options)
185 for (LineEvaluator& evaluator : evaluators_)
186 evaluator.set_lqn_solver_options(*options_.lqn_solver_options);
187 caches_.resize(evaluators_.size());
188 }
189
191 start_ = Clock::now();
192 iterations_ = 0;
193 best_value_ = std::numeric_limits<double>::infinity();
194 best_x_.clear();
195 convergence_history_.clear();
196 gradient_calls_ = 0;
197 lqn_sensitivity_cache_.clear();
198 resolved_seed_ = options_.seed.value_or(static_cast<std::uint64_t>(
199 std::chrono::duration_cast<std::chrono::nanoseconds>(
200 Clock::now().time_since_epoch()).count()) & UINT64_C(0x7fffffff));
201 for (auto& cache : caches_) cache.clear();
202
203 const std::vector<std::pair<double, double>> bounds = evaluators_[0].bounds();
204 if (bounds.empty()) return empty_result();
205 if (should_use_gradient()) return solve_gradient(bounds.size());
206 return solve_evolution(bounds.size());
207 }
208
209private:
210 using Clock = std::chrono::steady_clock;
211 struct TimeLimit {};
212
213 double elapsed() const {
214 return std::chrono::duration<double>(Clock::now() - start_).count();
215 }
216
217 VariableValues merge_values(const VariableValues& values) const {
218 VariableValues out = fixed_values_;
219 for (const auto& item : values) out[item.first] = item.second;
220 return out;
221 }
222
223 const EvaluationResult& evaluate(std::size_t scenario, const VariableValues& values) {
224 auto found = caches_[scenario].find(values);
225 if (found != caches_[scenario].end()) return found->second;
226 EvaluationResult result = evaluators_[scenario].evaluate(values);
227 return caches_[scenario].emplace(values, std::move(result)).first->second;
228 }
229
230 double aggregate_scenarios(const std::vector<double>& values) const {
231 if (values.size() == 1) return values[0];
232 if (options_.scenario_aggregation == "mean") {
233 double weighted = 0.0, weights = 0.0;
234 for (std::size_t i = 0; i < values.size(); ++i) {
235 weighted += scenario_weights_[i] * values[i];
236 weights += scenario_weights_[i];
237 }
238 return weighted / weights;
239 }
240 if (options_.scenario_aggregation != "worst")
241 throw InputError("LineOptSolver: unknown scenario aggregation '" +
242 options_.scenario_aggregation + "'");
243 return *std::max_element(values.begin(), values.end());
244 }
245
246 double objective_function(const std::vector<double>& x) {
247 if (elapsed() >= options_.time_limit) throw TimeLimit();
248 const VariableValues values = evaluators_[0].decode(x);
249 const VariableValues all_values = merge_values(values);
250 std::vector<double> scenario_values(evaluators_.size(), 0.0);
251 for (std::size_t i = 0; i < evaluators_.size(); ++i) {
252 const EvaluationResult& result = evaluate(i, values);
253 if (!result.feasible) return std::numeric_limits<double>::infinity();
254 double value = problem_.objective()->evaluate_with_penalty(
255 result, all_values, options_.penalty_weight);
256 for (const ConstraintPtr& constraint : problem_.constraints())
257 value += constraint->evaluate(result, all_values) * options_.penalty_weight;
258 scenario_values[i] = value;
259 }
260 const double total = aggregate_scenarios(scenario_values);
261 if (total < best_value_) {
262 best_value_ = total;
263 best_x_ = x;
264 }
265 return total;
266 }
267
268 OptimizationResult solve_evolution(std::size_t dimension) {
269 std::vector<double> low(dimension, 0.0), high(dimension, 1.0);
270 de::DifferentialEvolution engine(
271 [this](const std::vector<double>& x) { return objective_function(x); }, low, high,
272 options_.strategy, options_.popsize, options_.max_iterations,
273 options_.mutation_low, options_.mutation_high, options_.recombination,
274 options_.tolerance, resolved_seed_);
275 engine.set_callback([this](const std::vector<double>&, std::size_t nit) {
276 iterations_ = nit;
277 convergence_history_.push_back(best_value_);
278 return elapsed() >= options_.time_limit;
279 });
280
281 bool timed_out = false;
282 std::vector<double> x;
283 double value = std::numeric_limits<double>::infinity();
284 try {
285 const de::DifferentialEvolutionResult result = engine.solve();
286 if (!best_x_.empty() && best_value_ <= result.fun) {
287 x = best_x_;
288 value = best_value_;
289 } else {
290 x = result.x;
291 value = result.fun;
292 }
293 } catch (const TimeLimit&) {
294 timed_out = true;
295 if (best_x_.empty()) return empty_result();
296 x = best_x_;
297 value = best_value_;
298 }
299 OptimizationResult result = build_result(x, value);
300 if (timed_out) result.terminated_by = "time_limit";
301 return result;
302 }
303
304 bool all_continuous() const {
305 if (free_variables_.empty()) return false;
306 for (const VariablePtr& variable : free_variables_) {
307 const std::string type = variable->type();
308 if (type != "service_rate" && type != "routing" && type != "host_demand" &&
309 type != "think_time")
310 return false;
311 }
312 return true;
313 }
314
315 bool should_use_gradient() const {
316 if (options_.optimizer == "gradient") return true;
317 if (options_.optimizer == "evolution") return false;
318 if (options_.optimizer == "auto") return all_continuous();
319 throw InputError("LineOptSolver: unknown optimizer '" + options_.optimizer + "'");
320 }
321
322 std::vector<double> finite_difference_gradient(const std::vector<double>& x) {
323 const double h = evaluators_[0].is_layered() ? options_.fd_step_layered
324 : options_.fd_step;
325 std::vector<double> gradient(x.size(), 0.0);
326 std::optional<double> centre;
327 for (std::size_t i = 0; i < x.size(); ++i) {
328 std::vector<double> plus = x, minus = x;
329 plus[i] = std::min(1.0, x[i] + h);
330 minus[i] = std::max(0.0, x[i] - h);
331 const double fp = objective_function(plus);
332 const double fm = objective_function(minus);
333 if (std::isfinite(fp) && std::isfinite(fm) && plus[i] > minus[i]) {
334 gradient[i] = (fp - fm) / (plus[i] - minus[i]);
335 continue;
336 }
337 if (!centre) centre = objective_function(x);
338 if (std::isfinite(fp) && std::isfinite(*centre) && plus[i] > x[i])
339 gradient[i] = (fp - *centre) / (plus[i] - x[i]);
340 else if (std::isfinite(fm) && std::isfinite(*centre) && x[i] > minus[i])
341 gradient[i] = (*centre - fm) / (x[i] - minus[i]);
342 }
343 return gradient;
344 }
345
346 std::vector<double> projected_gradient_descent(std::vector<double> x) {
347 for (double& value : x) value = std::clamp(value, 0.0, 1.0);
348 double f = objective_function(x);
349 for (std::size_t iter = 0; iter < options_.max_iterations; ++iter) {
350 const std::vector<double> gradient = objective_gradient(x);
351 double norm2 = 0.0;
352 for (double value : gradient) norm2 += value * value;
353 if (std::sqrt(norm2) < 1e-9) break;
354 double step = 1.0;
355 bool improved = false;
356 for (std::size_t search = 0; search < 30; ++search) {
357 std::vector<double> next(x.size());
358 for (std::size_t i = 0; i < x.size(); ++i)
359 next[i] = std::clamp(x[i] - step * gradient[i], 0.0, 1.0);
360 const double fn = objective_function(next);
361 if (std::isfinite(fn) && fn < f - 1e-12) {
362 x = std::move(next);
363 f = fn;
364 improved = true;
365 break;
366 }
367 step *= 0.5;
368 }
369 if (!improved) break;
370 }
371 return x;
372 }
373
374 OptimizationResult solve_gradient(std::size_t dimension) {
375 const std::size_t starts = std::max<std::size_t>(1, options_.gradient_restarts);
376 de::NumpyRandomState random(resolved_seed_);
377 std::vector<double> best;
378 double best_fun = std::numeric_limits<double>::infinity();
379 bool timed_out = false;
380 for (std::size_t restart = 0; restart < starts; ++restart) {
381 if (elapsed() >= options_.time_limit) {
382 timed_out = true;
383 break;
384 }
385 std::vector<double> initial =
386 restart == 0 ? std::vector<double>(dimension, 0.5)
387 : random.uniform(0.0, 1.0, dimension);
388 try {
389 std::vector<double> candidate = projected_gradient_descent(initial);
390 const double value = objective_function(candidate);
391 if (std::isfinite(value) && value < best_fun) {
392 best = std::move(candidate);
393 best_fun = value;
394 }
395 } catch (const TimeLimit&) {
396 timed_out = true;
397 break;
398 }
399 }
400 if (best.empty() || (!best_x_.empty() && best_value_ < best_fun)) {
401 if (!best_x_.empty()) {
402 best = best_x_;
403 best_fun = best_value_;
404 } else {
405 return empty_result();
406 }
407 }
408 OptimizationResult result = build_result(best, best_fun);
409 if (timed_out) result.terminated_by = "time_limit";
410 return result;
411 }
412
413 void freeze_layers() {
414 if (!problem_.is_layered() || options_.frozen_layers.empty()) return;
415 const lqn::LqnModel<double>& model = problem_.layered_model();
416 std::set<std::string> frozen(options_.frozen_layers.begin(), options_.frozen_layers.end());
417 std::set<std::string> already;
418 for (const auto& fixed : fixed_variables_) already.insert(fixed.first->name());
419 std::vector<VariablePtr> kept;
420 for (const VariablePtr& variable : free_variables_) {
421 const std::vector<std::string> variable_layers = variable->layers(model);
422 bool intersects = false;
423 for (const std::string& layer : variable_layers)
424 if (frozen.find(layer) != frozen.end()) intersects = true;
425 if (!intersects) {
426 kept.push_back(variable);
427 continue;
428 }
429 if (already.find(variable->name()) != already.end()) continue;
430 const std::optional<Value> value = variable->current_value(model);
431 if (value) {
432 fixed_variables_.push_back({variable, *value});
433 already.insert(variable->name());
434 }
435 }
436 free_variables_ = std::move(kept);
437 }
438
439 std::vector<double> objective_gradient(const std::vector<double>& x) {
440 if (!evaluators_[0].is_layered()) return finite_difference_gradient(x);
441 const std::string& mode = options_.lqn_gradient;
442 if (mode == "partial_sens" || mode == "partial_plus_fd") {
443 ++gradient_calls_;
444 const std::size_t refresh = std::max<std::size_t>(1, options_.fd_refresh);
445 if (!(mode == "partial_plus_fd" && gradient_calls_ % refresh == 0)) {
446 const std::optional<std::vector<double>> gradient =
447 lqn_analytic_gradient(x);
448 if (gradient) return *gradient;
449 }
450 }
451 return finite_difference_gradient(x);
452 }
453
454 double scalar_objective(const EvaluationResult& result,
455 const VariableValues& values) const {
456 double out = problem_.objective()->evaluate_with_penalty(
457 result, values, options_.penalty_weight);
458 for (const ConstraintPtr& constraint : problem_.constraints())
459 out += constraint->evaluate(result, values) * options_.penalty_weight;
460 return out;
461 }
462
463 double scalar_metric_derivative(const EvaluationResult& base,
464 const VariableValues& values,
465 const std::string& kind,
466 const std::string& key) const {
467 const double h = options_.fd_step;
468 EvaluationResult plus = base, minus = base;
469 std::map<std::string, double>* plus_map = nullptr;
470 std::map<std::string, double>* minus_map = nullptr;
471 if (kind == "RespT") {
472 plus_map = &plus.response_times;
473 minus_map = &minus.response_times;
474 } else if (kind == "QLen") {
475 plus_map = &plus.queue_lengths;
476 minus_map = &minus.queue_lengths;
477 } else if (kind == "Tput") {
478 plus_map = &plus.throughputs;
479 minus_map = &minus.throughputs;
480 } else if (kind == "Util") {
481 plus_map = &plus.utilizations;
482 minus_map = &minus.utilizations;
483 } else {
484 return 0.0;
485 }
486 const auto found = plus_map->find(key);
487 if (found == plus_map->end()) return 0.0;
488 (*plus_map)[key] = found->second + h;
489 (*minus_map)[key] = found->second - h;
490 // The system metrics are precomputed from the reference task, so a perturbed activity
491 // metric must reach them or a system-level objective sees a zero gradient. One reference
492 // task: visits per cycle are X_act/X_ref, so d(sysRespT)/d(RespT_act) = X_act/X_ref and
493 // d(sysTput)/d(Tput_act) = X_ref/X_act. Several are not identified from the aggregates.
494 if ((kind == "RespT" || kind == "Tput") && base.system_throughputs.size() == 1) {
495 const auto act = base.throughputs.find(key);
496 const std::string& ref = base.system_throughputs.begin()->first;
497 const double x_ref = base.system_throughputs.begin()->second;
498 if (act != base.throughputs.end() && act->second > 0.0 && x_ref > 0.0) {
499 if (kind == "RespT") {
500 const auto sys = base.system_response_times.find(ref);
501 if (sys != base.system_response_times.end()) {
502 const double w = act->second / x_ref;
503 plus.system_response_times[ref] = sys->second + h * w;
504 minus.system_response_times[ref] = sys->second - h * w;
505 }
506 } else {
507 const double w = x_ref / act->second;
508 plus.system_throughputs[ref] = x_ref + h * w;
509 minus.system_throughputs[ref] = x_ref - h * w;
510 }
511 }
512 }
513 return (scalar_objective(plus, values) - scalar_objective(minus, values)) /
514 (2.0 * h);
515 }
516
517 std::optional<std::vector<double>> lqn_analytic_gradient(
518 const std::vector<double>& x) {
519 if (evaluators_.size() != 1 || free_variables_.empty()) return std::nullopt;
520 for (const VariablePtr& variable : free_variables_)
521 if (!variable->supports_sensitivity()) return std::nullopt;
522 const VariableValues values = evaluators_[0].decode(x);
523 const VariableValues all_values = merge_values(values);
524 const EvaluationResult& result = evaluate(0, values);
525 if (!result.feasible) return std::nullopt;
526
527 auto cached = lqn_sensitivity_cache_.find(values);
528 if (cached == lqn_sensitivity_cache_.end())
529 cached = lqn_sensitivity_cache_.emplace(
530 values, evaluators_[0].evaluate_layered_sensitivities(values)).first;
531 if (!cached->second) return std::nullopt;
532 const LineEvaluator::LayerSensitivityMap& sensitivities = *cached->second;
533 const lqn::LqnModel<double>& model = problem_.layered_model();
534 std::vector<double> gradient(x.size(), 0.0);
535 std::size_t offset = 0;
536 for (const VariablePtr& variable : free_variables_) {
537 auto row = sensitivities.end();
538 for (const std::string& key : variable->sensitivity_keys(model))
539 if ((row = sensitivities.find(key)) != sensitivities.end()) break;
540 if (row != sensitivities.end()) {
541 const std::map<std::string, std::string> targets =
542 variable->sensitivity_metric_targets(model);
543 double scalar_rate = 0.0;
544 const struct {
545 const char* kind;
546 double LayerSensitivity::*field;
547 } metrics[] = {{"Tput", &LayerSensitivity::throughput},
551 for (const auto& metric : metrics) {
552 const auto target = targets.find(metric.kind);
553 if (target == targets.end()) continue;
554 scalar_rate += scalar_metric_derivative(
555 result, all_values, metric.kind, target->second) *
556 row->second.*(metric.field);
557 }
558 const auto value = all_values.find(variable->name());
559 if (value != all_values.end())
560 gradient[offset] = scalar_rate * variable->rate_jacobian(value->second) *
561 variable->decode_jacobian(x[offset]);
562 }
563 offset += variable->dimension();
564 }
565 return gradient;
566 }
567
568 std::vector<ConstraintPtr> all_constraints() const {
569 std::vector<ConstraintPtr> constraints = problem_.objective()->constraints;
570 constraints.insert(constraints.end(), problem_.constraints().begin(),
571 problem_.constraints().end());
572 return constraints;
573 }
574
575 OptimizationResult build_result(const std::vector<double>& x, double objective_value) {
576 OptimizationResult out;
577 out.objective_value = objective_value;
578 out.variable_values = evaluators_[0].decode(x);
579 out.iterations = iterations_;
580 out.solve_time = elapsed();
581 out.convergence_history = convergence_history_;
582 for (const LineEvaluator& evaluator : evaluators_)
583 out.model_evaluations += evaluator.evaluation_count();
584
585 const VariableValues all_values = merge_values(out.variable_values);
586 out.feasible = true;
587 for (std::size_t i = 0; i < evaluators_.size(); ++i) {
588 const EvaluationResult& result = evaluate(i, out.variable_values);
589 if (!result.feasible) {
590 out.feasible = false;
591 continue;
592 }
593 for (const ConstraintPtr& constraint : all_constraints()) {
594 const double violation = constraint->evaluate(result, all_values);
595 if (violation > 0.0) {
596 out.feasible = false;
597 out.constraint_violations[constraint->name()] = std::max(
598 out.constraint_violations[constraint->name()], violation);
599 }
600 }
601 }
602 if (elapsed() >= options_.time_limit)
603 out.terminated_by = "time_limit";
604 else if (iterations_ >= options_.max_iterations)
605 out.terminated_by = "iterations";
606 else
607 out.terminated_by = "convergence";
608 return out;
609 }
610
611 OptimizationResult empty_result() const {
612 OptimizationResult out;
613 out.objective_value = 0.0;
614 out.feasible = true;
615 out.terminated_by = "empty";
616 return out;
617 }
618
619 const OptimizationProblem& problem_;
620 LineOptSolverOptions options_;
622 std::vector<VariablePtr> free_variables_;
623 std::vector<std::pair<VariablePtr, Value>> fixed_variables_;
624 VariableValues fixed_values_;
625 std::vector<LineEvaluator> evaluators_;
626 std::vector<double> scenario_weights_;
627 std::vector<std::map<VariableValues, EvaluationResult>> caches_;
628 Clock::time_point start_;
629 std::size_t iterations_ = 0;
630 double best_value_ = std::numeric_limits<double>::infinity();
631 std::vector<double> best_x_;
632 std::vector<double> convergence_history_;
633 std::size_t gradient_calls_ = 0;
634 std::uint64_t resolved_seed_ = 0;
635 std::map<VariableValues, std::optional<LineEvaluator::LayerSensitivityMap>>
636 lqn_sensitivity_cache_;
637};
638
639} // namespace opt
640} // namespace line
641
642#endif
Malformed or inconsistent input (dimensions, negative populations, ...): LINE:input:<kind>.
Definition error.h:103
InputError(const std::string &what)
Definition error.h:105
std::function< mva::AvgResult< double >( const qn::NetworkStruct< double > &)> SolveFunction
Definition evaluator.h:49
std::map< std::string, LayerSensitivity > LayerSensitivityMap
Definition evaluator.h:51
LineOptSolver(const OptimizationProblem &problem, LineOptSolverOptions options={}, LineEvaluator::SolveFunction solve={})
OptimizationResult solve()
std::vector< std::string > validate() const
Definition problem.h:79
const std::vector< VariablePtr > & variables() const
Definition problem.h:109
const std::vector< Scenario > & scenarios() const
Definition problem.h:113
const OptimizationModel & model_variant() const
Definition problem.h:108
const std::vector< std::pair< VariablePtr, Value > > & fixed_variables() const
Definition problem.h:112
Port of matlab/src/opt/+opt/+de/DifferentialEvolution.m.
The exception types the port throws.
double norm2(const std::vector< double > &v)
std::shared_ptr< Constraint > ConstraintPtr
Definition objectives.h:34
std::shared_ptr< DecisionVariable > VariablePtr
Definition variables.h:165
std::map< std::string, Value > VariableValues
Definition results.h:33
Mat plus(const Mat &A, const Mat &B)
Definition spn_ispn.h:155
Mat minus(const Mat &A, const Mat &B)
Definition spn_ispn.h:161
Conservation laws of a layered queueing network, enumerated from its structure.
Definition aoi_dist2ph.h:51
std::vector< T > solve(const Matrix< T > &A, const std::vector< T > &b)
Convenience: solve Ax = b, leaving A and b untouched.
Definition lu.h:158
The optimization problem: a model, the decision variables to search over, an objective,...
SolverLN: layered decomposition of a layered queueing network.
Options of SolverLN.
Definition solver_ln.h:275
LineOptSolverOptions & set_strategy(std::string value)
LineOptSolverOptions & set_penalty_weight(double value)
LineOptSolverOptions & set_gradient_restarts(std::size_t value)
std::vector< std::string > frozen_layers
LineOptSolverOptions & clear_seed()
LineOptSolverOptions & set_recombination(double value)
LineOptSolverOptions & set_mutation(double low, double high)
LineOptSolverOptions & set_scenario_aggregation(std::string value)
LineOptSolverOptions & set_fd_step(double value)
LineOptSolverOptions & set_lqn_solver_options(ln::LnOptions value)
LineOptSolverOptions & set_fd_refresh(std::size_t value)
LineOptSolverOptions & set_fd_step_layered(double value)
LineOptSolverOptions & set_frozen_layers(std::vector< std::string > value)
LineOptSolverOptions & set_lqn_gradient(std::string value)
LineOptSolverOptions & set_optimizer(std::string value)
LineOptSolverOptions & set_time_limit(double value)
LineOptSolverOptions & set_popsize(std::size_t value)
LineOptSolverOptions & set_seed(std::uint64_t value)
LineOptSolverOptions & set_tolerance(double value)
std::optional< std::uint64_t > seed
std::optional< ln::LnOptions > lqn_solver_options
SolverLN options for every LayeredNetwork evaluation (for example warmstart = "mol"); unset solves wi...
LineOptSolverOptions & set_max_iterations(std::size_t value)
LineOptSolverOptions & set_verbose(bool value)