2025-01-10 11:35:44 +01:00
|
|
|
// Copyright 2010-2025 Google LLC
|
2014-06-13 09:55:36 +00:00
|
|
|
// 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
|
|
|
|
|
//
|
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
//
|
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
// 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.
|
2014-07-09 15:18:27 +00:00
|
|
|
|
2024-11-18 11:32:13 +01:00
|
|
|
// TODO(user): Refactor this file to adhere to the SWIG style guide.
|
|
|
|
|
|
2021-12-05 15:33:21 +01:00
|
|
|
%typemap(csimports) SWIGTYPE %{
|
|
|
|
|
using System;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
%}
|
|
|
|
|
|
2024-11-18 11:32:13 +01:00
|
|
|
%include "ortools/base/base.i"
|
2021-02-16 17:28:13 +01:00
|
|
|
%template(IntBoolPair) std::pair<int, bool>;
|
2017-04-26 17:30:25 +02:00
|
|
|
%include "ortools/constraint_solver/csharp/constraint_solver.i"
|
2024-11-18 11:32:13 +01:00
|
|
|
%import "ortools/util/csharp/sorted_interval_list.i" // Domain
|
|
|
|
|
|
2018-10-31 16:18:18 +01:00
|
|
|
%include "ortools/constraint_solver/csharp/routing_index_manager.i"
|
2014-06-12 15:07:04 +00:00
|
|
|
|
2016-02-03 15:15:58 +01:00
|
|
|
// We need to forward-declare the proto here, so that PROTO_INPUT involving it
|
|
|
|
|
// works correctly. The order matters very much: this declaration needs to be
|
|
|
|
|
// before the %{ #include ".../routing.h" %}.
|
|
|
|
|
namespace operations_research {
|
|
|
|
|
class RoutingModelParameters;
|
|
|
|
|
class RoutingSearchParameters;
|
2024-11-18 11:32:13 +01:00
|
|
|
class RoutingSearchStatus;
|
2016-02-03 15:15:58 +01:00
|
|
|
} // namespace operations_research
|
|
|
|
|
|
2014-06-12 15:07:04 +00:00
|
|
|
// Include the file we want to wrap a first time.
|
|
|
|
|
%{
|
2017-04-26 17:30:25 +02:00
|
|
|
#include "ortools/constraint_solver/routing.h"
|
2024-11-18 11:32:13 +01:00
|
|
|
#include "ortools/constraint_solver/routing_enums.pb.h"
|
2018-10-31 16:18:18 +01:00
|
|
|
#include "ortools/constraint_solver/routing_index_manager.h"
|
|
|
|
|
#include "ortools/constraint_solver/routing_parameters.h"
|
|
|
|
|
#include "ortools/constraint_solver/routing_parameters.pb.h"
|
|
|
|
|
#include "ortools/constraint_solver/routing_types.h"
|
2014-06-12 15:07:04 +00:00
|
|
|
%}
|
|
|
|
|
|
2014-07-10 14:29:46 +00:00
|
|
|
%module(directors="1") operations_research;
|
2017-09-03 05:36:59 -07:00
|
|
|
|
2019-02-26 17:39:29 +01:00
|
|
|
// RoutingModel methods.
|
|
|
|
|
DEFINE_INDEX_TYPE_TYPEDEF(
|
|
|
|
|
operations_research::RoutingCostClassIndex,
|
|
|
|
|
operations_research::RoutingModel::CostClassIndex);
|
|
|
|
|
DEFINE_INDEX_TYPE_TYPEDEF(
|
|
|
|
|
operations_research::RoutingDimensionIndex,
|
|
|
|
|
operations_research::RoutingModel::DimensionIndex);
|
|
|
|
|
DEFINE_INDEX_TYPE_TYPEDEF(
|
|
|
|
|
operations_research::RoutingDisjunctionIndex,
|
|
|
|
|
operations_research::RoutingModel::DisjunctionIndex);
|
|
|
|
|
DEFINE_INDEX_TYPE_TYPEDEF(
|
|
|
|
|
operations_research::RoutingVehicleClassIndex,
|
|
|
|
|
operations_research::RoutingModel::VehicleClassIndex);
|
2024-01-08 13:18:01 +01:00
|
|
|
DEFINE_INDEX_TYPE_TYPEDEF(
|
|
|
|
|
operations_research::RoutingResourceClassIndex,
|
|
|
|
|
operations_research::RoutingModel::ResourceClassIndex);
|
2016-03-12 06:32:56 -08:00
|
|
|
|
2019-01-18 17:39:13 +01:00
|
|
|
namespace operations_research {
|
|
|
|
|
|
2024-11-18 11:32:13 +01:00
|
|
|
// GlobalVehicleBreaksConstraint
|
|
|
|
|
%unignore GlobalVehicleBreaksConstraint;
|
|
|
|
|
%typemap(csimports) GlobalVehicleBreaksConstraint %{
|
|
|
|
|
%}
|
|
|
|
|
|
|
|
|
|
// PathsMetadata
|
|
|
|
|
%unignore PathsMetadata;
|
|
|
|
|
|
|
|
|
|
// RoutingDimension
|
|
|
|
|
%unignore RoutingDimension;
|
|
|
|
|
%typemap(csimports) RoutingDimension %{
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
%}
|
|
|
|
|
%typemap(cscode) RoutingDimension %{
|
|
|
|
|
// Keep reference to delegate to avoid GC to collect them early.
|
|
|
|
|
private List<IntIntToLong> limitCallbacks;
|
|
|
|
|
private IntIntToLong StoreIntIntToLong(IntIntToLong limit) {
|
|
|
|
|
if (limitCallbacks == null)
|
|
|
|
|
limitCallbacks = new List<IntIntToLong>();
|
|
|
|
|
limitCallbacks.Add(limit);
|
|
|
|
|
return limit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<LongLongToLong> groupDelayCallbacks;
|
|
|
|
|
private LongLongToLong StoreLongLongToLong(LongLongToLong groupDelay) {
|
|
|
|
|
if (groupDelayCallbacks == null)
|
|
|
|
|
groupDelayCallbacks = new List<LongLongToLong>();
|
|
|
|
|
groupDelayCallbacks.Add(groupDelay);
|
|
|
|
|
return groupDelay;
|
|
|
|
|
}
|
|
|
|
|
%}
|
|
|
|
|
%ignore RoutingDimension::GetBreakDistanceDurationOfVehicle;
|
|
|
|
|
|
2019-02-26 17:39:29 +01:00
|
|
|
// RoutingModel
|
|
|
|
|
%unignore RoutingModel;
|
2024-11-18 11:32:13 +01:00
|
|
|
%typemap(csimports) RoutingModel %{
|
2021-12-05 15:33:21 +01:00
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2024-11-18 11:32:13 +01:00
|
|
|
using Domain = Google.OrTools.Util.Domain;
|
2021-12-05 15:33:21 +01:00
|
|
|
%}
|
2019-01-18 17:39:13 +01:00
|
|
|
%typemap(cscode) RoutingModel %{
|
2019-02-26 17:39:29 +01:00
|
|
|
// Keep reference to delegate to avoid GC to collect them early.
|
|
|
|
|
private List<LongToLong> unaryTransitCallbacks;
|
|
|
|
|
private LongToLong StoreLongToLong(LongToLong c) {
|
|
|
|
|
if (unaryTransitCallbacks == null)
|
|
|
|
|
unaryTransitCallbacks = new List<LongToLong>();
|
2019-01-18 17:39:13 +01:00
|
|
|
unaryTransitCallbacks.Add(c);
|
|
|
|
|
return c;
|
|
|
|
|
}
|
2019-02-26 17:39:29 +01:00
|
|
|
|
|
|
|
|
private List<LongLongToLong> transitCallbacks;
|
|
|
|
|
private LongLongToLong StoreLongLongToLong(LongLongToLong c) {
|
|
|
|
|
if (transitCallbacks == null)
|
|
|
|
|
transitCallbacks = new List<LongLongToLong>();
|
2019-01-18 17:39:13 +01:00
|
|
|
transitCallbacks.Add(c);
|
|
|
|
|
return c;
|
|
|
|
|
}
|
2019-02-26 17:39:29 +01:00
|
|
|
|
|
|
|
|
private List<VoidToVoid> solutionCallbacks;
|
|
|
|
|
private VoidToVoid StoreVoidToVoid(VoidToVoid c) {
|
|
|
|
|
if (solutionCallbacks == null)
|
|
|
|
|
solutionCallbacks = new List<VoidToVoid>();
|
|
|
|
|
solutionCallbacks.Add(c);
|
2019-01-18 17:39:13 +01:00
|
|
|
return c;
|
|
|
|
|
}
|
|
|
|
|
%}
|
2024-11-18 11:32:13 +01:00
|
|
|
%rename("GetStatus") RoutingModel::status;
|
2019-02-26 17:39:29 +01:00
|
|
|
// Ignored:
|
|
|
|
|
%ignore RoutingModel::AddDimensionDependentDimensionWithVehicleCapacity;
|
2021-02-16 17:28:13 +01:00
|
|
|
|
2021-02-19 16:01:53 +01:00
|
|
|
%unignore RoutingModel::RegisterUnaryTransitVector;
|
|
|
|
|
%unignore RoutingModel::RegisterTransitMatrix;
|
2021-02-16 17:28:13 +01:00
|
|
|
|
2021-02-19 16:01:53 +01:00
|
|
|
%unignore RoutingModel::AddVectorDimension;
|
|
|
|
|
%unignore RoutingModel::AddMatrixDimension;
|
2021-02-15 09:33:22 +01:00
|
|
|
|
2019-05-13 16:51:25 +02:00
|
|
|
%ignore RoutingModel::AddSameVehicleRequiredTypeAlternatives;
|
2019-02-26 17:39:29 +01:00
|
|
|
%ignore RoutingModel::GetAllDimensionNames;
|
2020-01-17 11:20:51 +01:00
|
|
|
%ignore RoutingModel::GetAutomaticFirstSolutionStrategy;
|
2019-02-26 17:39:29 +01:00
|
|
|
%ignore RoutingModel::GetDeliveryIndexPairs;
|
|
|
|
|
%ignore RoutingModel::GetDimensions;
|
|
|
|
|
%ignore RoutingModel::GetDimensionsWithSoftAndSpanCosts;
|
|
|
|
|
%ignore RoutingModel::GetDimensionsWithSoftOrSpanCosts;
|
2020-01-17 11:20:51 +01:00
|
|
|
%ignore RoutingModel::GetGlobalDimensionCumulOptimizers;
|
2019-05-13 16:51:25 +02:00
|
|
|
%ignore RoutingModel::GetHardTypeIncompatibilitiesOfType;
|
2020-01-17 11:20:51 +01:00
|
|
|
%ignore RoutingModel::GetLocalDimensionCumulMPOptimizers;
|
|
|
|
|
%ignore RoutingModel::GetLocalDimensionCumulOptimizers;
|
|
|
|
|
%ignore RoutingModel::GetMutableGlobalCumulOptimizer;
|
|
|
|
|
%ignore RoutingModel::GetMutableLocalCumulOptimizer;
|
|
|
|
|
%ignore RoutingModel::GetMutableLocalCumulMPOptimizer;
|
2019-02-26 17:39:29 +01:00
|
|
|
%ignore RoutingModel::GetPerfectBinaryDisjunctions;
|
|
|
|
|
%ignore RoutingModel::GetPickupIndexPairs;
|
2019-05-13 16:51:25 +02:00
|
|
|
%ignore RoutingModel::HasTypeRegulations;
|
2019-02-26 17:39:29 +01:00
|
|
|
%ignore RoutingModel::MakeStateDependentTransit;
|
2020-01-17 11:20:51 +01:00
|
|
|
%ignore RoutingModel::PackCumulsOfOptimizerDimensionsFromAssignment;
|
2019-02-26 17:39:29 +01:00
|
|
|
%ignore RoutingModel::RegisterStateDependentTransitCallback;
|
2020-01-17 11:20:51 +01:00
|
|
|
%ignore RoutingModel::RemainingTime;
|
2019-02-26 17:39:29 +01:00
|
|
|
%ignore RoutingModel::StateDependentTransitCallback;
|
|
|
|
|
%ignore RoutingModel::SolveWithParameters(
|
|
|
|
|
const RoutingSearchParameters& search_parameters,
|
|
|
|
|
std::vector<const Assignment*>* solutions);
|
|
|
|
|
%ignore RoutingModel::SolveFromAssignmentWithParameters(
|
|
|
|
|
const Assignment* assignment,
|
|
|
|
|
const RoutingSearchParameters& search_parameters,
|
|
|
|
|
std::vector<const Assignment*>* solutions);
|
|
|
|
|
%ignore RoutingModel::TransitCallback;
|
|
|
|
|
%ignore RoutingModel::UnaryTransitCallbackOrNull;
|
|
|
|
|
|
2024-11-18 11:32:13 +01:00
|
|
|
// RoutingModelVisitor
|
|
|
|
|
%unignore RoutingModelVisitor;
|
|
|
|
|
%typemap(csimports) RoutingModelVisitor %{
|
2019-01-18 17:39:13 +01:00
|
|
|
%}
|
2019-02-26 17:39:29 +01:00
|
|
|
|
2022-10-20 18:06:52 +02:00
|
|
|
// SimpleBoundCosts
|
|
|
|
|
%unignore BoundCost;
|
|
|
|
|
%unignore SimpleBoundCosts;
|
|
|
|
|
%rename("GetBoundCost") SimpleBoundCosts::bound_cost;
|
|
|
|
|
%rename("GetSize") SimpleBoundCosts::Size;
|
|
|
|
|
|
2024-11-18 11:32:13 +01:00
|
|
|
// TypeRegulationsConstraint
|
|
|
|
|
%unignore TypeRegulationsConstraint;
|
|
|
|
|
%typemap(csimports) TypeRegulationsConstraint %{
|
|
|
|
|
%}
|
|
|
|
|
|
|
|
|
|
// TypeRegulationsChecker
|
|
|
|
|
%unignore TypeRegulationsChecker;
|
|
|
|
|
%ignore TypeRegulationsChecker::CheckVehicle;
|
|
|
|
|
|
2019-01-18 17:39:13 +01:00
|
|
|
} // namespace operations_research
|
|
|
|
|
|
2014-06-12 15:07:04 +00:00
|
|
|
%rename("%(camelcase)s", %$isfunction) "";
|
|
|
|
|
|
2016-02-03 15:15:58 +01:00
|
|
|
// Protobuf support
|
|
|
|
|
PROTO_INPUT(operations_research::RoutingSearchParameters,
|
|
|
|
|
Google.OrTools.ConstraintSolver.RoutingSearchParameters,
|
|
|
|
|
search_parameters)
|
|
|
|
|
PROTO_INPUT(operations_research::RoutingModelParameters,
|
|
|
|
|
Google.OrTools.ConstraintSolver.RoutingModelParameters,
|
|
|
|
|
parameters)
|
|
|
|
|
PROTO2_RETURN(operations_research::RoutingSearchParameters,
|
|
|
|
|
Google.OrTools.ConstraintSolver.RoutingSearchParameters)
|
|
|
|
|
PROTO2_RETURN(operations_research::RoutingModelParameters,
|
|
|
|
|
Google.OrTools.ConstraintSolver.RoutingModelParameters)
|
2024-11-18 11:32:13 +01:00
|
|
|
PROTO_ENUM_RETURN(operations_research::RoutingSearchStatus::Value,
|
|
|
|
|
Google.OrTools.ConstraintSolver.RoutingSearchStatus.Types.Value)
|
2016-02-03 15:15:58 +01:00
|
|
|
|
2024-11-18 11:32:13 +01:00
|
|
|
// Wrap routing includes
|
2019-02-18 15:27:32 +01:00
|
|
|
// TODO(user): Replace with %ignoreall/%unignoreall
|
|
|
|
|
//swiglint: disable include-h-allglobals
|
2018-10-31 16:18:18 +01:00
|
|
|
%include "ortools/constraint_solver/routing_parameters.h"
|
2017-04-26 17:30:25 +02:00
|
|
|
%include "ortools/constraint_solver/routing.h"
|