huge sync with internal version

This commit is contained in:
lperron@google.com
2013-06-11 14:51:23 +00:00
parent 1749bbe14c
commit 72e547c935
37 changed files with 79 additions and 74 deletions

View File

@@ -1,4 +1,4 @@
// Copyright 2010-2012 Google
// Copyright 2010-2013 Google
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

View File

@@ -1,4 +1,4 @@
// Copyright 2010-2012 Google
// Copyright 2010-2013 Google
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
@@ -88,16 +88,17 @@ void Cryptoarithmetics() {
CHECK_EQ(r->Value(), 8);
CHECK_EQ(y->Value(), 2);
LG << "S=" << s->Value();
LG << "M=" << m->Value();
LG << "O=" << o->Value();
LG << "E=" << e->Value();
LG << "N=" << n->Value();
LG << "D=" << d->Value();
LG << "R=" << r->Value();
LG << "Y=" << y->Value();
LOG(INFO) << "S=" << s->Value();
LOG(INFO) << "M=" << m->Value();
LOG(INFO) << "O=" << o->Value();
LOG(INFO) << "E=" << e->Value();
LOG(INFO) << "N=" << n->Value();
LOG(INFO) << "D=" << d->Value();
LOG(INFO) << "R=" << r->Value();
LOG(INFO) << "Y=" << y->Value();
} else {
LG << "Cannot solve problem: number of failures " << solver.failures();
LOG(INFO) << "Cannot solve problem: number of failures "
<< solver.failures();
}
solver.EndSearch();
}

View File

