Google OR-Tools
v9.12
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
drat_writer.cc
Go to the documentation of this file.
1
// Copyright 2010-2025 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/sat/drat_writer.h
"
15
16
#include <string>
17
#if !defined(__PORTABLE_PLATFORM__)
18
#include "
ortools/base/file.h
"
19
#include "
ortools/base/helpers.h
"
20
#include "
ortools/base/options.h
"
21
#endif
// !__PORTABLE_PLATFORM__
22
#include "absl/log/check.h"
23
#include "absl/strings/str_format.h"
24
#include "absl/types/span.h"
25
#include "
ortools/sat/sat_base.h
"
26
27
namespace
operations_research
{
28
namespace
sat
{
29
30
DratWriter::~DratWriter
() {
31
if
(output_ !=
nullptr
) {
32
#if !defined(__PORTABLE_PLATFORM__)
33
CHECK_OK(
file::WriteString
(output_, buffer_,
file::Defaults
()));
34
CHECK_OK(output_->Close(
file::Defaults
()));
35
#endif
// !__PORTABLE_PLATFORM__
36
}
37
}
38
39
void
DratWriter::AddClause
(absl::Span<const Literal> clause) {
40
WriteClause(clause);
41
}
42
43
void
DratWriter::DeleteClause
(absl::Span<const Literal> clause) {
44
buffer_ +=
"d "
;
45
WriteClause(clause);
46
}
47
48
void
DratWriter::WriteClause(absl::Span<const Literal> clause) {
49
for
(
const
Literal
literal : clause) {
50
absl::StrAppendFormat(&buffer_,
"%d "
, literal.SignedValue());
51
}
52
buffer_ +=
"0\n"
;
53
if
(buffer_.size() > 10000) {
54
#if !defined(__PORTABLE_PLATFORM__)
55
CHECK_OK(
file::WriteString
(output_, buffer_,
file::Defaults
()));
56
#endif
// !__PORTABLE_PLATFORM__
57
buffer_.clear();
58
}
59
}
60
61
}
// namespace sat
62
}
// namespace operations_research
file.h
operations_research::sat::DratWriter::~DratWriter
~DratWriter()
Definition
drat_writer.cc:30
operations_research::sat::DratWriter::DeleteClause
void DeleteClause(absl::Span< const Literal > clause)
Definition
drat_writer.cc:43
operations_research::sat::DratWriter::AddClause
void AddClause(absl::Span< const Literal > clause)
Definition
drat_writer.cc:39
operations_research::sat::Literal
Definition
sat_base.h:66
drat_writer.h
helpers.h
file::WriteString
absl::Status WriteString(File *file, absl::string_view contents, Options options)
Definition
file.cc:231
file::Defaults
Options Defaults()
Definition
file.h:107
operations_research::sat
Definition
routing_sat.cc:45
operations_research
In SWIG mode, we don't want anything besides these top-level includes.
Definition
binary_indexed_tree.h:21
options.h
sat_base.h
ortools
sat
drat_writer.cc
Generated by
1.13.2