Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
rays.h
Go to the documentation of this file.
1// Copyright 2010-2024 Google LLC
2// Licensed under the Apache License, Version 2.0 (the "License");
3// you may not use this file except in compliance with the License.
4// You may obtain a copy of the License at
5//
6// http://www.apache.org/licenses/LICENSE-2.0
7//
8// Unless required by applicable law or agreed to in writing, software
9// distributed under the License is distributed on an "AS IS" BASIS,
10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11// See the License for the specific language governing permissions and
12// limitations under the License.
13
14// This header defines primal/dual unboundness ray computation functions for
15// GLPK solver. They use the index space of the computation form of the model as
16// defined in operations_research/glpk/glpk_computational_form.h.
17#ifndef OR_TOOLS_MATH_OPT_SOLVERS_GLPK_RAYS_H_
18#define OR_TOOLS_MATH_OPT_SOLVERS_GLPK_RAYS_H_
19
20#include <optional>
21#include <utility>
22#include <vector>
23
24#include "absl/status/statusor.h"
25
26extern "C" {
27#include <glpk.h>
28}
29
31
32// The type of the GlpkRay.
34 // A primal ray.
35 //
36 // If x (vector of variables) is a primal feasible solution to a primal
37 // unbounded problem and r is the ray, then x' = x + t r is also a primal
38 // feasible solution for all t >= 0.
40
41 // A dual ray.
42 //
43 // If λ (vector of reduced costs) is a dual feasible solution to a dual
44 // unbounded problem and r is the ray, then λ' = λ + t r is also a dual
45 // feasible solution for all t >= 0.
47};
48
49// A primal or dual unbound ray for the model in computational form.
50//
51// See the top comment of operations_research/glpk/glpk_computational_form.h to
52// understand that the computational form is. This structure uses the word
53// "variable" to mean a variable in the joint set of structural and auxiliary
54// variables.
55struct GlpkRay {
56 using SparseVector = std::vector<std::pair<int, double>>;
57
59
60 // The type of ray, primal or dual.
62
63 // The non zero components of the vector, in no particular order.
64 //
65 // The first member of the pair is the index of the variable (or of its
66 // corresponding reduced cost) and the second is the component's value.
67 //
68 // A given index can only appear once.
69 //
70 // The indices in GLPK are one-based. Here the indices are defined by:
71 // - if 1 <= k <= m: k is the index of the k-th auxiliary variable
72 // (a.k.a. row, a.k.a. constraint)
73 // - if m + 1 <= k <= m + n: k is the index of the (k-m)-th structural
74 // variable (a.k.a. column)
75 // Note that the value k = 0 is not used.
77};
78
79// Returns the primal or dual ray if one is identified by
80// glp_get_unbnd_ray(). Returns an error status if an internal error occurs.
81absl::StatusOr<std::optional<GlpkRay>> GlpkComputeUnboundRay(glp_prob* problem);
82
83} // namespace operations_research::math_opt
84
85#endif // OR_TOOLS_MATH_OPT_SOLVERS_GLPK_RAYS_H_
An object oriented wrapper for quadratic constraints in ModelStorage.
Definition gurobi_isv.cc:28
absl::StatusOr< std::optional< GlpkRay > > GlpkComputeUnboundRay(glp_prob *const problem)
Definition rays.cc:352
GlpkRayType
The type of the GlpkRay.
Definition rays.h:33
GlpkRay(GlpkRayType type, SparseVector non_zero_components)
Definition rays.cc:349
GlpkRayType type
The type of ray, primal or dual.
Definition rays.h:61
std::vector< std::pair< int, double > > SparseVector
Definition rays.h:56