@@ -1,4 +1,4 @@
// Copyright 2010-2012 Google
// Copyright 2010-2013 Google
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
@@ -204,7 +204,7 @@ void DisplayPlan(const RoutingModel& routing, const Assignment& plan) {
plan.Max(time_var));
}
}
LG << plan_output;
LOG(INFO) << plan_output;
}
int main(int argc, char **argv) {
@@ -277,7 +277,7 @@ int main(int argc, char **argv) {
if (solution != NULL) {
DisplayPlan(routing, *solution);
} else {
LG << "No solution found.";
LOG(INFO) << "No solution found.";
}
return 0;
}

View File

@@ -1,4 +1,4 @@
// Copyright 2010-2012 Google
// Copyright 2010-2013 Google
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

View File

@@ -1,4 +1,4 @@
// Copyright 2010-2012 Google
// Copyright 2010-2013 Google
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

View File

@@ -1,4 +1,4 @@
// Copyright 2010-2012 Google
// Copyright 2010-2013 Google
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

View File

@@ -1,4 +1,4 @@
// Copyright 2010-2012 Google
// Copyright 2010-2013 Google
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

View File

@@ -1,4 +1,4 @@
// Copyright 2010-2012 Google
// Copyright 2010-2013 Google
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

View File

@@ -1,4 +1,4 @@
// Copyright 2010-2012 Google
// Copyright 2010-2013 Google
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

View File

@@ -1,4 +1,4 @@
// Copyright 2010-2012 Google
// Copyright 2010-2013 Google
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

View File

@@ -1,4 +1,4 @@
// Copyright 2010-2012 Google
// Copyright 2010-2013 Google
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

View File

@@ -1,4 +1,4 @@
// Copyright 2010-2012 Google
// Copyright 2010-2013 Google
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
@@ -61,9 +61,9 @@ void MaxFeasibleFlow() {
LOG(INFO) << "Max Feasible Flow";
const int kNumNodes = 6;
const int kNumArcs = 9;
const NodeIndex kTail[kNumArcs] = { 0, 0, 0, 0, 1, 2, 3, 3, 4 };
const NodeIndex kHead[kNumArcs] = { 1, 2, 3, 4, 3, 4, 4, 5, 5 };
const FlowQuantity kCapacity[kNumArcs] = { 5, 8, 5, 3, 4, 5, 6, 6, 4 };
const NodeIndex kTail[kNumArcs] = { 0, 0, 0, 0, 1, 2, 3, 3, 4 };
const NodeIndex kHead[kNumArcs] = { 1, 2, 3, 4, 3, 4, 4, 5, 5 };
const FlowQuantity kCapacity[kNumArcs] = { 5, 8, 5, 3, 4, 5, 6, 6, 4 };
const FlowQuantity kExpectedFlow[kNumArcs] = { 1, 1, 5, 3, 1, 1, 0, 6, 4 };
const FlowQuantity kExpectedTotalFlow = 10;
StarGraph graph(kNumNodes, kNumArcs);
@@ -88,3 +88,4 @@ int main(int argc, char **argv) {
operations_research::MaxFeasibleFlow();
return 0;
}

View File

@@ -1,4 +1,4 @@
// Copyright 2010-2012 Google
// Copyright 2010-2013 Google
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

View File

@@ -1,4 +1,4 @@
// Copyright 2010-2012 Google
// Copyright 2010-2013 Google
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

View File

@@ -1,4 +1,4 @@
// Copyright 2010-2012 Google
// Copyright 2010-2013 Google
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

View File

@@ -1,4 +1,4 @@
// Copyright 2010-2012 Google
// Copyright 2010-2013 Google
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

View File

@@ -1,4 +1,4 @@
// Copyright 2010-2012 Google
// Copyright 2010-2013 Google
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

View File

@@ -1,4 +1,4 @@
// Copyright 2010-2012 Google
// Copyright 2010-2013 Google
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

View File

@@ -1,4 +1,4 @@
// Copyright 2010-2012 Google
// Copyright 2010-2013 Google
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

View File

@@ -1,4 +1,4 @@
// Copyright 2010-2012 Google
// Copyright 2010-2013 Google
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
@@ -32,6 +32,7 @@
//
// Search will be implemented as local search on the sequence variables.
#include "cpp/jobshop_ls.h"
#include <cstdio>
#include <cstdlib>
@@ -44,7 +45,6 @@
#include "constraint_solver/constraint_solver.h"
#include "constraint_solver/constraint_solveri.h"
#include "cpp/jobshop.h"
#include "cpp/jobshop_ls.h"
DEFINE_string(
data_file,

View File

@@ -1,4 +1,4 @@
// Copyright 2010-2012 Google
// Copyright 2010-2013 Google
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
@@ -10,7 +10,6 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// This model implements a simple jobshop problem.
//
// A jobshop is a standard scheduling problem where you must schedule a
@@ -34,15 +33,17 @@
#ifndef OR_TOOLS_EXAMPLES_JOBSHOP_LS_H_
#define OR_TOOLS_EXAMPLES_JOBSHOP_LS_H_
#include <cstdio>
#include <cstdlib>
#include "base/commandlineflags.h"
#include "base/commandlineflags.h"
#include "base/integral_types.h"
#include "base/logging.h"
#include "base/stringprintf.h"
#include "base/bitmap.h"
#include "base/strtoint.h"
#include "base/file.h"
#include "base/filelinereader.h"
#include "base/split.h"
#include "constraint_solver/constraint_solver.h"
#include "constraint_solver/constraint_solveri.h"

View File

@@ -1,4 +1,4 @@
// Copyright 2010-2012 Google
// Copyright 2010-2013 Google
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

View File

@@ -1,4 +1,4 @@
// Copyright 2010-2012 Google
// Copyright 2010-2013 Google
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
@@ -13,9 +13,11 @@
//
// Linear programming example that shows how to use the API.
#include "base/commandlineflags.h"
#include "base/commandlineflags.h"
#include "base/logging.h"
#include "linear_solver/linear_solver.h"
#include "linear_solver/linear_solver.pb.h"
namespace operations_research {
void RunLinearProgrammingExample(

View File

@@ -1,4 +1,4 @@
// Copyright 2010-2012 Google
// Copyright 2010-2013 Google
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

View File

@@ -1,4 +1,4 @@
// Copyright 2010-2012 Google
// Copyright 2010-2013 Google
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
@@ -52,7 +52,7 @@ void MagicSquare(int grid_size) {
const int sum = grid_size * (total_size + 1) / 2;
// create the variables
std::vector<IntVar*> vars;
solver.MakeIntVarArray(total_size, 1, total_size, "v", &vars);
solver.MakeIntVarArray(total_size, 1, total_size, "", &vars);
solver.AddConstraint(solver.MakeAllDifferent(vars));
// create the constraints
@@ -139,11 +139,11 @@ void MagicSquare(int grid_size) {
int64 v = vars[n * grid_size + m]->Value();
StringAppendF(&output, "%3lld ", v);
}
LG << output;
LOG(INFO) << output;
}
LG << "";
LOG(INFO) << "";
} else {
LG << "No solution found!";
LOG(INFO) << "No solution found!";
}
solver.EndSearch();
}

View File

@@ -1,4 +1,4 @@
// Copyright 2010-2012 Google
// Copyright 2010-2013 Google
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
@@ -285,7 +285,7 @@ int Run() {
CPModelProto model_proto;
RecordReader reader(file);
if (!(reader.ReadProtocolMessage(&model_proto) && reader.Close())) {
LOG(INFO) << "No model found in " << file->CreateFileName();
LOG(INFO) << "No model found in " << file->filename();
return kProblem;
}

View File

@@ -1,4 +1,4 @@
// Copyright 2010-2012 Google
// Copyright 2010-2013 Google
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

View File

@@ -1,4 +1,4 @@
// Copyright 2010-2012 Google
// Copyright 2010-2013 Google
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

View File

@@ -1,4 +1,4 @@
// Copyright 2010-2012 Google
// Copyright 2010-2013 Google
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

View File

@@ -1,4 +1,4 @@
// Copyright 2010-2012 Google
// Copyright 2010-2013 Google
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

View File

@@ -1,4 +1,4 @@
// Copyright 2010-2012 Google
// Copyright 2010-2013 Google
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
@@ -110,7 +110,7 @@ void DimacsAssignmentParser<GraphType>::ParseProblemLine(
NodeIndex num_nodes;
ArcIndex num_arcs;
if ((sscanf(line, "%*c%3s%d%d", // NOLINT
if ((sscanf(line, "%*c%3s%d%d",
problem_type,
&num_nodes,
&num_arcs) != 3) ||
@@ -131,7 +131,7 @@ void DimacsAssignmentParser<GraphType>::ParseProblemLine(
template <typename GraphType>
void DimacsAssignmentParser<GraphType>::ParseNodeLine(const char* line) {
NodeIndex node_id;
if (sscanf(line, "%*c%d", &node_id) != 1) { // NOLINT
if (sscanf(line, "%*c%d", &node_id) != 1) {
state_.bad = true;
state_.reason = "Syntax error in node desciption.";
state_.bad_line.reset(new string(line));
@@ -165,7 +165,7 @@ void DimacsAssignmentParser<GraphType>::ParseArcLine(
NodeIndex tail;
NodeIndex head;
CostValue cost;
if (sscanf(line, "%*c%d%d%lld", &tail, &head, &cost) != 3) { // NOLINT
if (sscanf(line, "%*c%d%d%lld", &tail, &head, &cost) != 3) {
state_.bad = true;
state_.reason = "Syntax error in arc descriptor.";
state_.bad_line.reset(new string(line));

View File

@@ -1,4 +1,4 @@
// Copyright 2010-2012 Google
// Copyright 2010-2013 Google
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
@@ -155,9 +155,9 @@ namespace {
// An inefficient but convenient method to parse a whitespace-separated list
// of integers. Returns true iff the input string was entirely valid and parsed.
bool SafeParseInt64Array(const string& str, std::vector<int64>* parsed_int) {
std::vector<string> items;
static const char kWhiteSpaces[] = " \t\n\v\f\r";
SplitStringUsing(str, kWhiteSpaces, &items);
std::vector<string> items = strings::Split(
str, strings::delimiter::AnyOf(kWhiteSpaces), strings::SkipEmpty());
parsed_int->assign(items.size(), 0);
for (int i = 0; i < items.size(); ++i) {
const char* item = items[i].c_str();
@@ -304,8 +304,8 @@ bool LoadAndSolve(const string& pdp_file) {
// Solve pickup and delivery problem.
const Assignment* assignment = routing.Solve(NULL);
if (NULL != assignment) {
LG << "Cost: " << assignment->ObjectiveValue();
LG << VerboseOutput(routing, *assignment, coords, service_times);
LOG(INFO) << "Cost: " << assignment->ObjectiveValue();
LOG(INFO) << VerboseOutput(routing, *assignment, coords, service_times);
return true;
}
return false;
@@ -316,7 +316,7 @@ bool LoadAndSolve(const string& pdp_file) {
int main(int argc, char **argv) {
google::ParseCommandLineFlags(&argc, &argv, true);
if (!operations_research::LoadAndSolve(FLAGS_pdp_file)) {
LG << "Error solving " << FLAGS_pdp_file;
LOG(INFO) << "Error solving " << FLAGS_pdp_file;
}
return 0;
}

View File

@@ -1,4 +1,4 @@
// Copyright 2010-2012 Google
// Copyright 2010-2013 Google
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

View File

@@ -1,4 +1,4 @@
// Copyright 2010-2012 Google
// Copyright 2010-2013 Google
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

View File

@@ -1,4 +1,4 @@
// Copyright 2010-2012 Google
// Copyright 2010-2013 Google
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

View File

@@ -1,4 +1,4 @@
// Copyright 2010-2012 Google
// Copyright 2010-2013 Google
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

View File

@@ -1,4 +1,4 @@
// Copyright 2010-2012 Google
// Copyright 2010-2013 Google
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
@@ -129,7 +129,7 @@ int main(int argc, char **argv) {
const int64 from = randomizer.Uniform(FLAGS_tsp_size - 1);
const int64 to = randomizer.Uniform(FLAGS_tsp_size - 1) + 1;
if (routing.NextVar(from)->Contains(to)) {
LG << "Forbidding connection " << from << " -> " << to;
LOG(INFO) << "Forbidding connection " << from << " -> " << to;
routing.NextVar(from)->RemoveValue(to);
++forbidden_connections;
}
@@ -138,7 +138,7 @@ int main(int argc, char **argv) {
const Assignment* solution = routing.Solve();
if (solution != NULL) {
// Solution cost.
LG << "Cost " << solution->ObjectiveValue();
LOG(INFO) << "Cost " << solution->ObjectiveValue();
// Inspect solution.
// Only one route here; otherwise iterate from 0 to routing.vehicles() - 1
const int route_number = 0;
@@ -149,12 +149,12 @@ int main(int argc, char **argv) {
route = StrCat(route, StrCat(node, " -> "));
}
route = StrCat(route, "0");
LG << route;
LOG(INFO) << route;
} else {
LG << "No solution found.";
LOG(INFO) << "No solution found.";
}
} else {
LG << "Specify an instance size greater than 0.";
LOG(INFO) << "Specify an instance size greater than 0.";
}
return 0;
}