minor improvements from internal code
This commit is contained in:
3
Makefile
3
Makefile
@@ -5,7 +5,8 @@ help:
|
||||
@echo " - mathematical programming: lplibs lpexe pylp javalp"
|
||||
@echo " - algorithms: algorithmslibs pyalgorithms javaalgorithms"
|
||||
@echo " - graph: graphlibs pygraph javagraph"
|
||||
@echo " - .NET on windows: csharp csharpcp csharplp csharpalgorithms csharpgraph csharpexe"
|
||||
@echo " - .NET on windows: csharp csharpcp csharplp csharpalgorithms"
|
||||
@echo " csharpgraph csharpexe"
|
||||
@echo " - misc: clean cleancsharp"
|
||||
|
||||
.PHONY : python cc java
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2010-2011 Google
|
||||
// Copyright 2010-2012 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
|
||||
@@ -28,10 +28,6 @@
|
||||
#endif // SWIGJAVA
|
||||
|
||||
#if defined(SWIGCSHARP)
|
||||
%rename (bestSolutionContains) operations_research::KnapsackSolver::BestSolutionContains;
|
||||
%rename (GetName) operations_research::KnapsackSolver::GetName;
|
||||
%rename (Init) operations_research::KnapsackSolver::Init;
|
||||
%rename (Solve) operations_research::KnapsackSolver::Solve;
|
||||
%rename (UseReduction) operations_research::KnapsackSolver::use_reduction;
|
||||
%rename (SetUseReduction) operations_research::KnapsackSolver::set_use_reduction;
|
||||
#endif // SWIGCSHARP
|
||||
|
||||
@@ -32,10 +32,10 @@ void RecordWriter::set_use_compression(bool use_compression) {
|
||||
}
|
||||
|
||||
std::string RecordWriter::Compress(std::string const& s) const {
|
||||
const unsigned long source_size = s.size();
|
||||
const unsigned long source_size = s.size(); // NOLINT
|
||||
const char * source = s.c_str();
|
||||
|
||||
unsigned long dsize = source_size + (source_size * 0.1f) + 16;
|
||||
unsigned long dsize = source_size + (source_size * 0.1f) + 16; // NOLINT
|
||||
scoped_ptr<char> destination(new char[dsize]);
|
||||
// Use compress() from zlib.h.
|
||||
const int result =
|
||||
@@ -58,7 +58,7 @@ void RecordReader::Uncompress(const char* const source,
|
||||
uint64 source_size,
|
||||
char* const output_buffer,
|
||||
uint64 output_size) const {
|
||||
unsigned long result_size = output_size;
|
||||
unsigned long result_size = output_size; // NOLINT
|
||||
// Use uncompress() from zlib.h
|
||||
const int result =
|
||||
uncompress(reinterpret_cast<unsigned char *>(output_buffer), &result_size,
|
||||
@@ -66,6 +66,6 @@ void RecordReader::Uncompress(const char* const source,
|
||||
if (result != Z_OK) {
|
||||
LOG(FATAL) << "Uncompress error occured! Error code: " << result;
|
||||
}
|
||||
CHECK_LE(result_size, static_cast<unsigned long>(output_size));
|
||||
CHECK_LE(result_size, static_cast<unsigned long>(output_size)); // NOLINT
|
||||
}
|
||||
} // namespace operations_research
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef UTIL_OPERATIONS_RESEARCH_OPEN_SOURCE_BASE_RECORDIO_H_
|
||||
#define UTIL_OPERATIONS_RESEARCH_OPEN_SOURCE_BASE_RECORDIO_H_
|
||||
#ifndef OR_TOOLS_BASE_RECORDIO_H_
|
||||
#define OR_TOOLS_BASE_RECORDIO_H_
|
||||
|
||||
#include <string>
|
||||
#include "base/file.h"
|
||||
@@ -132,4 +132,4 @@ class RecordReader {
|
||||
};
|
||||
} // namespace operations_research
|
||||
|
||||
#endif // UTIL_OPERATIONS_RESEARCH_OPEN_SOURCE_BASE_RECORDIO_H_
|
||||
#endif // OR_TOOLS_BASE_RECORDIO_H_
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2010-2011 Google
|
||||
// Copyright 2010-2012 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
|
||||
@@ -1842,75 +1842,75 @@ namespace operations_research {
|
||||
|
||||
// Add arithmetic operators to integer expressions.
|
||||
%typemap(cscode) IntExpr %{
|
||||
public static IntExpr operator+(IntExpr a, IntExpr b) {
|
||||
return a.solver().MakeSum(a, b);
|
||||
}
|
||||
public static IntExpr operator+(IntExpr a, long v) {
|
||||
return a.solver().MakeSum(a, v);
|
||||
}
|
||||
public static IntExpr operator+(long v, IntExpr a) {
|
||||
return a.solver().MakeSum(a, v);
|
||||
}
|
||||
public static IntExpr operator-(IntExpr a, IntExpr b) {
|
||||
return a.solver().MakeDifference(a, b);
|
||||
}
|
||||
public static IntExpr operator-(IntExpr a, long v) {
|
||||
return a.solver().MakeSum(a, -v);
|
||||
}
|
||||
public static IntExpr operator-(long v, IntExpr a) {
|
||||
return a.solver().MakeDifference(v, a);
|
||||
}
|
||||
public static IntExpr operator*(IntExpr a, IntExpr b) {
|
||||
return a.solver().MakeProd(a, b);
|
||||
}
|
||||
public static IntExpr operator*(IntExpr a, long v) {
|
||||
return a.solver().MakeProd(a, v);
|
||||
}
|
||||
public static IntExpr operator*(long v, IntExpr a) {
|
||||
return a.solver().MakeProd(a, v);
|
||||
}
|
||||
public static IntExpr operator/(IntExpr a, long v) {
|
||||
return a.solver().MakeDiv(a, v);
|
||||
}
|
||||
public static IntExpr operator-(IntExpr a) {
|
||||
return a.solver().MakeOpposite(a);
|
||||
}
|
||||
public IntExpr Abs() {
|
||||
return this.solver().MakeAbs(this);
|
||||
}
|
||||
public IntExpr Square() {
|
||||
return this.solver().MakeSquare(this);
|
||||
}
|
||||
public static ValCstPair operator ==(IntExpr a, long v) {
|
||||
return new ValCstPair(a.solver().MakeEquality(a, v));
|
||||
}
|
||||
public static ValCstPair operator !=(IntExpr a, long v) {
|
||||
return new ValCstPair(a.solver().MakeNonEquality(a.Var(), v));
|
||||
}
|
||||
public static ValCstPair operator >=(IntExpr a, long v) {
|
||||
return new ValCstPair(a.solver().MakeGreaterOrEqual(a, v));
|
||||
}
|
||||
public static ValCstPair operator >(IntExpr a, long v) {
|
||||
return new ValCstPair(a.solver().MakeGreater(a, v));
|
||||
}
|
||||
public static ValCstPair operator <=(IntExpr a, long v) {
|
||||
return new ValCstPair(a.solver().MakeLessOrEqual(a, v));
|
||||
}
|
||||
public static ValCstPair operator <(IntExpr a, long v) {
|
||||
return new ValCstPair(a.solver().MakeLess(a, v));
|
||||
}
|
||||
public static ValCstPair operator >=(IntExpr a, IntExpr b) {
|
||||
return new ValCstPair(a.solver().MakeGreaterOrEqual(a.Var(), b.Var()));
|
||||
}
|
||||
public static ValCstPair operator >(IntExpr a, IntExpr b) {
|
||||
return new ValCstPair(a.solver().MakeGreater(a.Var(), b.Var()));
|
||||
}
|
||||
public static ValCstPair operator <=(IntExpr a, IntExpr b) {
|
||||
return new ValCstPair(a.solver().MakeLessOrEqual(a.Var(), b.Var()));
|
||||
}
|
||||
public static ValCstPair operator <(IntExpr a, IntExpr b) {
|
||||
return new ValCstPair(a.solver().MakeLess(a.Var(), b.Var()));
|
||||
}
|
||||
public static IntExpr operator+(IntExpr a, IntExpr b) {
|
||||
return a.solver().MakeSum(a, b);
|
||||
}
|
||||
public static IntExpr operator+(IntExpr a, long v) {
|
||||
return a.solver().MakeSum(a, v);
|
||||
}
|
||||
public static IntExpr operator+(long v, IntExpr a) {
|
||||
return a.solver().MakeSum(a, v);
|
||||
}
|
||||
public static IntExpr operator-(IntExpr a, IntExpr b) {
|
||||
return a.solver().MakeDifference(a, b);
|
||||
}
|
||||
public static IntExpr operator-(IntExpr a, long v) {
|
||||
return a.solver().MakeSum(a, -v);
|
||||
}
|
||||
public static IntExpr operator-(long v, IntExpr a) {
|
||||
return a.solver().MakeDifference(v, a);
|
||||
}
|
||||
public static IntExpr operator*(IntExpr a, IntExpr b) {
|
||||
return a.solver().MakeProd(a, b);
|
||||
}
|
||||
public static IntExpr operator*(IntExpr a, long v) {
|
||||
return a.solver().MakeProd(a, v);
|
||||
}
|
||||
public static IntExpr operator*(long v, IntExpr a) {
|
||||
return a.solver().MakeProd(a, v);
|
||||
}
|
||||
public static IntExpr operator/(IntExpr a, long v) {
|
||||
return a.solver().MakeDiv(a, v);
|
||||
}
|
||||
public static IntExpr operator-(IntExpr a) {
|
||||
return a.solver().MakeOpposite(a);
|
||||
}
|
||||
public IntExpr Abs() {
|
||||
return this.solver().MakeAbs(this);
|
||||
}
|
||||
public IntExpr Square() {
|
||||
return this.solver().MakeSquare(this);
|
||||
}
|
||||
public static ValCstPair operator ==(IntExpr a, long v) {
|
||||
return new ValCstPair(a.solver().MakeEquality(a, v));
|
||||
}
|
||||
public static ValCstPair operator !=(IntExpr a, long v) {
|
||||
return new ValCstPair(a.solver().MakeNonEquality(a.Var(), v));
|
||||
}
|
||||
public static ValCstPair operator >=(IntExpr a, long v) {
|
||||
return new ValCstPair(a.solver().MakeGreaterOrEqual(a, v));
|
||||
}
|
||||
public static ValCstPair operator >(IntExpr a, long v) {
|
||||
return new ValCstPair(a.solver().MakeGreater(a, v));
|
||||
}
|
||||
public static ValCstPair operator <=(IntExpr a, long v) {
|
||||
return new ValCstPair(a.solver().MakeLessOrEqual(a, v));
|
||||
}
|
||||
public static ValCstPair operator <(IntExpr a, long v) {
|
||||
return new ValCstPair(a.solver().MakeLess(a, v));
|
||||
}
|
||||
public static ValCstPair operator >=(IntExpr a, IntExpr b) {
|
||||
return new ValCstPair(a.solver().MakeGreaterOrEqual(a.Var(), b.Var()));
|
||||
}
|
||||
public static ValCstPair operator >(IntExpr a, IntExpr b) {
|
||||
return new ValCstPair(a.solver().MakeGreater(a.Var(), b.Var()));
|
||||
}
|
||||
public static ValCstPair operator <=(IntExpr a, IntExpr b) {
|
||||
return new ValCstPair(a.solver().MakeLessOrEqual(a.Var(), b.Var()));
|
||||
}
|
||||
public static ValCstPair operator <(IntExpr a, IntExpr b) {
|
||||
return new ValCstPair(a.solver().MakeLess(a.Var(), b.Var()));
|
||||
}
|
||||
%}
|
||||
|
||||
%extend IntervalVar {
|
||||
@@ -2039,7 +2039,7 @@ namespace operations_research {
|
||||
delete intercept;\
|
||||
} else {\
|
||||
solver->clear_fail_intercept();\
|
||||
SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "fail");\
|
||||
SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "fail");\
|
||||
return $null;\
|
||||
}
|
||||
|
||||
@@ -2087,7 +2087,7 @@ namespace operations_research {
|
||||
}
|
||||
} // namespace operations_research
|
||||
|
||||
#endif // SWIGCSHARP
|
||||
#endif // SWIGCSHARP
|
||||
|
||||
// Wrap cp includes
|
||||
%include constraint_solver/constraint_solver.h
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2010-2011 Google
|
||||
// Copyright 2010-2012 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
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2010-2011 Google
|
||||
// Copyright 2010-2012 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
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2010-2011 Google
|
||||
// Copyright 2010-2012 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
|
||||
@@ -700,7 +700,7 @@ namespace operations_research {
|
||||
|
||||
} // namespace operations_research
|
||||
|
||||
#endif // SWIGCSHARP
|
||||
#endif // SWIGCSHARP
|
||||
|
||||
// Wrap linear_solver includes
|
||||
%include "linear_solver/linear_solver.h"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2010-2011 Google
|
||||
// Copyright 2010-2012 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
|
||||
@@ -553,18 +553,18 @@ class LongResultCallback3 : private ResultCallback3<int64, int64, int64, int64>
|
||||
|
||||
////////////////////////////////////////////////
|
||||
//
|
||||
// CS_TYPEMAP_STDVECTOR
|
||||
// CS_TYPEMAP_STDVECTOR
|
||||
//
|
||||
////////////////////////////////////////////////
|
||||
|
||||
%define CS_TYPEMAP_STDVECTOR(TYPE, CTYPE, CSHARPTYPE)
|
||||
|
||||
%typemap(ctype) const std::vector<TYPE>& %{ int length$argnum, CTYPE* %}
|
||||
%typemap(imtype) const std::vector<TYPE>& %{ int length$argnum, CSHARPTYPE[] %}
|
||||
%typemap(cstype) const std::vector<TYPE>& %{ CSHARPTYPE[] %}
|
||||
%typemap(csin) const std::vector<TYPE>& "$csinput.Length, $csinput"
|
||||
%typemap(freearg) const std::vector<TYPE>& { delete $1; }
|
||||
%typemap(in) const std::vector<TYPE>& %{
|
||||
%typemap(ctype) const std::vector<TYPE>& %{ int length$argnum, CTYPE* %}
|
||||
%typemap(imtype) const std::vector<TYPE>& %{ int length$argnum, CSHARPTYPE[] %}
|
||||
%typemap(cstype) const std::vector<TYPE>& %{ CSHARPTYPE[] %}
|
||||
%typemap(csin) const std::vector<TYPE>& "$csinput.Length, $csinput"
|
||||
%typemap(freearg) const std::vector<TYPE>& { delete $1; }
|
||||
%typemap(in) const std::vector<TYPE>& %{
|
||||
$1 = new std::vector<TYPE>;
|
||||
for(int i = 0; i < length$argnum; ++i)
|
||||
$1->push_back($input[i]);
|
||||
@@ -573,7 +573,7 @@ class LongResultCallback3 : private ResultCallback3<int64, int64, int64, int64>
|
||||
|
||||
////////////////////////////////////////////////
|
||||
//
|
||||
// CS_TYPEMAP_STDVECTOR_IN1
|
||||
// CS_TYPEMAP_STDVECTOR_IN1
|
||||
//
|
||||
////////////////////////////////////////////////
|
||||
|
||||
@@ -597,11 +597,11 @@ class LongResultCallback3 : private ResultCallback3<int64, int64, int64, int64>
|
||||
class NestedArrayHelper {};
|
||||
%}
|
||||
|
||||
%typemap(ctype) const std::vector<std::vector<TYPE> >& %{ int len$argnum_1, int len$argnum_2, CTYPE* %}
|
||||
%typemap(imtype) const std::vector<std::vector<TYPE> >& %{ int len$argnum_1, int len$argnum_2, CSHARPTYPE[] %}
|
||||
%typemap(cstype) const std::vector<std::vector<TYPE> >& %{ CSHARPTYPE[,] %}
|
||||
%typemap(csin) const std::vector<std::vector<TYPE> >& "$csinput.GetLength(0), $csinput.GetLength(1), NestedArrayHelper.GetFlatArray($csinput)"
|
||||
%typemap(in) const std::vector<std::vector<TYPE> >& (std::vector<std::vector<TYPE> > result) %{
|
||||
%typemap(ctype) const std::vector<std::vector<TYPE> >& %{ int len$argnum_1, int len$argnum_2, CTYPE* %}
|
||||
%typemap(imtype) const std::vector<std::vector<TYPE> >& %{ int len$argnum_1, int len$argnum_2, CSHARPTYPE[] %}
|
||||
%typemap(cstype) const std::vector<std::vector<TYPE> >& %{ CSHARPTYPE[,] %}
|
||||
%typemap(csin) const std::vector<std::vector<TYPE> >& "$csinput.GetLength(0), $csinput.GetLength(1), NestedArrayHelper.GetFlatArray($csinput)"
|
||||
%typemap(in) const std::vector<std::vector<TYPE> >& (std::vector<std::vector<TYPE> > result) %{
|
||||
|
||||
const int size_x = len$argnum_1;
|
||||
const int size_y = len$argnum_2;
|
||||
@@ -625,7 +625,7 @@ class LongResultCallback3 : private ResultCallback3<int64, int64, int64, int64>
|
||||
|
||||
////////////////////////////////////////////////
|
||||
//
|
||||
// CS_TYPEMAP_PTRARRAY
|
||||
// CS_TYPEMAP_PTRARRAY
|
||||
//
|
||||
////////////////////////////////////////////////
|
||||
|
||||
@@ -640,24 +640,24 @@ class LongResultCallback3 : private ResultCallback3<int64, int64, int64, int64>
|
||||
}
|
||||
%}
|
||||
|
||||
%typemap(ctype) CTYPE** "CTYPE**"
|
||||
%typemap(ctype) CTYPE** "CTYPE**"
|
||||
|
||||
%typemap(imtype,
|
||||
inattributes="[In, Out, MarshalAs(UnmanagedType.LPArray)]",
|
||||
outattributes="[return: MarshalAs(UnmanagedType.LPArray)]")
|
||||
CTYPE** "IntPtr[]"
|
||||
|
||||
%typemap(cstype) CTYPE** "TYPE[]"
|
||||
%typemap(csin) CTYPE** "TYPE.getCPtr($csinput)"
|
||||
%typemap(in) CTYPE** "$1 = $input;"
|
||||
%typemap(freearg) CTYPE** ""
|
||||
%typemap(argout) CTYPE** ""
|
||||
%typemap(cstype) CTYPE** "TYPE[]"
|
||||
%typemap(csin) CTYPE** "TYPE.getCPtr($csinput)"
|
||||
%typemap(in) CTYPE** "$1 = $input;"
|
||||
%typemap(freearg) CTYPE** ""
|
||||
%typemap(argout) CTYPE** ""
|
||||
|
||||
%enddef // CS_TYPEMAP_PTRARRAY
|
||||
%enddef // CS_TYPEMAP_PTRARRAY
|
||||
|
||||
////////////////////////////////////////////////
|
||||
//
|
||||
// CS_TYPEMAP_STDVECTOR_OBJECT
|
||||
// CS_TYPEMAP_STDVECTOR_OBJECT
|
||||
//
|
||||
////////////////////////////////////////////////
|
||||
|
||||
@@ -681,7 +681,7 @@ CTYPE** "IntPtr[]"
|
||||
result.push_back($input[i]);
|
||||
$1 = &result;
|
||||
}
|
||||
%enddef // CS_TYPEMAP_STDVECTOR_OBJECT
|
||||
%enddef // CS_TYPEMAP_STDVECTOR_OBJECT
|
||||
|
||||
%{
|
||||
#include <vector>
|
||||
@@ -788,12 +788,11 @@ CS_TYPEMAP_STDVECTOR_IN1(int64, int64, long)
|
||||
// type
|
||||
// @param param_name the parameter name
|
||||
%define PROTO_INPUT(CppProtoType, CSharpProtoType, param_name)
|
||||
%typemap(ctype) PROTO_TYPE* INPUT, PROTO_TYPE& INPUT "int proto_size, char*"
|
||||
%typemap(imtype) PROTO_TYPE* INPUT, PROTO_TYPE& INPUT "int proto_size, byte[]"
|
||||
%typemap(cstype) PROTO_TYPE* INPUT, PROTO_TYPE& INPUT "CSharpProtoType"
|
||||
%typemap(csin) PROTO_TYPE* INPUT, PROTO_TYPE& INPUT "$csinput.GetByteArrayLength(), $csinput.ToByteArray()"
|
||||
%typemap(in) PROTO_TYPE* INPUT (CppProtoType temp),
|
||||
PROTO_TYPE& INPUT (CppProtoType temp) {
|
||||
%typemap(ctype) PROTO_TYPE* INPUT, PROTO_TYPE& INPUT "int proto_size, char*"
|
||||
%typemap(imtype) PROTO_TYPE* INPUT, PROTO_TYPE& INPUT "int proto_size, byte[]"
|
||||
%typemap(cstype) PROTO_TYPE* INPUT, PROTO_TYPE& INPUT "CSharpProtoType"
|
||||
%typemap(csin) PROTO_TYPE* INPUT, PROTO_TYPE& INPUT "$csinput.GetByteArrayLength(), $csinput.ToByteArray()"
|
||||
%typemap(in) PROTO_TYPE* INPUT (CppProtoType temp), PROTO_TYPE& INPUT (CppProtoType temp) {
|
||||
int proto_size = 0;
|
||||
scoped_array<char> proto_buffer($input);
|
||||
bool parsed_ok = temp.ParseFromArray(proto_buffer.get(), proto_size);
|
||||
|
||||
Reference in New Issue
Block a user