Backport from g3 to github

This commit is contained in:
Corentin Le Molgat
2019-03-13 13:50:23 +01:00
parent afcc53d300
commit 2f0680127d
19 changed files with 148 additions and 239 deletions

View File

@@ -39,4 +39,6 @@ typedef uint64_t uint64;
%rename (UseReduction) operations_research::KnapsackSolver::use_reduction;
%rename (SetUseReduction) operations_research::KnapsackSolver::set_use_reduction;
// TODO(user): Replace with %ignoreall/%unignoreall
//swiglint: disable include-h-allglobals
%include "ortools/algorithms/knapsack_solver.h"

View File

@@ -10,6 +10,7 @@
// 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.
%{
#include <cstdint>
#include <string>

View File

@@ -25,12 +25,12 @@ package com.google.ortools.constraintsolver;
*/
@FunctionalInterface
public interface IntIntToLongFunction {
/**
* Applies this function to the given arguments.
*
* @param left the first argument
* @param right the second argument
* @return the function result
*/
long applyAsLong(int left, int right);
/**
* Applies this function to the given arguments.
*
* @param left the first argument
* @param right the second argument
* @return the function result
*/
long applyAsLong(int left, int right);
}

View File

@@ -25,13 +25,13 @@ package com.google.ortools.constraintsolver;
*/
@FunctionalInterface
public interface LongTernaryOperator {
/**
* Applies this operator to the given operands.
*
* @param left the first operand
* @param center the second operand
* @param right the third operand
* @return the operator result
*/
long applyAsLong(long left, long center, long right);
/**
* Applies this operator to the given operands.
*
* @param left the first operand
* @param center the second operand
* @param right the third operand
* @return the operator result
*/
long applyAsLong(long left, long center, long right);
}

View File

@@ -24,25 +24,25 @@ package com.google.ortools.constraintsolver;
*/
@FunctionalInterface
public interface LongTernaryPredicate {
/**
* Evaluates this predicate on the given arguments.
*
* @param left the first operand
* @param center the second operand
* @param right the third operand
* @return {@code true} if the input argument matches the predicate,
* otherwise {@code false}
*/
boolean test(long left, long center, long right);
/**
* Evaluates this predicate on the given arguments.
*
* @param left the first operand
* @param center the second operand
* @param right the third operand
* @return {@code true} if the input argument matches the predicate,
* otherwise {@code false}
*/
boolean test(long left, long center, long right);
/**
* Returns a predicate that represents the logical negation of this
* predicate.
*
* @return a predicate that represents the logical negation of this
* predicate
*/
default LongTernaryPredicate negate() {
return (left, center, right) -> !test(left, center, right);
}
/**
* Returns a predicate that represents the logical negation of this
* predicate.
*
* @return a predicate that represents the logical negation of this
* predicate
*/
default LongTernaryPredicate negate() {
return (left, center, right) -> !test(left, center, right);
}
}

View File

@@ -105,7 +105,7 @@ public partial class CpIntVectorVector : IDisposable, System.Collections.IEnumer
return outVal;
}
// cast from C# int[][] two-dimensional rray
// cast from C# int[][] two-dimensional array
public static implicit operator CpIntVectorVector(int[][] inVal) {
int x_size = inVal.GetLength(0);
CpIntVectorVector outVal = new CpIntVectorVector();
@@ -173,7 +173,7 @@ public partial class CpInt64VectorVector : IDisposable, System.Collections.IEnum
return outVal;
}
// cast from C# long[][] two-dimensional rray
// cast from C# long[][] two-dimensional array
public static implicit operator CpInt64VectorVector(long[][] inVal) {
int x_size = inVal.GetLength(0);
CpInt64VectorVector outVal = new CpInt64VectorVector();

View File

@@ -238,39 +238,6 @@ DEFINE_ARGS_TO_R_CALLBACK(
#undef DEFINE_ARGS_TO_R_CALLBACK
#undef DEFINE_VOID_TO_STRING_CALLBACK
// Convert in module_csharp_wrap.cc input argument (delegate marshaled in C function pointer) to original std::function<...>
//%typemap(in) Solver::DisplayCallback %{
// $1 = [$input]() -> std::string {
// std::string result;
// return result.assign((*(char* (*)())$input)());
// };
//%}
//
//%typemap(in) Solver::IndexEvaluator1 %{
// $1 = [$input](int64 u) -> int64 {
// return (*(int64 (*)(int64))$input)(u);
// };
//%}
//%typemap(in) Solver::IndexEvaluator2 %{
// $1 = [$input](int64 u, int64 v) -> int64 {
// return (*(int64 (*)(int64, int64))$input)(u, v);};
//%}
//%typemap(in) Solver::IndexEvaluator3 %{
// $1 = [$input](int64 u, int64 v, int64 w) -> int64 {
// return (*(int64 (*)(int64, int64, int64))$input)(u, v, w);};
//%}
//
//%typemap(in) Solver::IndexFilter1 %{
// $1 = [$input](int64 u) -> bool {
// return (*(bool (*)(int64))$input)(u);};
//%}
//%typemap(in) Solver::ObjectiveWatcher %{
// $1 = [$input](int64 u) -> void {
// return (*(void (*)(int64))$input)(u);};
//%}
// Renaming
namespace operations_research {

View File

@@ -126,7 +126,10 @@ PROTECT_FROM_FAILURE(Solver::Fail(), arg1);
#include "ortools/constraint_solver/constraint_solveri.h"
%}
// Use to correctly wrap Solver::MakeScheduleOrPostpone.
%apply int64 * INOUT { int64 *const marker };
// Use to correctly wrap arguments otherwise SWIG will wrap them as
// SWIGTYPE_p_long_long opaque pointer.
%apply int64 * OUTPUT { int64 *l, int64 *u, int64 *value };
// Types in Proxy class (e.g. Solver.java) e.g.:
@@ -349,20 +352,17 @@ namespace operations_research {
// Decision
%feature("director") Decision;
%unignore Decision;
// Methods:
%rename (apply) Decision::Apply;
%rename (refute) Decision::Refute;
// DecisionBuilder
%feature("director") DecisionBuilder;
%unignore DecisionBuilder;
// Methods:
%rename (nextWrap) DecisionBuilder::Next;
// DecisionVisitor
%feature("director") DecisionVisitor;
%unignore DecisionVisitor;
// Methods:
%rename (visitRankFirstInterval) DecisionVisitor::VisitRankFirstInterval;
%rename (visitRankLastInterval) DecisionVisitor::VisitRankLastInterval;
%rename (visitScheduleOrExpedite) DecisionVisitor::VisitScheduleOrExpedite;
@@ -373,7 +373,6 @@ namespace operations_research {
// ModelVisitor
%unignore ModelVisitor;
// Methods:
%rename (beginVisitConstraint) ModelVisitor::BeginVisitConstraint;
%rename (beginVisitExtension) ModelVisitor::BeginVisitExtension;
%rename (beginVisitIntegerExpression) ModelVisitor::BeginVisitIntegerExpression;
@@ -398,14 +397,12 @@ namespace operations_research {
// SymmetryBreaker
%feature("director") SymmetryBreaker;
%unignore SymmetryBreaker;
// Methods:
%rename (addIntegerVariableEqualValueClause) SymmetryBreaker::AddIntegerVariableEqualValueClause;
%rename (addIntegerVariableGreaterOrEqualValueClause) SymmetryBreaker::AddIntegerVariableGreaterOrEqualValueClause;
%rename (addIntegerVariableLessOrEqualValueClause) SymmetryBreaker::AddIntegerVariableLessOrEqualValueClause;
// ModelCache
%unignore ModelCache;
// Methods:
%rename (clear) ModelCache::Clear;
%rename (findExprConstantExpression) ModelCache::FindExprConstantExpression;
%rename (findExprExprConstantExpression) ModelCache::FindExprExprConstantExpression;
@@ -436,7 +433,6 @@ namespace operations_research {
// RevPartialSequence
%unignore RevPartialSequence;
// Methods:
%rename (isRanked) RevPartialSequence::IsRanked;
%rename (numFirstRanked) RevPartialSequence::NumFirstRanked;
%rename (numLastRanked) RevPartialSequence::NumLastRanked;
@@ -445,7 +441,7 @@ namespace operations_research {
%rename (size) RevPartialSequence::Size;
// UnsortedNullableRevBitset
// TODO(corentinl) To removed from constraint_solveri.h (only use by table.cc)
// TODO(user): Remove from constraint_solveri.h (only use by table.cc)
%ignore UnsortedNullableRevBitset;
// Assignment
@@ -528,12 +524,10 @@ namespace operations_research {
%rename (unperformed) Assignment::Unperformed;
// template AssignmentContainer<>
// Ignored:
%ignore AssignmentContainer::MutableElement;
%ignore AssignmentContainer::MutableElementOrNull;
%ignore AssignmentContainer::ElementPtrOrNull;
%ignore AssignmentContainer::elements;
// Methods:
%rename (add) AssignmentContainer::Add;
%rename (addAtPosition) AssignmentContainer::AddAtPosition;
%rename (clear) AssignmentContainer::Clear;
@@ -550,17 +544,14 @@ namespace operations_research {
// AssignmentElement
%unignore AssignmentElement;
// Methods:
%rename (activate) AssignmentElement::Activate;
%rename (deactivate) AssignmentElement::Deactivate;
%rename (activated) AssignmentElement::Activated;
// IntVarElement
%unignore IntVarElement;
// Ignored:
%ignore IntVarElement::LoadFromProto;
%ignore IntVarElement::WriteToProto;
// Methods:
%rename (reset) IntVarElement::Reset;
%rename (clone) IntVarElement::Clone;
%rename (copy) IntVarElement::Copy;
@@ -577,10 +568,8 @@ namespace operations_research {
// IntervalVarElement
%unignore IntervalVarElement;
// Ignored:
%ignore IntervalVarElement::LoadFromProto;
%ignore IntervalVarElement::WriteToProto;
// Methods:
%rename (clone) IntervalVarElement::Clone;
%rename (copy) IntervalVarElement::Copy;
%rename (durationMax) IntervalVarElement::DurationMax;
@@ -618,10 +607,8 @@ namespace operations_research {
// SequenceVarElement
%unignore SequenceVarElement;
// Ignored:
%ignore SequenceVarElement::LoadFromProto;
%ignore SequenceVarElement::WriteToProto;
// Methods:
%rename (backwardSequence) SequenceVarElement::BackwardSequence;
%rename (clone) SequenceVarElement::Clone;
%rename (copy) SequenceVarElement::Copy;
@@ -638,7 +625,6 @@ namespace operations_research {
// SolutionCollector
%unignore SolutionCollector;
// Methods:
%rename (add) SolutionCollector::Add;
%rename (addObjective) SolutionCollector::AddObjective;
%rename (backwardSequence) SolutionCollector::BackwardSequence;
@@ -654,7 +640,6 @@ namespace operations_research {
// SolutionPool
%unignore SolutionPool;
// Methods:
%rename (getNextSolution) SolutionPool::GetNextSolution;
%rename (initialize) SolutionPool::Initialize;
%rename (registerNewSolution) SolutionPool::RegisterNewSolution;
@@ -789,7 +774,6 @@ import java.lang.Runnable;
return array;
}
%}
// Ignored:
%ignore Solver::SearchLogParameters;
%ignore Solver::ActiveSearch;
%ignore Solver::SetSearchContext;
@@ -804,7 +788,6 @@ import java.lang.Runnable;
%ignore Solver::MakeAtMost;
%ignore Solver::demon_profiler;
%ignore Solver::set_fail_intercept;
// Methods:
%unignore Solver::Solver;
%rename (acceptedNeighbors) Solver::accepted_neighbors;
%rename (addBacktrackAction) Solver::AddBacktrackAction;
@@ -1048,12 +1031,10 @@ import java.lang.Runnable;
// BaseIntExpr
%unignore BaseIntExpr;
// Methods:
%rename (castToVar) BaseIntExpr::CastToVar;
// IntExpr
%unignore IntExpr;
// Methods:
%rename (isVar) IntExpr::IsVar;
%rename (range) IntExpr::Range;
%rename (var) IntExpr::Var;
@@ -1062,7 +1043,6 @@ import java.lang.Runnable;
// IntVar
%unignore IntVar;
// Methods:
%rename (addName) IntVar::AddName;
%rename (contains) IntVar::Contains;
%rename (isDifferent) IntVar::IsDifferent;
@@ -1083,14 +1063,12 @@ import java.lang.Runnable;
// IntVarIterator
%unignore IntVarIterator;
// Methods:
%rename (init) IntVarIterator::Init;
%rename (next) IntVarIterator::Next;
%rename (ok) IntVarIterator::Ok;
// BooleanVar
%unignore BooleanVar;
// Methods:
%rename (baseName) BooleanVar::BaseName;
%rename (isDifferent) BooleanVar::IsDifferent;
%rename (isEqual) BooleanVar::IsEqual;
@@ -1108,7 +1086,6 @@ import java.lang.Runnable;
// IntervalVar
%unignore IntervalVar;
// Methods:
%rename (cannotBePerformed) IntervalVar::CannotBePerformed;
%rename (durationExpr) IntervalVar::DurationExpr;
%rename (durationMax) IntervalVar::DurationMax;
@@ -1154,17 +1131,14 @@ import java.lang.Runnable;
// OptimizeVar
%unignore OptimizeVar;
// Methods:
%rename (applyBound) OptimizeVar::ApplyBound;
%rename (print) OptimizeVar::Print;
%rename (var) OptimizeVar::Var;
// SequenceVar
%unignore SequenceVar;
// Ignored:
%ignore SequenceVar::ComputePossibleFirstsAndLasts;
%ignore SequenceVar::FillSequence;
// Methods:
%rename (rankFirst) SequenceVar::RankFirst;
%rename (rankLast) SequenceVar::RankLast;
%rename (rankNotFirst) SequenceVar::RankNotFirst;
@@ -1175,7 +1149,6 @@ import java.lang.Runnable;
// Constraint
%unignore Constraint;
// Methods:
%rename (initialPropagate) Constraint::InitialPropagate;
%rename (isCastConstraint) Constraint::IsCastConstraint;
%rename (postAndPropagate) Constraint::PostAndPropagate;
@@ -1189,7 +1162,6 @@ import java.lang.Runnable;
// see https://docs.oracle.com/javase/8/docs/api/java/util/function/LongBinaryOperator.html
import java.util.function.LongBinaryOperator;
%}
// Methods:
%rename (makeSequenceVar) DisjunctiveConstraint::MakeSequenceVar;
%rename (setTransitionTime) DisjunctiveConstraint::SetTransitionTime;
%rename (transitionTime) DisjunctiveConstraint::TransitionTime;
@@ -1204,7 +1176,6 @@ import java.util.function.LongUnaryOperator;
// see https://docs.oracle.com/javase/8/docs/api/java/util/function/LongBinaryOperator.html
import java.util.function.LongBinaryOperator;
%}
// Methods:
%rename (addCountAssignedItemsDimension) Pack::AddCountAssignedItemsDimension;
%rename (addCountUsedBinDimension) Pack::AddCountUsedBinDimension;
%rename (addSumVariableWeightsLessOrEqualConstantDimension) Pack::AddSumVariableWeightsLessOrEqualConstantDimension;
@@ -1231,11 +1202,9 @@ import java.util.function.LongBinaryOperator;
// PropagationBaseObject
%unignore PropagationBaseObject;
// Ignored:
%ignore PropagationBaseObject::ExecuteAll;
%ignore PropagationBaseObject::EnqueueAll;
%ignore PropagationBaseObject::set_action_on_fail;
// Methods:
%rename (baseName) PropagationBaseObject::BaseName;
%rename (enqueueDelayedDemon) PropagationBaseObject::EnqueueDelayedDemon;
%rename (enqueueVar) PropagationBaseObject::EnqueueVar;
@@ -1247,7 +1216,6 @@ import java.util.function.LongBinaryOperator;
// SearchMonitor
%feature("director") SearchMonitor;
%unignore SearchMonitor;
// Methods:
%rename (acceptDelta) SearchMonitor::AcceptDelta;
%rename (acceptNeighbor) SearchMonitor::AcceptNeighbor;
%rename (acceptSolution) SearchMonitor::AcceptSolution;
@@ -1274,7 +1242,6 @@ import java.util.function.LongBinaryOperator;
// SearchLimit
%unignore SearchLimit;
// Ignored:
%rename (check) SearchLimit::Check;
%rename (copy) SearchLimit::Copy;
%rename (init) SearchLimit::Init;
@@ -1287,13 +1254,11 @@ import java.util.function.LongBinaryOperator;
// see https://docs.oracle.com/javase/8/docs/api/java/util/function/Supplier.html
import java.util.function.Supplier;
%}
// Methods:
%rename (maintain) SearchLog::Maintain;
%rename (outputDecision) SearchLog::OutputDecision;
// LocalSearchMonitor
%unignore LocalSearchMonitor;
// Methods:
%rename (beginAcceptNeighbor) LocalSearchMonitor::BeginAcceptNeighbor;
%rename (beginFiltering) LocalSearchMonitor::BeginFiltering;
%rename (beginFilterNeighbor) LocalSearchMonitor::BeginFilterNeighbor;
@@ -1307,7 +1272,6 @@ import java.util.function.Supplier;
// PropagationMonitor
%unignore PropagationMonitor;
// Methods:
%rename (beginConstraintInitialPropagation) PropagationMonitor::BeginConstraintInitialPropagation;
%rename (beginDemonRun) PropagationMonitor::BeginDemonRun;
%rename (beginNestedConstraintInitialPropagation) PropagationMonitor::BeginNestedConstraintInitialPropagation;
@@ -1358,19 +1322,16 @@ import java.util.function.Supplier;
// LocalSearchOperator
%feature("director") LocalSearchOperator;
%unignore LocalSearchOperator;
// Methods:
%rename (nextNeighbor) LocalSearchOperator::MakeNextNeighbor;
%rename (reset) LocalSearchOperator::Reset;
%rename (start) LocalSearchOperator::Start;
// VarLocalSearchOperator<>
%unignore VarLocalSearchOperator;
// Ignored:
%ignore VarLocalSearchOperator::Start;
%ignore VarLocalSearchOperator::ApplyChanges;
%ignore VarLocalSearchOperator::RevertChanges;
%ignore VarLocalSearchOperator::SkipUnchanged;
// Methods:
%rename (size) VarLocalSearchOperator::Size;
%rename (value) VarLocalSearchOperator::Value;
%rename (isIncremental) VarLocalSearchOperator::IsIncremental;
@@ -1386,9 +1347,7 @@ import java.util.function.Supplier;
// IntVarLocalSearchOperator
%feature("director") IntVarLocalSearchOperator;
%unignore IntVarLocalSearchOperator;
// Ignored:
%ignore IntVarLocalSearchOperator::MakeNextNeighbor;
// Methods:
%rename (size) IntVarLocalSearchOperator::Size;
%rename (oneNeighbor) IntVarLocalSearchOperator::MakeOneNeighbor;
%rename (value) IntVarLocalSearchOperator::Value;
@@ -1405,7 +1364,6 @@ import java.util.function.Supplier;
// BaseLns
%feature("director") BaseLns;
%unignore BaseLns;
// Methods:
%rename (initFragments) BaseLns::InitFragments;
%rename (nextFragment) BaseLns::NextFragment;
%feature ("nodirector") BaseLns::OnStart;
@@ -1418,35 +1376,29 @@ import java.util.function.Supplier;
// ChangeValue
%feature("director") ChangeValue;
%unignore ChangeValue;
// Methods:
%rename (modifyValue) ChangeValue::ModifyValue;
// SequenceVarLocalSearchOperator
%feature("director") SequenceVarLocalSearchOperator;
%unignore SequenceVarLocalSearchOperator;
// Ignored:
%ignore SequenceVarLocalSearchOperator::OldSequence;
%ignore SequenceVarLocalSearchOperator::Sequence;
%ignore SequenceVarLocalSearchOperator::SetBackwardSequence;
%ignore SequenceVarLocalSearchOperator::SetForwardSequence;
// Methods:
%rename (start) SequenceVarLocalSearchOperator::Start;
// PathOperator
%feature("director") PathOperator;
%unignore PathOperator;
%typemap(javaimports) PathOperator %{
// Used to wrap start_empty_path_class
// see
// Used to wrap start_empty_path_class see:
// https://docs.oracle.com/javase/8/docs/api/java/util/function/LongToIntFunction.html
import java.util.function.LongToIntFunction;
%}
// Ignored:
%ignore PathOperator::Next;
%ignore PathOperator::Path;
%ignore PathOperator::SkipUnchanged;
%ignore PathOperator::number_of_nexts;
// Methods:
%rename (getBaseNodeRestartPosition) PathOperator::GetBaseNodeRestartPosition;
%rename (initPosition) PathOperator::InitPosition;
%rename (neighbor) PathOperator::MakeNeighbor;
@@ -1456,14 +1408,12 @@ import java.util.function.LongToIntFunction;
// PathWithPreviousNodesOperator
%unignore PathWithPreviousNodesOperator;
// Methods:
%rename (isPathStart) PathWithPreviousNodesOperator::IsPathStart;
%rename (prev) PathWithPreviousNodesOperator::Prev;
// LocalSearchFilter
%feature("director") LocalSearchFilter;
%unignore LocalSearchFilter;
// Methods:
%rename (accept) LocalSearchFilter::Accept;
%rename (getAcceptedObjectiveValue) LocalSearchFilter::GetAcceptedObjectiveValue;
%rename (getSynchronizedObjectiveValue) LocalSearchFilter::GetSynchronizedObjectiveValue;
@@ -1478,10 +1428,8 @@ import java.util.function.LongToIntFunction;
// see https://docs.oracle.com/javase/8/docs/api/java/util/function/LongConsumer.html
import java.util.function.LongConsumer;
%}
// Ignored:
%ignore IntVarLocalSearchFilter::FindIndex;
%ignore IntVarLocalSearchFilter::IsVarSynced;
// Methods:
%feature("nodirector") IntVarLocalSearchFilter::Synchronize; // Inherited.
%rename (addVars) IntVarLocalSearchFilter::AddVars; // Inherited.
%rename (injectObjectiveValue) IntVarLocalSearchFilter::InjectObjectiveValue;
@@ -1502,7 +1450,6 @@ import java.util.function.LongConsumer;
// Demon
%unignore Demon;
// Methods:
%rename (run) Demon::Run;
%define CONVERT_VECTOR(CType, JavaType)
@@ -1603,11 +1550,9 @@ PROTO2_RETURN(operations_research::SearchLimitParameters,
namespace operations_research {
// Globals
// IMPORTANT(corentinl): Global will be placed in main.java
// IMPORTANT(corentinl): Globals will be placed in main.java
// i.e. use `import com.[...].constraintsolver.main`
// Ignored:
%ignore FillValues;
// Functions:
%rename (areAllBooleans) AreAllBooleans;
%rename (areAllBound) AreAllBound;
%rename (areAllBoundTo) AreAllBoundTo;

View File

@@ -62,7 +62,6 @@ import java.util.function.LongBinaryOperator;
// see https://docs.oracle.com/javase/8/docs/api/java/util/function/LongUnaryOperator.html
import java.util.function.LongUnaryOperator;
%}
// Ignored:
%ignore RoutingModel::AddDimensionDependentDimensionWithVehicleCapacity;
%ignore RoutingModel::AddMatrixDimension(
std::vector<std::vector<int64> > values,
@@ -89,7 +88,6 @@ import java.util.function.LongUnaryOperator;
%ignore RoutingModel::TransitCallback;
%ignore RoutingModel::StateDependentTransitCallback;
%ignore RoutingModel::UnaryTransitCallbackOrNull;
// Methods:
%rename (activeVar) RoutingModel::ActiveVar;
%rename (addAllActive) RoutingModel::AddAllActive;
%rename (addAtSolutionCallback) RoutingModel::AddAtSolutionCallback;
@@ -225,7 +223,6 @@ import java.util.function.LongUnaryOperator;
// see https://docs.oracle.com/javase/8/docs/api/java/util/function/LongBinaryOperator.html
import java.util.function.LongBinaryOperator;
%}
// Methods:
%rename (cumulVar) RoutingDimension::CumulVar;
%rename (fixedTransitVar) RoutingDimension::FixedTransitVar;
%rename (getBreakIntervalsOfVehicle) RoutingDimension::GetBreakIntervalsOfVehicle;
@@ -258,7 +255,6 @@ import java.util.function.LongBinaryOperator;
// RoutingFilteredDecisionBuilder
%unignore RoutingFilteredDecisionBuilder;
// Methods:
%rename (getEndChainStart) RoutingFilteredDecisionBuilder::GetEndChainStart;
%rename (getStartChainEnd) RoutingFilteredDecisionBuilder::GetStartChainEnd;
%rename (initializeRoutes) RoutingFilteredDecisionBuilder::InitializeRoutes;

View File

@@ -1922,6 +1922,8 @@ CONTAINERHELPER(IntVar, IntVarElement, IntContainer)
CONTAINERHELPER(IntervalVar, IntervalVarElement, IntervalContainer)
CONTAINERHELPER(SequenceVar, SequenceVarElement, SequenceContainer)
#undef CONTAINERHELPER
} // namespace operations_research
// ================= constraint_solver.i API =====================

View File

@@ -20,7 +20,6 @@ import com.google.ortools.constraintsolver.RoutingModel;
import com.google.ortools.constraintsolver.RoutingSearchParameters;
import com.google.ortools.constraintsolver.main;
import java.util.logging.Logger;
// [END import]
/** Minimal VRP. */

View File

@@ -44,6 +44,8 @@ typedef uint64_t uint64;
%unignore operations_research;
%rename (MaxFlow) operations_research::SimpleMaxFlow;
%ignore operations_research::SimpleMaxFlow::GetSourceSideMinCut; // missing typemap for argument
%ignore operations_research::SimpleMaxFlow::GetSinkSideMinCut; // missing typemap for argument
%unignore operations_research::SimpleMaxFlow::SimpleMaxFlow;
%unignore operations_research::SimpleMaxFlow::~SimpleMaxFlow;
%unignore operations_research::SimpleMaxFlow::AddArcWithCapacity;
@@ -55,9 +57,6 @@ typedef uint64_t uint64;
%unignore operations_research::SimpleMaxFlow::Capacity;
%unignore operations_research::SimpleMaxFlow::OptimalFlow;
%unignore operations_research::SimpleMaxFlow::Flow;
// Ignored:
%ignore operations_research::SimpleMaxFlow::GetSourceSideMinCut; // missing typemap for argument
%ignore operations_research::SimpleMaxFlow::GetSinkSideMinCut; // missing typemap for argument
// Expose the "operations_research::SimpleMaxFlow::Status" enum.
%unignore operations_research::SimpleMaxFlow::Status;

View File

@@ -42,9 +42,6 @@
#include "ortools/graph/min_cost_flow.h"
%}
typedef int64_t int64;
typedef uint64_t uint64;
// ############ max_flow.h ############
%ignoreall
@@ -53,6 +50,8 @@ typedef uint64_t uint64;
// MaxFlow
%rename (MaxFlow) operations_research::SimpleMaxFlow;
%ignore operations_research::SimpleMaxFlow::GetSourceSideMinCut; // missing typemap for argument
%ignore operations_research::SimpleMaxFlow::GetSinkSideMinCut; // missing typemap for argument
%unignore operations_research::SimpleMaxFlow::SimpleMaxFlow;
%unignore operations_research::SimpleMaxFlow::~SimpleMaxFlow;
%rename (addArcWithCapacity) operations_research::SimpleMaxFlow::AddArcWithCapacity;
@@ -65,9 +64,6 @@ typedef uint64_t uint64;
%rename (solve) operations_research::SimpleMaxFlow::Solve;
%rename (getOptimalFlow) operations_research::SimpleMaxFlow::OptimalFlow;
%rename (getFlow) operations_research::SimpleMaxFlow::Flow;
// Ignored:
%ignore operations_research::SimpleMaxFlow::GetSourceSideMinCut; // missing typemap for argument
%ignore operations_research::SimpleMaxFlow::GetSinkSideMinCut; // missing typemap for argument
// To expose the Status enum's values (as constant integers), we must expose the enum
// type itself.

View File

@@ -16,9 +16,9 @@ namespace Google.OrTools.Sat
using System;
using System.Collections.Generic;
/// <summary>
/// <summary>
/// Wrapper class around the cp_model proto.
/// </summary>
/// </summary>
public class CpModel
{
public CpModel()

View File

@@ -15,7 +15,7 @@ using System;
using System.Collections.Generic;
namespace Google.OrTools.Sat
{
{
public class CpSolver
{

View File

@@ -15,7 +15,6 @@
// TODO(user): Refactor this file to comply with the SWIG style guide.
%include "ortools/base/base.i"
%include "ortools/util/csharp/vector.i"
%{

View File

@@ -27,9 +27,11 @@
#include "ortools/base/integral_types.h"
%}
// Typemaps to represent const std::vector<TYPE>& arguments as arrays of
// CSHARPTYPE.
// Typemaps to represent arguments of types "const std::vector<TYPE>&" or
// "std::vector<TYPE>" as CSHARPTYPE[].
// note: TYPE must be a primitive data type (PDT).
%define VECTOR_AS_CSHARP_ARRAY(TYPE, CTYPE, CSHARPTYPE, ARRAYTYPE)
// This part is for const std::vector<>&.
%typemap(cstype) const std::vector<TYPE>& %{ CSHARPTYPE[] %}
%typemap(csin) const std::vector<TYPE>& %{ $csinput.Length, $csinput %}
%typemap(imtype, out="global::System.IntPtr") const std::vector<TYPE>& %{ int length$argnum, CSHARPTYPE[] %}
@@ -54,8 +56,7 @@
}
return ret;
}
// Same, for std::vector<TYPE>
// Now, we do it for std::vector<>.
%typemap(cstype) std::vector<TYPE> %{ CSHARPTYPE[] %}
%typemap(csin) std::vector<TYPE> %{ $csinput.Length, $csinput %}
%typemap(imtype, out="global::System.IntPtr") std::vector<TYPE> %{ int length$argnum, CSHARPTYPE[] %}
@@ -81,13 +82,11 @@
}
%enddef // VECTOR_AS_CSHARP_ARRAY
//VECTOR_AS_CSHARP_ARRAY(int, int, int);
//VECTOR_AS_CSHARP_ARRAY(int64, int64, long);
//VECTOR_AS_CSHARP_ARRAY(double, double, double);
// Typemaps to represent const std::vector<std::vector<CType> >& arguments as
// a CSharpType[][].
// Typemaps to represent arguments of types "const std::vector<std::vector<TYPE>>&" or
// "std::vector<std::vector<TYPE>>*" as CSHARPTYPE[][].
// note: TYPE must be a primitive data type (PDT).
%define MATRIX_AS_CSHARP_ARRAY(TYPE, CTYPE, CSHARPTYPE, ARRAYTYPE)
// This part is for const std::vector<std::vector<>>&.
%typemap(cstype) const std::vector<std::vector<TYPE> >& %{ CSHARPTYPE[][] %}
%typemap(csin) const std::vector<std::vector<TYPE> >& %{
$csinput.GetLength(0),
@@ -117,8 +116,7 @@
$1 = &result;
%}
// Same, for std::vector<std::vector<CType>>*
// Now, we do it for std::vector<std::vector<>>*.
%typemap(cstype) std::vector<std::vector<TYPE> >* %{ CSHARPTYPE[][] %}
%typemap(csin) std::vector<std::vector<TYPE> >* %{
$csinput.GetLength(0),
@@ -149,6 +147,3 @@
%}
%enddef // MATRIX_AS_CSHARP_ARRAY
//MATRIX_AS_CSHARP_ARRAY(int, int, int);
//MATRIX_AS_CSHARP_ARRAY(int64, int64, long);
//MATRIX_AS_CSHARP_ARRAY(double, double, double);

View File

@@ -25,6 +25,7 @@
#include "ortools/util/tuple_set.h"
%}
%ignore operations_research::IntTupleSet::RawData; // no typemap
%rename (arity) operations_research::IntTupleSet::Arity;
%rename (clear) operations_research::IntTupleSet::Clear;
%rename (contains) operations_research::IntTupleSet::Contains;
@@ -38,7 +39,5 @@
%rename (sortedByColumn) operations_research::IntTupleSet::SortedByColumn;
%rename (sortedLexicographically) operations_research::IntTupleSet::SortedLexicographically;
%rename (value) operations_research::IntTupleSet::Value;
// Ignored:
%ignore operations_research::IntTupleSet::RawData; // no typemap
%include ortools/util/tuple_set.h

View File

@@ -29,9 +29,12 @@
#include "ortools/base/integral_types.h"
%}
// Typemaps to represent const std::vector<CType>& arguments as arrays of
// JavaType.
// Typemaps to represents arguments of types "const std::vector<CType>&" or
// "std::vector<CType>" as JavaType[] (<PrimitiveType>Array).
// note: CType must be a primitive data type (PDT).
// ref: https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/functions.html#Get_PrimitiveType_ArrayElements_routines
%define VECTOR_AS_JAVA_ARRAY(CType, JavaType, JavaTypeName)
// This part is for const std::vector<>&.
%typemap(jstype) const std::vector<CType>& #JavaType "[]"
%typemap(javain) const std::vector<CType>& "$javainput"
%typemap(jtype) const std::vector<CType>& #JavaType "[]"
@@ -64,8 +67,7 @@
%typemap(javaout) const std::vector<CType>& {
return $jnicall;
}
// Same, for std::vector<CType>
// Now, we do it for std::vector<>.
%typemap(jstype) std::vector<CType> #JavaType "[]"
%typemap(javain) std::vector<CType> "$javainput"
%typemap(jtype) std::vector<CType> #JavaType "[]"
@@ -101,9 +103,80 @@ VECTOR_AS_JAVA_ARRAY(int, int, Int);
VECTOR_AS_JAVA_ARRAY(int64, long, Long);
VECTOR_AS_JAVA_ARRAY(double, double, Double);
// Typemaps to represent const std::vector<std::vector<CType> >& arguments as
// an ObjectArray of JavaTypeArrays.
// Typemaps to represents arguments of types "const std::vector<CType*>&" or
// "std::vector<CType*>" as JavaType[] (ObjectArray).
// note: CType is NOT a primitive type.
// note: CastOp defines how to cast the output of CallStaticLongMethod to CType*;
// its first argument is CType, its second is the output of CallStaticLongMethod.
// ref: https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/functions.html#GetObjectArrayElement
%define CONVERT_VECTOR_WITH_CAST(CType, JavaType, CastOp, JavaPackage)
// This part is for const std::vector<CType*>&.
%typemap(jstype) const std::vector<CType*>& "JavaType[]"
%typemap(javain) const std::vector<CType*>& "$javainput"
%typemap(jtype) const std::vector<CType*>& "JavaType[]"
%typemap(jni) const std::vector<CType*>& "jobjectArray"
%typemap(in) const std::vector<CType*>& (std::vector<CType*> result) {
std::string java_class_path = #JavaPackage "/" #JavaType;
jclass object_class = jenv->FindClass(java_class_path.c_str());
if (nullptr == object_class)
return $null;
jmethodID method_id =
jenv->GetStaticMethodID(object_class,
"getCPtr",
std::string("(L" + java_class_path + ";)J").c_str());
assert(method_id != nullptr);
for (int i = 0; i < jenv->GetArrayLength($input); i++) {
jobject elem = jenv->GetObjectArrayElement($input, i);
jlong ptr_value = jenv->CallStaticLongMethod(object_class, method_id, elem);
result.push_back(CastOp(CType, ptr_value));
}
$1 = &result;
}
%typemap(out) const std::vector<CType*>& {
jclass object_class = jenv->FindClass("JavaPackage/JavaType");
$result = jenv->NewObjectArray($1->size(), object_class, 0);
if (nullptr != object_class) {
jmethodID ctor = jenv->GetMethodID(object_class,"<init>", "(JZ)V");
for (int i = 0; i < $1->size(); ++i) {
jlong obj_ptr = 0;
*((CType **)&obj_ptr) = (*$1)[i];
jobject elem = jenv->NewObject(object_class, ctor, obj_ptr, false);
jenv->SetObjectArrayElement($result, i, elem);
}
}
}
%typemap(javaout) const std::vector<CType*> & {
return $jnicall;
}
// Now, we do it for std::vector<CType*>.
%typemap(jstype) std::vector<CType*> "JavaType[]"
%typemap(javain) std::vector<CType*> "$javainput"
%typemap(jtype) std::vector<CType*> "JavaType[]"
%typemap(jni) std::vector<CType*> "jobjectArray"
%typemap(in) std::vector<CType*> (std::vector<CType*> result) {
jclass object_class = jenv->FindClass("JavaPackage/JavaType");
if (nullptr == object_class)
return $null;
jmethodID method_id = jenv->GetStaticMethodID(
object_class, "getCPtr", "(LJavaPackage/JavaType;)J");
assert(method_id != nullptr);
for (int i = 0; i < jenv->GetArrayLength($input); i++) {
jobject elem = jenv->GetObjectArrayElement($input, i);
jlong ptr_value = jenv->CallStaticLongMethod(object_class, method_id, elem);
$1.push_back(CastOp(CType, ptr_value));
}
}
%enddef // CONVERT_VECTOR_WITH_CAST
// Typemaps to represents arguments of types "const std::vector<std::vector<CType>>&" or
// "std::vector<std::vector<CType>>*" as JavaType[][] (ObjectArray of JavaTypeArrays).
// note: CType must be a primitive data type (PDT).
// ref: https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/functions.html#GetObjectArrayElement
// ref: https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/functions.html#Get_PrimitiveType_ArrayElements_routines
%define MATRIX_AS_JAVA_ARRAY(CType, JavaType, JavaTypeName)
// This part is for const std::vector<std::vector<>>&.
%typemap(jstype) const std::vector<std::vector<CType> >& #JavaType "[][]"
%typemap(javain) const std::vector<std::vector<CType> >& "$javainput"
%typemap(jtype) const std::vector<std::vector<CType> >& #JavaType "[][]"
@@ -134,8 +207,7 @@ VECTOR_AS_JAVA_ARRAY(double, double, Double);
return $null;
}
%}
// Same, for std::vector<std::vector<CType>>*
// Now, we do it for std::vector<std::vector<>>*
%typemap(jstype) std::vector<std::vector<CType> >* #JavaType "[][]"
%typemap(javain) std::vector<std::vector<CType> >* "$javainput"
%typemap(jtype) std::vector<std::vector<CType> >* #JavaType "[][]"
@@ -180,69 +252,6 @@ MATRIX_AS_JAVA_ARRAY(int, int, Int);
MATRIX_AS_JAVA_ARRAY(int64, long, Long);
MATRIX_AS_JAVA_ARRAY(double, double, Double);
// Same, for std::vector<CType*>, where CType is not a primitive type.
// CastOp defines how to cast the output of CallStaticLongMethod to CType*;
// its first argument is CType, its second is the output of
// CallStaticLongMethod.
%define CONVERT_VECTOR_WITH_CAST(CType, JavaType, CastOp, JavaPackage)
%typemap(jstype) const std::vector<CType*>& "JavaType[]"
%typemap(javain) const std::vector<CType*>& "$javainput"
%typemap(jtype) const std::vector<CType*>& "JavaType[]"
%typemap(jni) const std::vector<CType*>& "jobjectArray"
%typemap(in) const std::vector<CType*>& (std::vector<CType*> result) {
std::string java_class_path = #JavaPackage "/" #JavaType;
jclass object_class = jenv->FindClass(java_class_path.c_str());
if (nullptr == object_class)
return $null;
jmethodID method_id =
jenv->GetStaticMethodID(object_class,
"getCPtr",
std::string("(L" + java_class_path + ";)J").c_str());
assert(method_id != nullptr);
for (int i = 0; i < jenv->GetArrayLength($input); i++) {
jobject elem = jenv->GetObjectArrayElement($input, i);
jlong ptr_value = jenv->CallStaticLongMethod(object_class, method_id, elem);
result.push_back(CastOp(CType, ptr_value));
}
$1 = &result;
}
%typemap(out) const std::vector<CType*>& {
jclass object_class = jenv->FindClass("JavaPackage/JavaType");
$result = jenv->NewObjectArray($1->size(), object_class, 0);
if (nullptr != object_class) {
jmethodID ctor = jenv->GetMethodID(object_class,"<init>", "(JZ)V");
for (int i = 0; i < $1->size(); ++i) {
jlong obj_ptr = 0;
*((CType **)&obj_ptr) = (*$1)[i];
jobject elem = jenv->NewObject(object_class, ctor, obj_ptr, false);
jenv->SetObjectArrayElement($result, i, elem);
}
}
}
%typemap(javaout) const std::vector<CType*> & {
return $jnicall;
}
// Same, for std::vector<CType*>
%typemap(jstype) std::vector<CType*> "JavaType[]"
%typemap(javain) std::vector<CType*> "$javainput"
%typemap(jtype) std::vector<CType*> "JavaType[]"
%typemap(jni) std::vector<CType*> "jobjectArray"
%typemap(in) std::vector<CType*> (std::vector<CType*> result) {
jclass object_class = jenv->FindClass("JavaPackage/JavaType");
if (nullptr == object_class)
return $null;
jmethodID method_id = jenv->GetStaticMethodID(
object_class, "getCPtr", "(LJavaPackage/JavaType;)J");
assert(method_id != nullptr);
for (int i = 0; i < jenv->GetArrayLength($input); i++) {
jobject elem = jenv->GetObjectArrayElement($input, i);
jlong ptr_value = jenv->CallStaticLongMethod(object_class, method_id, elem);
$1.push_back(CastOp(CType, ptr_value));
}
}
%enddef
%define REINTERPRET_CAST(CType, ptr)
reinterpret_cast<CType*>(ptr)
%enddef