Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
status.cc
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#include "ortools/glop/status.h"
15
16#include <string>
17#include <utility>
18
20
21namespace operations_research {
22namespace glop {
23
24Status::Status() : error_code_(GLOP_OK), error_message_() {}
25
26Status::Status(ErrorCode error_code, std::string error_message)
27 : error_code_(error_code),
28 error_message_(error_code == GLOP_OK ? "" : std::move(error_message)) {}
29
30std::string GetErrorCodeString(Status::ErrorCode error_code) {
31 switch (error_code) {
32 case Status::GLOP_OK:
33 return "GLOP_OK";
35 return "ERROR_LU";
37 return "ERROR_BOUND";
39 return "ERROR_NULL";
41 return "INVALID_PROBLEM";
42 }
43 // Fallback. We don't use "default:" so the compiler will return an error
44 // if we forgot one enum case above.
45 LOG(DFATAL) << "Invalid Status::ErrorCode " << error_code;
46 return "UNKNOWN Status::ErrorCode";
47}
48
49} // namespace glop
50} // namespace operations_research
ErrorCode
Possible kinds of errors.
Definition status.h:29
@ GLOP_OK
Not an error. Returned on success.
Definition status.h:31
@ ERROR_INVALID_PROBLEM
The linear program is invalid or it does not have the required format.
Definition status.h:43
@ ERROR_NULL
A pointer argument was NULL when it shouldn't be.
Definition status.h:40
@ ERROR_LU
The LU factorization of the current basis couldn't be computed.
Definition status.h:34
@ ERROR_BOUND
The current variable values are out of their bound modulo the tolerance.
Definition status.h:37
Status()
Creates a "successful" status.
Definition status.cc:24
std::string GetErrorCodeString(Status::ErrorCode error_code)
Returns the string representation of the ErrorCode enum.
Definition status.cc:30
In SWIG mode, we don't want anything besides these top-level includes.
STL namespace.