revamp c# layer, with methods accepting or returning vectors
This commit is contained in:
@@ -1,158 +0,0 @@
|
||||
/*
|
||||
Colors and images taken from the Sphinx (http://sphinx.pocoo.org/)
|
||||
"pyramid" theme.
|
||||
Sphinx is written by Georg Brandl and licensed under the BSD license.
|
||||
The "pyramid" theme comes from the Pyramid web framework project
|
||||
(http://readthedocs.org/docs/pyramid/en/latest/) and is designed by
|
||||
Blaise Laflamme.
|
||||
*/
|
||||
|
||||
body {
|
||||
font-family: Tahoma, Geneva, sans-serif;
|
||||
line-height:1.4em;
|
||||
margin:15px;
|
||||
background-color:#FFFFFF;
|
||||
}
|
||||
|
||||
.examples_list {
|
||||
padding:0 ! important;
|
||||
margin:0 ! important;
|
||||
}
|
||||
|
||||
img {border:none;}
|
||||
a { text-decoration: none;}
|
||||
a:visited { color: #2929ff;}
|
||||
a:hover { color: #0000ff;}
|
||||
|
||||
#wrap {
|
||||
margin:0 auto;
|
||||
max-width:1024px;
|
||||
min-width:480px;
|
||||
position:relative;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size:1.8em;
|
||||
font-weight:bold;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size:1.1em;
|
||||
font-weight:bold;
|
||||
margin:10px 0px 10px 0px;
|
||||
}
|
||||
|
||||
.empty {
|
||||
color: #D8D8D8;
|
||||
}
|
||||
|
||||
.rightmenu {
|
||||
float:right;
|
||||
margin:10px 30px 10px 30px;
|
||||
}
|
||||
.description {
|
||||
margin-top:10px;
|
||||
font-size:1.2em;
|
||||
}
|
||||
.toolbar {
|
||||
margin-top:20px;
|
||||
}
|
||||
.footer {
|
||||
font-size:.8em;
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
li {
|
||||
margin:1px 0px 1px 0px;
|
||||
}
|
||||
|
||||
dl{
|
||||
width:100%;
|
||||
overflow:hidden;
|
||||
}
|
||||
dt {
|
||||
float:left;
|
||||
width:10%; /* adjust the width; make sure the total of both is 100% */
|
||||
text-decoration: underline;
|
||||
}
|
||||
dd.examples_list {
|
||||
float:left;
|
||||
width:90%; /* adjust the width; make sure the total of both is 100% */
|
||||
}
|
||||
|
||||
|
||||
|
||||
.language {
|
||||
font-variant: small-caps;
|
||||
font-weight: bold;
|
||||
|
||||
}
|
||||
|
||||
/* Progress bars */
|
||||
|
||||
.progress_background {
|
||||
padding:0px;
|
||||
background:#F2F1F0; /* #F5F5F5; #F1F1F1; */
|
||||
}
|
||||
|
||||
|
||||
.progress_foreground_green {
|
||||
/* background:#00FF00; */
|
||||
background: #98FB98; /* #C0EF4A; */
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
.progress_foreground_red {
|
||||
/* background:#FF0000; */
|
||||
background:#FE8181; /* #FF4500; #FEEFB3;*/
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
|
||||
/* Admonitions */
|
||||
|
||||
.seealso, .warning, .note, .topic, .safe_trees {
|
||||
border: 1px solid;
|
||||
margin: 10px 0px;
|
||||
padding:15px 10px 15px 50px;
|
||||
background-repeat: no-repeat;
|
||||
background-position: 10px center;
|
||||
}
|
||||
.seealso {
|
||||
color: #4F8A10;
|
||||
background-color: #DFF2BF;
|
||||
background-image: url('dialog-seealso.png');
|
||||
}
|
||||
.warning {
|
||||
color: #D8000C;
|
||||
background-color: #FFBABA;
|
||||
background-image:url('dialog-warning.png');
|
||||
}
|
||||
.note {
|
||||
color: #9F6000;
|
||||
background-color: #FEEFB3;
|
||||
background-image: url('dialog-note.png');
|
||||
}
|
||||
.topic {
|
||||
color: #00529B;
|
||||
background-color: #BDE5F8;
|
||||
background-image: url('dialog-topic.png');
|
||||
}
|
||||
|
||||
.safe_trees {
|
||||
color: #338C1E;
|
||||
background-color: #C0EF4A; /*#A8D141;*/
|
||||
background-image: url('earth.png');
|
||||
}
|
||||
|
||||
.code_line {
|
||||
background: #E6E6E6; /* #C0EF4A; */
|
||||
background-repeat: no-repeat;
|
||||
font-family: "Courier New", Courier, monospace;
|
||||
font-stretch: condensed;
|
||||
font-size: -80%;
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
.hidden { display: none; }
|
||||
.unhidden { display: block; }
|
||||
@@ -1,595 +0,0 @@
|
||||
/*
|
||||
* basic.css
|
||||
* ~~~~~~~~~
|
||||
*
|
||||
* Sphinx stylesheet -- basic theme.
|
||||
*
|
||||
* :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS.
|
||||
* :license: BSD, see LICENSE for details.
|
||||
*
|
||||
*/
|
||||
|
||||
/* -- main layout ----------------------------------------------------------- */
|
||||
|
||||
div.clearer {
|
||||
clear: both;
|
||||
}
|
||||
|
||||
/* -- relbar ---------------------------------------------------------------- */
|
||||
|
||||
div.related {
|
||||
width: 100%;
|
||||
font-size: 90%;
|
||||
}
|
||||
|
||||
div.related h3 {
|
||||
display: none;
|
||||
}
|
||||
|
||||
div.related ul {
|
||||
margin: 0;
|
||||
padding: 0 0 0 10px;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
div.related li {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
div.related li.right {
|
||||
float: right;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
/* -- sidebar --------------------------------------------------------------- */
|
||||
|
||||
div.sphinxsidebarwrapper {
|
||||
padding: 10px 5px 0 10px;
|
||||
}
|
||||
|
||||
div.sphinxsidebar {
|
||||
float: left;
|
||||
width: 270px;
|
||||
margin-left: -100%;
|
||||
font-size: 90%;
|
||||
}
|
||||
|
||||
div.sphinxsidebar ul {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
div.sphinxsidebar ul ul,
|
||||
div.sphinxsidebar ul.want-points {
|
||||
margin-left: 20px;
|
||||
list-style: square;
|
||||
}
|
||||
|
||||
div.sphinxsidebar ul ul {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
div.sphinxsidebar form {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
div.sphinxsidebar input {
|
||||
border: 1px solid #98dbcc;
|
||||
font-family: sans-serif;
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
div.sphinxsidebar input[type="text"] {
|
||||
width: 170px;
|
||||
}
|
||||
|
||||
div.sphinxsidebar input[type="submit"] {
|
||||
width: 30px;
|
||||
}
|
||||
|
||||
div.sphinxsidebar div.sphinxsidebarwrapper h2 {
|
||||
# font-size: 1.875em;
|
||||
# margin:25px -30px 25px;
|
||||
}
|
||||
|
||||
img {
|
||||
border: 0;
|
||||
}
|
||||
|
||||
/* -- search page ----------------------------------------------------------- */
|
||||
|
||||
ul.search {
|
||||
margin: 10px 0 0 20px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
ul.search li {
|
||||
padding: 5px 0 5px 20px;
|
||||
background-image: url(file.png);
|
||||
background-repeat: no-repeat;
|
||||
background-position: 0 7px;
|
||||
}
|
||||
|
||||
ul.search li a {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
ul.search li div.context {
|
||||
color: #888;
|
||||
margin: 2px 0 0 30px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
ul.keywordmatches li.goodmatch a {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* -- index page ------------------------------------------------------------ */
|
||||
|
||||
table.contentstable {
|
||||
width: 90%;
|
||||
}
|
||||
|
||||
table.contentstable p.biglink {
|
||||
line-height: 150%;
|
||||
}
|
||||
|
||||
a.biglink {
|
||||
font-size: 1.3em;
|
||||
}
|
||||
|
||||
span.linkdescr {
|
||||
font-style: italic;
|
||||
padding-top: 5px;
|
||||
font-size: 90%;
|
||||
}
|
||||
|
||||
/* -- general index --------------------------------------------------------- */
|
||||
|
||||
table.indextable {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
table.indextable td {
|
||||
text-align: left;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
table.indextable dl, table.indextable dd {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
table.indextable tr.pcap {
|
||||
height: 10px;
|
||||
}
|
||||
|
||||
table.indextable tr.cap {
|
||||
margin-top: 10px;
|
||||
background-color: #f2f2f2;
|
||||
}
|
||||
|
||||
|
||||
.table {
|
||||
align: center;
|
||||
}
|
||||
|
||||
img.toggler {
|
||||
margin-right: 3px;
|
||||
margin-top: 3px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
div.modindex-jumpbox {
|
||||
border-top: 1px solid #ddd;
|
||||
border-bottom: 1px solid #ddd;
|
||||
margin: 1em 0 1em 0;
|
||||
padding: 0.4em;
|
||||
}
|
||||
|
||||
div.genindex-jumpbox {
|
||||
border-top: 1px solid #ddd;
|
||||
border-bottom: 1px solid #ddd;
|
||||
margin: 1em 0 1em 0;
|
||||
padding: 0.4em;
|
||||
}
|
||||
|
||||
/* -- general body styles --------------------------------------------------- */
|
||||
|
||||
a.headerlink {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
h1:hover > a.headerlink,
|
||||
h2:hover > a.headerlink,
|
||||
h3:hover > a.headerlink,
|
||||
h4:hover > a.headerlink,
|
||||
h5:hover > a.headerlink,
|
||||
h6:hover > a.headerlink,
|
||||
dt:hover > a.headerlink {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
div.body p.caption {
|
||||
text-align: inherit;
|
||||
}
|
||||
|
||||
div.body td {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.field-list ul {
|
||||
padding-left: 1em;
|
||||
}
|
||||
|
||||
.first {
|
||||
margin-top: 0 !important;
|
||||
}
|
||||
|
||||
p.rubric {
|
||||
margin-top: 30px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
img.align-left, .figure.align-left, object.align-left {
|
||||
clear: left;
|
||||
float: left;
|
||||
margin-right: 1em;
|
||||
}
|
||||
|
||||
img.align-right, .figure.align-right, object.align-right {
|
||||
clear: right;
|
||||
float: right;
|
||||
margin-left: 1em;
|
||||
}
|
||||
|
||||
img.align-center, .figure.align-center, object.align-center {
|
||||
display: block;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.align-left {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.align-center {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.align-right {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
/* -- sidebars -------------------------------------------------------------- */
|
||||
|
||||
div.sidebar {
|
||||
margin: 0 0 0.5em 1em;
|
||||
border: 1px solid #ddb;
|
||||
padding: 7px 7px 0 7px;
|
||||
background-color: #ffe;
|
||||
width: 40%;
|
||||
float: right;
|
||||
}
|
||||
|
||||
p.sidebar-title {
|
||||
font-weight: bold;
|
||||
|
||||
}
|
||||
|
||||
/* -- files-sidebar----------------------------------------------------- */
|
||||
|
||||
/* -- files-sidebar----------------------------------------------------- */
|
||||
|
||||
div.files-sidebar {
|
||||
margin: 0 0 0.5em 1em;
|
||||
border: 1px solid #ddb;
|
||||
padding: 0px 0px 0px 7px;
|
||||
background-color: #FFFFFF;
|
||||
width: 200px;
|
||||
float: right;
|
||||
|
||||
}
|
||||
|
||||
div.files-sidebar p {
|
||||
font-family: 'Trebuchet MS', sans-serif;
|
||||
font-size: 18px;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
div.files-sidebar { color:#eee; }
|
||||
div.files-sidebar ol {
|
||||
font-size:16px;
|
||||
color: #20435C;
|
||||
padding:0;
|
||||
margin:0;
|
||||
}
|
||||
div.files-sidebar ol li {
|
||||
list-style-type: none;
|
||||
|
||||
padding:0;
|
||||
margin:0;
|
||||
}
|
||||
div.files-sidebar ol li ol { list-style-image: url("nested.png"); padding:5px 0 5px 18px; font-size:15px; text-decoration: none; }
|
||||
div.files-sidebar ol li ol li { color:#D80000; height:15px; margin-left:10px; color: #9A0303; text-decoration: none; }
|
||||
div.files-sidebar ol li ol li a { color:#D80000; height:15px; color: #9A0303; text-decoration: none;}
|
||||
div.files-sidebar ol li ol li a:hover { color: #D80000; height:15px; color: #9A0303; text-decoration: underline;}
|
||||
|
||||
|
||||
/* -- topics ---------------------------------------------------------------- */
|
||||
|
||||
div.topic {
|
||||
border: 1px solid #ccc;
|
||||
padding: 7px 7px 0 7px;
|
||||
margin: 10px 0 10px 0;
|
||||
}
|
||||
|
||||
p.topic-title {
|
||||
font-size: 1.1em;
|
||||
font-weight: bold;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
/* -- admonitions ----------------------------------------------------------- */
|
||||
|
||||
div.admonition {
|
||||
margin-top: 10px;
|
||||
margin-bottom: 10px;
|
||||
padding: 7px;
|
||||
}
|
||||
|
||||
div.admonition dt {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
div.admonition dl {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
p.admonition-title {
|
||||
margin: 0px 10px 5px 0px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
div.body p.centered {
|
||||
text-align: center;
|
||||
margin-top: 25px;
|
||||
}
|
||||
|
||||
/* -- tables ---------------------------------------------------------------- */
|
||||
|
||||
table.docutils {
|
||||
border: 0;
|
||||
border-collapse: collapse;
|
||||
align: center;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
table.docutils td, table.docutils th {
|
||||
padding: 1px 8px 1px 5px;
|
||||
border-top: 0;
|
||||
border-left: 0;
|
||||
border-right: 0;
|
||||
border-bottom: 1px solid #aaa;
|
||||
}
|
||||
|
||||
table.field-list td, table.field-list th {
|
||||
border: 0 !important;
|
||||
}
|
||||
|
||||
table.footnote td, table.footnote th {
|
||||
border: 0 !important;
|
||||
}
|
||||
|
||||
th {
|
||||
text-align: left;
|
||||
padding-right: 5px;
|
||||
}
|
||||
|
||||
table.citation {
|
||||
border-left: solid 1px gray;
|
||||
margin-left: 1px;
|
||||
}
|
||||
|
||||
table.citation td {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
/* -- other body styles ----------------------------------------------------- */
|
||||
|
||||
ol.arabic {
|
||||
list-style: decimal;
|
||||
}
|
||||
|
||||
ol.loweralpha {
|
||||
list-style: lower-alpha;
|
||||
}
|
||||
|
||||
ol.upperalpha {
|
||||
list-style: upper-alpha;
|
||||
}
|
||||
|
||||
ol.lowerroman {
|
||||
list-style: lower-roman;
|
||||
}
|
||||
|
||||
ol.upperroman {
|
||||
list-style: upper-roman;
|
||||
}
|
||||
|
||||
dl {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
dd p {
|
||||
margin-top: 0px;
|
||||
}
|
||||
|
||||
dd ul, dd table {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
dd {
|
||||
margin-top: 3px;
|
||||
margin-bottom: 10px;
|
||||
margin-left: 30px;
|
||||
}
|
||||
|
||||
dt:target, .highlighted {
|
||||
background-color: #fbe54e;
|
||||
}
|
||||
|
||||
dl.glossary dt {
|
||||
font-weight: bold;
|
||||
font-size: 1.1em;
|
||||
}
|
||||
|
||||
.field-list ul {
|
||||
margin: 0;
|
||||
padding-left: 1em;
|
||||
}
|
||||
|
||||
.field-list p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.refcount {
|
||||
color: #060;
|
||||
}
|
||||
|
||||
.optional {
|
||||
font-size: 1.3em;
|
||||
}
|
||||
|
||||
.versionmodified {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.system-message {
|
||||
background-color: #fda;
|
||||
padding: 5px;
|
||||
border: 3px solid red;
|
||||
}
|
||||
|
||||
.footnote:target {
|
||||
background-color: #ffa;
|
||||
}
|
||||
|
||||
.line-block {
|
||||
display: block;
|
||||
margin-top: 1em;
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
.line-block .line-block {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
margin-left: 1.5em;
|
||||
}
|
||||
|
||||
.guilabel, .menuselection {
|
||||
font-family: sans-serif;
|
||||
}
|
||||
|
||||
.accelerator {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.classifier {
|
||||
font-style: oblique;
|
||||
}
|
||||
|
||||
abbr, acronym {
|
||||
border-bottom: dotted 1px;
|
||||
cursor: help;
|
||||
}
|
||||
|
||||
/* -- code displays --------------------------------------------------------- */
|
||||
|
||||
pre {
|
||||
overflow: auto;
|
||||
overflow-y: hidden; /* fixes display issues on Chrome browsers */
|
||||
}
|
||||
|
||||
td.linenos pre {
|
||||
padding: 5px 0px;
|
||||
border: 0;
|
||||
background-color: transparent;
|
||||
color: #aaa;
|
||||
}
|
||||
|
||||
table.highlighttable {
|
||||
margin-left: 0.5em;
|
||||
}
|
||||
|
||||
table.highlighttable td {
|
||||
padding: 0 0.5em 0 0.5em;
|
||||
}
|
||||
|
||||
tt.descname {
|
||||
background-color: transparent;
|
||||
font-weight: bold;
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
tt.descclassname {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
tt.xref, a tt {
|
||||
background-color: transparent;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
h1 tt, h2 tt, h3 tt, h4 tt, h5 tt, h6 tt {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.viewcode-link {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.viewcode-back {
|
||||
float: right;
|
||||
font-family: sans-serif;
|
||||
}
|
||||
|
||||
div.viewcode-block:target {
|
||||
margin: -1px -10px;
|
||||
padding: 0 10px;
|
||||
}
|
||||
|
||||
/* -- math display ---------------------------------------------------------- */
|
||||
|
||||
img.math {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
div.body div.math p {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
span.eqno {
|
||||
float: right;
|
||||
}
|
||||
|
||||
/* -- printout stylesheet --------------------------------------------------- */
|
||||
|
||||
@media print {
|
||||
div.document,
|
||||
div.documentwrapper,
|
||||
div.bodywrapper {
|
||||
margin: 0 !important;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
div.sphinxsidebar,
|
||||
div.related,
|
||||
div.footer,
|
||||
#top-link {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ public class OneVarLns : BaseLNS
|
||||
index_ = 0;
|
||||
}
|
||||
|
||||
public override bool NextFragment(IntVector fragment)
|
||||
public override bool NextFragment(CpIntVector fragment)
|
||||
{
|
||||
int size = Size();
|
||||
if (index_ < size)
|
||||
|
||||
@@ -83,12 +83,10 @@ $(GEN_DIR)/constraint_solver/constraint_solver_csharp_wrap.cc: \
|
||||
$(SWIG_BINARY) $(SWIG_INC) -I$(INC_DIR) -c++ -csharp -o $(GEN_DIR)$Sconstraint_solver$Sconstraint_solver_csharp_wrap.cc -module operations_research_constraint_solver -namespace Google.OrTools.ConstraintSolver -dllimport "Google.OrTools.$(DYNAMIC_SWIG_LIB_SUFFIX)" -outdir $(GEN_DIR)$Scom$Sgoogle$Sortools$Sconstraintsolver $(SRC_DIR)$Sconstraint_solver$Scsharp$Srouting.swig
|
||||
$(SED) -i -e 's/CSharp_new_Solver/CSharp_new_CpSolver/g' $(GEN_DIR)/com/google/ortools/constraintsolver/*cs $(GEN_DIR)/constraint_solver/constraint_solver_csharp_wrap.*
|
||||
$(SED) -i -e 's/CSharp_delete_Solver/CSharp_delete_CpSolver/g' $(GEN_DIR)/com/google/ortools/constraintsolver/*cs $(GEN_DIR)/constraint_solver/constraint_solver_csharp_wrap.*
|
||||
$(SED) -i -e 's/CSharp_Solver_Solve/CSharp_CpSolver_Solve/g' $(GEN_DIR)/com/google/ortools/constraintsolver/*cs $(GEN_DIR)/constraint_solver/constraint_solver_csharp_wrap.*
|
||||
$(SED) -i -e 's/CSharp_Solver_WallTime/CSharp_CpSolver_WallTime/g' $(GEN_DIR)/com/google/ortools/constraintsolver/*cs $(GEN_DIR)/constraint_solver/constraint_solver_csharp_wrap.*
|
||||
$(SED) -i -e 's/CSharp_Solver_WallTime/CSharp_CpSolver_WallTime/g' $(GEN_DIR)/com/google/ortools/constraintsolver/*cs $(GEN_DIR)/constraint_solver/constraint_solver_csharp_wrap.*
|
||||
$(SED) -i -e 's/CSharp_Solver_Constraints/CSharp_CpSolver_Constraints/g' $(GEN_DIR)/com/google/ortools/constraintsolver/*cs $(GEN_DIR)/constraint_solver/constraint_solver_csharp_wrap.*
|
||||
$(SED) -i -e 's/CSharp_delete_Constraint/CSharp_delete_CpConstraint/g' $(GEN_DIR)/com/google/ortools/constraintsolver/*cs $(GEN_DIR)/constraint_solver/constraint_solver_csharp_wrap.*
|
||||
$(SED) -i -e 's/CSharp_Solver/CSharp_CpSolver/g' $(GEN_DIR)/com/google/ortools/constraintsolver/*cs $(GEN_DIR)/constraint_solver/constraint_solver_csharp_wrap.*
|
||||
$(SED) -i -e 's/CSharp_new_Constraint/CSharp_new_CpConstraint/g' $(GEN_DIR)/com/google/ortools/constraintsolver/*cs $(GEN_DIR)/constraint_solver/constraint_solver_csharp_wrap.*
|
||||
$(SED) -i -e 's/CSharp_delete_Constraint/CSharp_delete_CpConstraint/g' $(GEN_DIR)/com/google/ortools/constraintsolver/*cs $(GEN_DIR)/constraint_solver/constraint_solver_csharp_wrap.*
|
||||
$(SED) -i -e 's/CSharp_Constraint/CSharp_CpConstraint/g' $(GEN_DIR)/com/google/ortools/constraintsolver/*cs $(GEN_DIR)/constraint_solver/constraint_solver_csharp_wrap.*
|
||||
|
||||
$(OBJ_DIR)/swig/constraint_solver_csharp_wrap.$O: \
|
||||
$(GEN_DIR)/constraint_solver/constraint_solver_csharp_wrap.cc
|
||||
@@ -123,17 +121,19 @@ $(BIN_DIR)/Google.OrTools.dll: \
|
||||
$(SRC_DIR)/com/google/ortools/constraintsolver/IntVarArrayHelper.cs \
|
||||
$(SRC_DIR)/com/google/ortools/constraintsolver/IntervalVarArrayHelper.cs \
|
||||
$(SRC_DIR)/com/google/ortools/constraintsolver/IntArrayHelper.cs \
|
||||
$(SRC_DIR)/com/google/ortools/constraintsolver/SolverHelper.cs \
|
||||
$(SRC_DIR)/com/google/ortools/constraintsolver/ValCstPair.cs \
|
||||
$(SRC_DIR)/com/google/ortools/constraintsolver/NetDecisionBuilder.cs \
|
||||
$(SRC_DIR)/com/google/ortools/linearsolver/LinearExpr.cs \
|
||||
$(SRC_DIR)/com/google/ortools/linearsolver/LinearConstraint.cs \
|
||||
$(SRC_DIR)/com/google/ortools/algorithms/IntArrayHelper.cs \
|
||||
$(SRC_DIR)/com/google/ortools/util/NestedArrayHelper.cs \
|
||||
$(STATIC_ALL_DEPS)
|
||||
ifeq ($(SYSTEM),win)
|
||||
$(CSC) /target:module /out:$(LIB_DIR)$S$(LIBPREFIX)Google.OrTools.netmodule /warn:0 /nologo /debug $(GEN_DIR)\\com\\google\\ortools\\linearsolver\\*.cs $(SRC_DIR)\\com\\google\\ortools\\linearsolver\\*.cs $(GEN_DIR)\\com\\google\\ortools\\constraintsolver\\*.cs $(SRC_DIR)\\com\\google\\ortools\\constraintsolver\\*.cs $(GEN_DIR)\\com\\google\\ortools\\knapsacksolver\\*.cs $(GEN_DIR)\\com\\google\\ortools\\graph\\*.cs $(SRC_DIR)\\com\\google\\ortools\\util\\*.cs
|
||||
$(CSC) /target:module /out:$(LIB_DIR)$S$(LIBPREFIX)Google.OrTools.netmodule /warn:0 /nologo /debug $(GEN_DIR)\\com\\google\\ortools\\linearsolver\\*.cs $(SRC_DIR)\\com\\google\\ortools\\linearsolver\\*.cs $(GEN_DIR)\\com\\google\\ortools\\constraintsolver\\*.cs $(SRC_DIR)\\com\\google\\ortools\\constraintsolver\\*.cs $(GEN_DIR)\\com\\google\\ortools\\knapsacksolver\\*.cs $(SRC_DIR)\\com\\google\\ortools\algorithms\\*cs $(GEN_DIR)\\com\\google\\ortools\\graph\\*.cs $(SRC_DIR)\\com\\google\\ortools\\util\\*.cs
|
||||
$(DYNAMIC_LD) $(SIGNING_FLAGS) $(LDOUT)$(BIN_DIR)$SGoogle.OrTools.dll $(LIB_DIR)$S$(LIBPREFIX)Google.OrTools.netmodule $(OBJ_DIR)$Sswig$Slinear_solver_csharp_wrap.$O $(OBJ_DIR)$Sswig$Sconstraint_solver_csharp_wrap.$O $(OBJ_DIR)$Sswig$Sknapsack_solver_csharp_wrap.$O $(OBJ_DIR)$Sswig$Sgraph_csharp_wrap.$O $(STATIC_ALL_LNK) $(STATIC_LD_FLAGS)
|
||||
else
|
||||
$(CSC) /target:library /out:$(BIN_DIR)/Google.OrTools.dll /warn:0 /nologo /debug $(SRC_DIR)/com/google/ortools/util/*.cs $(GEN_DIR)/com/google/ortools/linearsolver/*.cs $(SRC_DIR)/com/google/ortools/linearsolver/*.cs $(GEN_DIR)/com/google/ortools/constraintsolver/*.cs $(SRC_DIR)/com/google/ortools/constraintsolver/*.cs $(GEN_DIR)/com/google/ortools/knapsacksolver/*.cs $(GEN_DIR)/com/google/ortools/graph/*.cs
|
||||
$(CSC) /target:library /out:$(BIN_DIR)/Google.OrTools.dll /warn:0 /nologo /debug $(SRC_DIR)/com/google/ortools/util/*.cs $(GEN_DIR)/com/google/ortools/linearsolver/*.cs $(SRC_DIR)/com/google/ortools/linearsolver/*.cs $(GEN_DIR)/com/google/ortools/constraintsolver/*.cs $(SRC_DIR)/com/google/ortools/constraintsolver/*.cs $(GEN_DIR)/com/google/ortools/knapsacksolver/*.cs $(SRC_DIR)/com/google/ortools/algorithms/*cs $(GEN_DIR)/com/google/ortools/graph/*.cs
|
||||
$(DYNAMIC_LD) $(LDOUT)$(LIB_DIR)$S$(LIBPREFIX)Google.OrTools.$(DYNAMIC_SWIG_LIB_SUFFIX) $(OBJ_DIR)/swig/linear_solver_csharp_wrap.$O $(OBJ_DIR)/swig/constraint_solver_csharp_wrap.$O $(OBJ_DIR)/swig/knapsack_solver_csharp_wrap.$O $(OBJ_DIR)/swig/graph_csharp_wrap.$O $(STATIC_ALL_LNK) $(STATIC_LD_FLAGS)
|
||||
endif
|
||||
|
||||
|
||||
@@ -20,6 +20,11 @@
|
||||
#include "algorithms/knapsack_solver.h"
|
||||
%}
|
||||
|
||||
%include "std_vector.i"
|
||||
|
||||
%template(KIntVector) std::vector<int>;
|
||||
%template(KInt64Vector) std::vector<int64>;
|
||||
|
||||
%rename (UseReduction) operations_research::KnapsackSolver::use_reduction;
|
||||
%rename (SetUseReduction) operations_research::KnapsackSolver::set_use_reduction;
|
||||
|
||||
|
||||
61
src/com/google/ortools/algorithms/IntArrayHelper.cs
Normal file
61
src/com/google/ortools/algorithms/IntArrayHelper.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
// Copyright 2010-2014 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
|
||||
//
|
||||
// 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.
|
||||
|
||||
namespace Google.OrTools.Algorithms {
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public partial class KInt64Vector: IDisposable, System.Collections.IEnumerable
|
||||
#if !SWIG_DOTNET_1
|
||||
, System.Collections.Generic.IList<long>
|
||||
#endif
|
||||
{
|
||||
// cast from C# long array
|
||||
public static implicit operator KInt64Vector(long[] inVal) {
|
||||
var outVal= new KInt64Vector();
|
||||
foreach (long element in inVal) {
|
||||
outVal.Add(element);
|
||||
}
|
||||
return outVal;
|
||||
}
|
||||
|
||||
// cast to C# long array
|
||||
public static implicit operator long[](KInt64Vector inVal) {
|
||||
var outVal= new long[inVal.Count];
|
||||
inVal.CopyTo(outVal);
|
||||
return outVal;
|
||||
}
|
||||
}
|
||||
|
||||
public partial class KIntVector: IDisposable, System.Collections.IEnumerable
|
||||
#if !SWIG_DOTNET_1
|
||||
, System.Collections.Generic.IList<int>
|
||||
#endif
|
||||
{
|
||||
// cast from C# int array
|
||||
public static implicit operator KIntVector(int[] inVal) {
|
||||
var outVal= new KIntVector();
|
||||
foreach (int element in inVal) {
|
||||
outVal.Add(element);
|
||||
}
|
||||
return outVal;
|
||||
}
|
||||
|
||||
// cast to C# int array
|
||||
public static implicit operator int[](KIntVector inVal) {
|
||||
var outVal= new int[inVal.Count];
|
||||
inVal.CopyTo(outVal);
|
||||
return outVal;
|
||||
}
|
||||
}
|
||||
} // namespace Google.OrTools.Algorithms
|
||||
@@ -12,16 +12,60 @@
|
||||
// limitations under the License.
|
||||
|
||||
namespace Google.OrTools.ConstraintSolver {
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
// int[] and long[] helper class.
|
||||
public static class IntArrayHelper {
|
||||
public static IntExpr Element(this int[] array, IntExpr index) {
|
||||
return index.solver().MakeElement(array, index.Var());
|
||||
}
|
||||
public static IntExpr Element(this long[] array, IntExpr index) {
|
||||
return index.solver().MakeElement(array, index.Var());
|
||||
}
|
||||
// int[] and long[] helper class.
|
||||
public static class IntArrayHelper {
|
||||
public static IntExpr Element(this int[] array, IntExpr index) {
|
||||
return index.solver().MakeElement(array, index.Var());
|
||||
}
|
||||
public static IntExpr Element(this long[] array, IntExpr index) {
|
||||
return index.solver().MakeElement(array, index.Var());
|
||||
}
|
||||
}
|
||||
|
||||
public partial class CpInt64Vector: IDisposable, System.Collections.IEnumerable
|
||||
#if !SWIG_DOTNET_1
|
||||
, System.Collections.Generic.IList<long>
|
||||
#endif
|
||||
{
|
||||
// cast from C# long array
|
||||
public static implicit operator CpInt64Vector(long[] inVal) {
|
||||
var outVal= new CpInt64Vector();
|
||||
foreach (long element in inVal) {
|
||||
outVal.Add(element);
|
||||
}
|
||||
return outVal;
|
||||
}
|
||||
|
||||
// cast to C# long array
|
||||
public static implicit operator long[](CpInt64Vector inVal) {
|
||||
var outVal= new long[inVal.Count];
|
||||
inVal.CopyTo(outVal);
|
||||
return outVal;
|
||||
}
|
||||
}
|
||||
|
||||
public partial class CpIntVector: IDisposable, System.Collections.IEnumerable
|
||||
#if !SWIG_DOTNET_1
|
||||
, System.Collections.Generic.IList<int>
|
||||
#endif
|
||||
{
|
||||
// cast from C# int array
|
||||
public static implicit operator CpIntVector(int[] inVal) {
|
||||
var outVal= new CpIntVector();
|
||||
foreach (int element in inVal) {
|
||||
outVal.Add(element);
|
||||
}
|
||||
return outVal;
|
||||
}
|
||||
|
||||
// cast to C# int array
|
||||
public static implicit operator int[](CpIntVector inVal) {
|
||||
var outVal= new int[inVal.Count];
|
||||
inVal.CopyTo(outVal);
|
||||
return outVal;
|
||||
}
|
||||
}
|
||||
} // namespace Google.OrTools.ConstraintSolver
|
||||
|
||||
@@ -189,4 +189,180 @@ namespace Google.OrTools.ConstraintSolver
|
||||
return flat;
|
||||
}
|
||||
}
|
||||
|
||||
public partial class CpIntVarVector: IDisposable, System.Collections.IEnumerable
|
||||
#if !SWIG_DOTNET_1
|
||||
, System.Collections.Generic.IList<IntVar>
|
||||
#endif
|
||||
{
|
||||
// cast from C# long array
|
||||
public static implicit operator CpIntVarVector(IntVar[] inVal) {
|
||||
var outVal= new CpIntVarVector();
|
||||
foreach (IntVar element in inVal) {
|
||||
outVal.Add(element);
|
||||
}
|
||||
return outVal;
|
||||
}
|
||||
|
||||
// cast to C# IntVar array
|
||||
public static implicit operator IntVar[](CpIntVarVector inVal) {
|
||||
var outVal= new IntVar[inVal.Count];
|
||||
inVal.CopyTo(outVal);
|
||||
return outVal;
|
||||
}
|
||||
}
|
||||
|
||||
public partial class CpSearchMonitorVector: IDisposable, System.Collections.IEnumerable
|
||||
#if !SWIG_DOTNET_1
|
||||
, System.Collections.Generic.IList<SearchMonitor>
|
||||
#endif
|
||||
{
|
||||
// cast from C# long array
|
||||
public static implicit operator CpSearchMonitorVector(SearchMonitor[] inVal) {
|
||||
var outVal= new CpSearchMonitorVector();
|
||||
foreach (SearchMonitor element in inVal) {
|
||||
outVal.Add(element);
|
||||
}
|
||||
return outVal;
|
||||
}
|
||||
|
||||
// cast to C# SearchMonitor array
|
||||
public static implicit operator SearchMonitor[](CpSearchMonitorVector inVal) {
|
||||
var outVal= new SearchMonitor[inVal.Count];
|
||||
inVal.CopyTo(outVal);
|
||||
return outVal;
|
||||
}
|
||||
}
|
||||
|
||||
public partial class CpDecisionBuilderVector: IDisposable, System.Collections.IEnumerable
|
||||
#if !SWIG_DOTNET_1
|
||||
, System.Collections.Generic.IList<DecisionBuilder>
|
||||
#endif
|
||||
{
|
||||
// cast from C# long array
|
||||
public static implicit operator CpDecisionBuilderVector(DecisionBuilder[] inVal) {
|
||||
var outVal= new CpDecisionBuilderVector();
|
||||
foreach (DecisionBuilder element in inVal) {
|
||||
outVal.Add(element);
|
||||
}
|
||||
return outVal;
|
||||
}
|
||||
|
||||
// cast to C# DecisionBuilder array
|
||||
public static implicit operator DecisionBuilder[](CpDecisionBuilderVector inVal) {
|
||||
var outVal= new DecisionBuilder[inVal.Count];
|
||||
inVal.CopyTo(outVal);
|
||||
return outVal;
|
||||
}
|
||||
}
|
||||
|
||||
public partial class CpIntervalVarVector: IDisposable, System.Collections.IEnumerable
|
||||
#if !SWIG_DOTNET_1
|
||||
, System.Collections.Generic.IList<IntervalVar>
|
||||
#endif
|
||||
{
|
||||
// cast from C# long array
|
||||
public static implicit operator CpIntervalVarVector(IntervalVar[] inVal) {
|
||||
var outVal= new CpIntervalVarVector();
|
||||
foreach (IntervalVar element in inVal) {
|
||||
outVal.Add(element);
|
||||
}
|
||||
return outVal;
|
||||
}
|
||||
|
||||
// cast to C# IntervalVar array
|
||||
public static implicit operator IntervalVar[](CpIntervalVarVector inVal) {
|
||||
var outVal= new IntervalVar[inVal.Count];
|
||||
inVal.CopyTo(outVal);
|
||||
return outVal;
|
||||
}
|
||||
}
|
||||
|
||||
public partial class CpSequenceVarVector: IDisposable, System.Collections.IEnumerable
|
||||
#if !SWIG_DOTNET_1
|
||||
, System.Collections.Generic.IList<SequenceVar>
|
||||
#endif
|
||||
{
|
||||
// cast from C# long array
|
||||
public static implicit operator CpSequenceVarVector(SequenceVar[] inVal) {
|
||||
var outVal= new CpSequenceVarVector();
|
||||
foreach (SequenceVar element in inVal) {
|
||||
outVal.Add(element);
|
||||
}
|
||||
return outVal;
|
||||
}
|
||||
|
||||
// cast to C# SequenceVar array
|
||||
public static implicit operator SequenceVar[](CpSequenceVarVector inVal) {
|
||||
var outVal= new SequenceVar[inVal.Count];
|
||||
inVal.CopyTo(outVal);
|
||||
return outVal;
|
||||
}
|
||||
}
|
||||
|
||||
public partial class CpLocalSearchOperatorVector: IDisposable, System.Collections.IEnumerable
|
||||
#if !SWIG_DOTNET_1
|
||||
, System.Collections.Generic.IList<LocalSearchOperator>
|
||||
#endif
|
||||
{
|
||||
// cast from C# long array
|
||||
public static implicit operator CpLocalSearchOperatorVector(LocalSearchOperator[] inVal) {
|
||||
var outVal= new CpLocalSearchOperatorVector();
|
||||
foreach (LocalSearchOperator element in inVal) {
|
||||
outVal.Add(element);
|
||||
}
|
||||
return outVal;
|
||||
}
|
||||
|
||||
// cast to C# LocalSearchOperator array
|
||||
public static implicit operator LocalSearchOperator[](CpLocalSearchOperatorVector inVal) {
|
||||
var outVal= new LocalSearchOperator[inVal.Count];
|
||||
inVal.CopyTo(outVal);
|
||||
return outVal;
|
||||
}
|
||||
}
|
||||
|
||||
public partial class CpLocalSearchFilterVector: IDisposable, System.Collections.IEnumerable
|
||||
#if !SWIG_DOTNET_1
|
||||
, System.Collections.Generic.IList<LocalSearchFilter>
|
||||
#endif
|
||||
{
|
||||
// cast from C# long array
|
||||
public static implicit operator CpLocalSearchFilterVector(LocalSearchFilter[] inVal) {
|
||||
var outVal= new CpLocalSearchFilterVector();
|
||||
foreach (LocalSearchFilter element in inVal) {
|
||||
outVal.Add(element);
|
||||
}
|
||||
return outVal;
|
||||
}
|
||||
|
||||
// cast to C# LocalSearchFilter array
|
||||
public static implicit operator LocalSearchFilter[](CpLocalSearchFilterVector inVal) {
|
||||
var outVal= new LocalSearchFilter[inVal.Count];
|
||||
inVal.CopyTo(outVal);
|
||||
return outVal;
|
||||
}
|
||||
}
|
||||
|
||||
public partial class CpSymmetryBreakerVector: IDisposable, System.Collections.IEnumerable
|
||||
#if !SWIG_DOTNET_1
|
||||
, System.Collections.Generic.IList<SymmetryBreaker>
|
||||
#endif
|
||||
{
|
||||
// cast from C# long array
|
||||
public static implicit operator CpSymmetryBreakerVector(SymmetryBreaker[] inVal) {
|
||||
var outVal= new CpSymmetryBreakerVector();
|
||||
foreach (SymmetryBreaker element in inVal) {
|
||||
outVal.Add(element);
|
||||
}
|
||||
return outVal;
|
||||
}
|
||||
|
||||
// cast to C# SymmetryBreaker array
|
||||
public static implicit operator SymmetryBreaker[](CpSymmetryBreakerVector inVal) {
|
||||
var outVal= new SymmetryBreaker[inVal.Count];
|
||||
inVal.CopyTo(outVal);
|
||||
return outVal;
|
||||
}
|
||||
}
|
||||
} // namespace Google.OrTools.ConstraintSolver
|
||||
|
||||
514
src/com/google/ortools/constraintsolver/SolverHelper.cs
Normal file
514
src/com/google/ortools/constraintsolver/SolverHelper.cs
Normal file
@@ -0,0 +1,514 @@
|
||||
// Copyright 2010-2014 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
|
||||
//
|
||||
// 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.
|
||||
|
||||
namespace Google.OrTools.ConstraintSolver {
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public partial class Solver : IDisposable {
|
||||
public IntVar[] MakeIntVarArray(int count, long min, long max) {
|
||||
IntVar[] array = new IntVar[count];
|
||||
for (int i = 0; i < count; ++i) {
|
||||
array[i] = MakeIntVar(min, max);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public IntVar[] MakeIntVarArray(int count, long min, long max, string name) {
|
||||
IntVar[] array = new IntVar[count];
|
||||
for (int i = 0; i < count; ++i) {
|
||||
string var_name = name + i;
|
||||
array[i] = MakeIntVar(min, max, var_name);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public IntVar[] MakeIntVarArray(int count, long[] values) {
|
||||
IntVar[] array = new IntVar[count];
|
||||
for (int i = 0; i < count; ++i) {
|
||||
array[i] = MakeIntVar(values);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public IntVar[] MakeIntVarArray(int count, long[] values, string name) {
|
||||
IntVar[] array = new IntVar[count];
|
||||
for (int i = 0; i < count; ++i) {
|
||||
string var_name = name + i;
|
||||
array[i] = MakeIntVar(values, var_name);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public IntVar[] MakeIntVarArray(int count, int[] values) {
|
||||
IntVar[] array = new IntVar[count];
|
||||
for (int i = 0; i < count; ++i) {
|
||||
array[i] = MakeIntVar(values);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public IntVar[] MakeIntVarArray(int count, int[] values, string name) {
|
||||
IntVar[] array = new IntVar[count];
|
||||
for (int i = 0; i < count; ++i) {
|
||||
string var_name = name + i;
|
||||
array[i] = MakeIntVar(values, var_name);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public IntVar[] MakeBoolVarArray(int count) {
|
||||
IntVar[] array = new IntVar[count];
|
||||
for (int i = 0; i < count; ++i) {
|
||||
array[i] = MakeBoolVar();
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public IntVar[] MakeBoolVarArray(int count, string name) {
|
||||
IntVar[] array = new IntVar[count];
|
||||
for (int i = 0; i < count; ++i) {
|
||||
string var_name = name + i;
|
||||
array[i] = MakeBoolVar(var_name);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public IntVar[,] MakeIntVarMatrix(int rows, int cols, long min, long max) {
|
||||
IntVar[,] array = new IntVar[rows, cols];
|
||||
for (int i = 0; i < rows; ++i) {
|
||||
for (int j = 0; j < cols; ++j) {
|
||||
array[i,j] = MakeIntVar(min, max);
|
||||
}
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public IntVar[,] MakeIntVarMatrix(int rows, int cols,
|
||||
long min, long max, string name) {
|
||||
IntVar[,] array = new IntVar[rows, cols];
|
||||
for (int i = 0; i < rows; ++i) {
|
||||
for (int j = 0; j < cols; ++j) {
|
||||
string var_name = name + "["+ i + ", " + j +"]";
|
||||
array[i,j] = MakeIntVar(min, max, var_name);
|
||||
}
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public IntVar[,] MakeIntVarMatrix(int rows, int cols, long[] values) {
|
||||
IntVar[,] array = new IntVar[rows, cols];
|
||||
for (int i = 0; i < rows; ++i) {
|
||||
for (int j = 0; j < cols; ++j) {
|
||||
array[i,j] = MakeIntVar(values);
|
||||
}
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public IntVar[,] MakeIntVarMatrix(int rows, int cols,
|
||||
long[] values, string name) {
|
||||
IntVar[,] array = new IntVar[rows, cols];
|
||||
for (int i = 0; i < rows; ++i) {
|
||||
for (int j = 0; j < cols; ++j) {
|
||||
string var_name = name + "["+ i + ", " + j +"]";
|
||||
array[i,j] = MakeIntVar(values, var_name);
|
||||
}
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public IntVar[,] MakeIntVarMatrix(int rows, int cols, int[] values) {
|
||||
IntVar[,] array = new IntVar[rows, cols];
|
||||
for (int i = 0; i < rows; ++i) {
|
||||
for (int j = 0; j < cols; ++j) {
|
||||
array[i,j] = MakeIntVar(values);
|
||||
}
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public IntVar[,] MakeIntVarMatrix(int rows, int cols,
|
||||
int[] values, string name) {
|
||||
IntVar[,] array = new IntVar[rows, cols];
|
||||
for (int i = 0; i < rows; ++i) {
|
||||
for (int j = 0; j < cols; ++j) {
|
||||
string var_name = name + "["+ i + ", " + j +"]";
|
||||
array[i,j] = MakeIntVar(values, var_name);
|
||||
}
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public IntVar[,] MakeBoolVarMatrix(int rows, int cols) {
|
||||
IntVar[,] array = new IntVar[rows, cols];
|
||||
for (int i = 0; i < rows; ++i) {
|
||||
for (int j = 0; j < cols; ++j) {
|
||||
array[i,j] = MakeBoolVar();
|
||||
}
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public IntVar[,] MakeBoolVarMatrix(int rows, int cols, string name) {
|
||||
IntVar[,] array = new IntVar[rows, cols];
|
||||
for (int i = 0; i < rows; ++i) {
|
||||
for (int j = 0; j < cols; ++j) {
|
||||
string var_name = name + "["+ i + ", " + j +"]";
|
||||
array[i,j] = MakeBoolVar(var_name);
|
||||
}
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public IntervalVar[] MakeFixedDurationIntervalVarArray(int count,
|
||||
long start_min,
|
||||
long start_max,
|
||||
long duration,
|
||||
bool optional) {
|
||||
IntervalVar[] array = new IntervalVar[count];
|
||||
for (int i = 0; i < count; ++i) {
|
||||
array[i] = MakeFixedDurationIntervalVar(start_min,
|
||||
start_max,
|
||||
duration,
|
||||
optional,
|
||||
"");
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public IntervalVar[] MakeFixedDurationIntervalVarArray(int count,
|
||||
long start_min,
|
||||
long start_max,
|
||||
long duration,
|
||||
bool optional,
|
||||
string name) {
|
||||
IntervalVar[] array = new IntervalVar[count];
|
||||
for (int i = 0; i < count; ++i) {
|
||||
array[i] = MakeFixedDurationIntervalVar(start_min,
|
||||
start_max,
|
||||
duration,
|
||||
optional,
|
||||
name + i);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public IntervalVar[] MakeFixedDurationIntervalVarArray(int count,
|
||||
long[] start_min,
|
||||
long[] start_max,
|
||||
long[] duration,
|
||||
bool optional,
|
||||
string name) {
|
||||
IntervalVar[] array = new IntervalVar[count];
|
||||
for (int i = 0; i < count; ++i) {
|
||||
array[i] = MakeFixedDurationIntervalVar(start_min[i],
|
||||
start_max[i],
|
||||
duration[i],
|
||||
optional,
|
||||
name + i);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public IntervalVar[] MakeFixedDurationIntervalVarArray(int count,
|
||||
int[] start_min,
|
||||
int[] start_max,
|
||||
int[] duration,
|
||||
bool optional,
|
||||
string name) {
|
||||
IntervalVar[] array = new IntervalVar[count];
|
||||
for (int i = 0; i < count; ++i) {
|
||||
array[i] = MakeFixedDurationIntervalVar(start_min[i],
|
||||
start_max[i],
|
||||
duration[i],
|
||||
optional,
|
||||
name + i);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
public IntervalVar[] MakeFixedDurationIntervalVarArray(IntVar[] starts,
|
||||
int[] durations,
|
||||
string name) {
|
||||
int count = starts.Length;
|
||||
IntervalVar[] array = new IntervalVar[count];
|
||||
for (int i = 0; i < count; ++i) {
|
||||
array[i] = MakeFixedDurationIntervalVar(starts[i],
|
||||
durations[i],
|
||||
name + i);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
public IntervalVar[] MakeFixedDurationIntervalVarArray(IntVar[] starts,
|
||||
long[] durations,
|
||||
string name) {
|
||||
int count = starts.Length;
|
||||
IntervalVar[] array = new IntervalVar[count];
|
||||
for (int i = 0; i < count; ++i) {
|
||||
array[i] = MakeFixedDurationIntervalVar(starts[i],
|
||||
durations[i],
|
||||
name + i);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
public void NewSearch(DecisionBuilder db) {
|
||||
pinned_decision_builder_ = db;
|
||||
pinned_search_monitors_.Clear();
|
||||
NewSearchAux(db);
|
||||
}
|
||||
|
||||
public void NewSearch(DecisionBuilder db, SearchMonitor sm1) {
|
||||
pinned_decision_builder_ = db;
|
||||
pinned_search_monitors_.Clear();
|
||||
pinned_search_monitors_.Add(sm1);
|
||||
NewSearchAux(db, sm1);
|
||||
}
|
||||
|
||||
|
||||
public void NewSearch(DecisionBuilder db,
|
||||
SearchMonitor sm1,
|
||||
SearchMonitor sm2) {
|
||||
pinned_decision_builder_ = db;
|
||||
pinned_search_monitors_.Clear();
|
||||
pinned_search_monitors_.Add(sm1);
|
||||
pinned_search_monitors_.Add(sm2);
|
||||
NewSearchAux(db, sm1, sm2);
|
||||
}
|
||||
|
||||
public void NewSearch(DecisionBuilder db,
|
||||
SearchMonitor sm1,
|
||||
SearchMonitor sm2,
|
||||
SearchMonitor sm3) {
|
||||
pinned_decision_builder_ = db;
|
||||
pinned_search_monitors_.Clear();
|
||||
pinned_search_monitors_.Add(sm1);
|
||||
pinned_search_monitors_.Add(sm2);
|
||||
pinned_search_monitors_.Add(sm3);
|
||||
NewSearchAux(db, sm1, sm2, sm3);
|
||||
}
|
||||
|
||||
public void NewSearch(DecisionBuilder db,
|
||||
SearchMonitor sm1,
|
||||
SearchMonitor sm2,
|
||||
SearchMonitor sm3,
|
||||
SearchMonitor sm4) {
|
||||
pinned_decision_builder_ = db;
|
||||
pinned_search_monitors_.Clear();
|
||||
pinned_search_monitors_.Add(sm1);
|
||||
pinned_search_monitors_.Add(sm2);
|
||||
pinned_search_monitors_.Add(sm3);
|
||||
pinned_search_monitors_.Add(sm4);
|
||||
NewSearchAux(db, sm1, sm2, sm3, sm4);
|
||||
}
|
||||
|
||||
public void NewSearch(DecisionBuilder db, SearchMonitor[] monitors) {
|
||||
pinned_decision_builder_ = db;
|
||||
pinned_search_monitors_.Clear();
|
||||
pinned_search_monitors_.AddRange(monitors);
|
||||
NewSearchAux(db, monitors);
|
||||
}
|
||||
|
||||
public void EndSearch() {
|
||||
pinned_decision_builder_ = null;
|
||||
pinned_search_monitors_.Clear();
|
||||
EndSearchAux();
|
||||
}
|
||||
|
||||
private System.Collections.Generic.List<SearchMonitor> pinned_search_monitors_
|
||||
= new System.Collections.Generic.List<SearchMonitor>();
|
||||
private DecisionBuilder pinned_decision_builder_;
|
||||
}
|
||||
|
||||
public partial class IntExpr : PropagationBaseObject {
|
||||
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 IntExprEquality operator ==(IntExpr a, IntExpr b) {
|
||||
return new IntExprEquality(a, b, true);
|
||||
}
|
||||
public static IntExprEquality operator !=(IntExpr a, IntExpr b) {
|
||||
return new IntExprEquality(a, b, false);
|
||||
}
|
||||
public static WrappedConstraint operator ==(IntExpr a, long v) {
|
||||
return new WrappedConstraint(a.solver().MakeEquality(a, v));
|
||||
}
|
||||
public static WrappedConstraint operator !=(IntExpr a, long v) {
|
||||
return new WrappedConstraint(a.solver().MakeNonEquality(a.Var(), v));
|
||||
}
|
||||
public static WrappedConstraint operator >=(IntExpr a, long v) {
|
||||
return new WrappedConstraint(a.solver().MakeGreaterOrEqual(a, v));
|
||||
}
|
||||
public static WrappedConstraint operator >(IntExpr a, long v) {
|
||||
return new WrappedConstraint(a.solver().MakeGreater(a, v));
|
||||
}
|
||||
public static WrappedConstraint operator <=(IntExpr a, long v) {
|
||||
return new WrappedConstraint(a.solver().MakeLessOrEqual(a, v));
|
||||
}
|
||||
public static WrappedConstraint operator <(IntExpr a, long v) {
|
||||
return new WrappedConstraint(a.solver().MakeLess(a, v));
|
||||
}
|
||||
public static WrappedConstraint operator >=(IntExpr a, IntExpr b) {
|
||||
return new WrappedConstraint(a.solver().MakeGreaterOrEqual(a.Var(), b.Var()));
|
||||
}
|
||||
public static WrappedConstraint operator >(IntExpr a, IntExpr b) {
|
||||
return new WrappedConstraint(a.solver().MakeGreater(a.Var(), b.Var()));
|
||||
}
|
||||
public static WrappedConstraint operator <=(IntExpr a, IntExpr b) {
|
||||
return new WrappedConstraint(a.solver().MakeLessOrEqual(a.Var(), b.Var()));
|
||||
}
|
||||
public static WrappedConstraint operator <(IntExpr a, IntExpr b) {
|
||||
return new WrappedConstraint(a.solver().MakeLess(a.Var(), b.Var()));
|
||||
}
|
||||
}
|
||||
|
||||
public partial class Constraint : PropagationBaseObject, IConstraintWithStatus {
|
||||
public static implicit operator IntVar(Constraint eq)
|
||||
{
|
||||
return eq.Var();
|
||||
}
|
||||
|
||||
public static implicit operator IntExpr(Constraint eq)
|
||||
{
|
||||
return eq.Var();
|
||||
}
|
||||
public static IntExpr operator+(Constraint a, Constraint b) {
|
||||
return a.solver().MakeSum(a.Var(), b.Var());
|
||||
}
|
||||
public static IntExpr operator+(Constraint a, long v) {
|
||||
return a.solver().MakeSum(a.Var(), v);
|
||||
}
|
||||
public static IntExpr operator+(long v, Constraint a) {
|
||||
return a.solver().MakeSum(a.Var(), v);
|
||||
}
|
||||
public static IntExpr operator-(Constraint a, Constraint b) {
|
||||
return a.solver().MakeDifference(a.Var(), b.Var());
|
||||
}
|
||||
public static IntExpr operator-(Constraint a, long v) {
|
||||
return a.solver().MakeSum(a.Var(), -v);
|
||||
}
|
||||
public static IntExpr operator-(long v, Constraint a) {
|
||||
return a.solver().MakeDifference(v, a.Var());
|
||||
}
|
||||
public static IntExpr operator*(Constraint a, Constraint b) {
|
||||
return a.solver().MakeProd(a.Var(), b.Var());
|
||||
}
|
||||
public static IntExpr operator*(Constraint a, long v) {
|
||||
return a.solver().MakeProd(a.Var(), v);
|
||||
}
|
||||
public static IntExpr operator*(long v, Constraint a) {
|
||||
return a.solver().MakeProd(a.Var(), v);
|
||||
}
|
||||
public static IntExpr operator/(Constraint a, long v) {
|
||||
return a.solver().MakeDiv(a.Var(), v);
|
||||
}
|
||||
public static IntExpr operator-(Constraint a) {
|
||||
return a.solver().MakeOpposite(a.Var());
|
||||
}
|
||||
public IntExpr Abs() {
|
||||
return this.solver().MakeAbs(this.Var());
|
||||
}
|
||||
public IntExpr Square() {
|
||||
return this.solver().MakeSquare(this.Var());
|
||||
}
|
||||
public static WrappedConstraint operator ==(Constraint a, long v) {
|
||||
return new WrappedConstraint(a.solver().MakeEquality(a.Var(), v));
|
||||
}
|
||||
public static WrappedConstraint operator ==(long v, Constraint a) {
|
||||
return new WrappedConstraint(a.solver().MakeEquality(a.Var(), v));
|
||||
}
|
||||
public static WrappedConstraint operator !=(Constraint a, long v) {
|
||||
return new WrappedConstraint(a.solver().MakeNonEquality(a.Var(), v));
|
||||
}
|
||||
public static WrappedConstraint operator !=(long v, Constraint a) {
|
||||
return new WrappedConstraint(a.solver().MakeNonEquality(a.Var(), v));
|
||||
}
|
||||
public static WrappedConstraint operator >=(Constraint a, long v) {
|
||||
return new WrappedConstraint(a.solver().MakeGreaterOrEqual(a.Var(), v));
|
||||
}
|
||||
public static WrappedConstraint operator >=(long v, Constraint a) {
|
||||
return new WrappedConstraint(a.solver().MakeLessOrEqual(a.Var(), v));
|
||||
}
|
||||
public static WrappedConstraint operator >(Constraint a, long v) {
|
||||
return new WrappedConstraint(a.solver().MakeGreater(a.Var(), v));
|
||||
}
|
||||
public static WrappedConstraint operator >(long v, Constraint a) {
|
||||
return new WrappedConstraint(a.solver().MakeLess(a.Var(), v));
|
||||
}
|
||||
public static WrappedConstraint operator <=(Constraint a, long v) {
|
||||
return new WrappedConstraint(a.solver().MakeLessOrEqual(a.Var(), v));
|
||||
}
|
||||
public static WrappedConstraint operator <=(long v, Constraint a) {
|
||||
return new WrappedConstraint(a.solver().MakeGreaterOrEqual(a.Var(), v));
|
||||
}
|
||||
public static WrappedConstraint operator <(Constraint a, long v) {
|
||||
return new WrappedConstraint(a.solver().MakeLess(a.Var(), v));
|
||||
}
|
||||
public static WrappedConstraint operator <(long v, Constraint a) {
|
||||
return new WrappedConstraint(a.solver().MakeGreater(a.Var(), v));
|
||||
}
|
||||
public static WrappedConstraint operator >=(Constraint a, Constraint b) {
|
||||
return new WrappedConstraint(a.solver().MakeGreaterOrEqual(a.Var(), b.Var()));
|
||||
}
|
||||
public static WrappedConstraint operator >(Constraint a, Constraint b) {
|
||||
return new WrappedConstraint(a.solver().MakeGreater(a.Var(), b.Var()));
|
||||
}
|
||||
public static WrappedConstraint operator <=(Constraint a, Constraint b) {
|
||||
return new WrappedConstraint(a.solver().MakeLessOrEqual(a.Var(), b.Var()));
|
||||
}
|
||||
public static WrappedConstraint operator <(Constraint a, Constraint b) {
|
||||
return new WrappedConstraint(a.solver().MakeLess(a.Var(), b.Var()));
|
||||
}
|
||||
public static ConstraintEquality operator ==(Constraint a, Constraint b) {
|
||||
return new ConstraintEquality(a, b, true);
|
||||
}
|
||||
public static ConstraintEquality operator !=(Constraint a, Constraint b) {
|
||||
return new ConstraintEquality(a, b, false);
|
||||
}
|
||||
}
|
||||
} // namespace Google.OrTools.ConstraintSolver
|
||||
@@ -162,8 +162,6 @@ class LongResultCallback3 {
|
||||
|
||||
%include "std_vector.i"
|
||||
|
||||
%template(IntVector) std::vector<int>;
|
||||
|
||||
%{
|
||||
#include <setjmp.h>
|
||||
|
||||
@@ -186,23 +184,27 @@ struct FailureProtect {
|
||||
};
|
||||
%}
|
||||
|
||||
%template(CpIntVector) std::vector<int>;
|
||||
%template(CpInt64Vector) std::vector<int64>;
|
||||
|
||||
%define CS_TYPEMAP_STDVECTOR_OBJECT(CTYPE, TYPE)
|
||||
SWIG_STD_VECTOR_ENHANCED(operations_research::CTYPE*);
|
||||
%template(Cp ## TYPE ## Vector) std::vector<CTYPE*>;
|
||||
%enddef // CS_TYPEMAP_STDVECTOR_OBJECT
|
||||
|
||||
CS_TYPEMAP_STDVECTOR_OBJECT(operations_research::IntVar, IntVar)
|
||||
CS_TYPEMAP_STDVECTOR_OBJECT(operations_research::SearchMonitor, SearchMonitor)
|
||||
CS_TYPEMAP_STDVECTOR_OBJECT(operations_research::DecisionBuilder, DecisionBuilder)
|
||||
CS_TYPEMAP_STDVECTOR_OBJECT(operations_research::IntervalVar, IntervalVar)
|
||||
CS_TYPEMAP_STDVECTOR_OBJECT(operations_research::SequenceVar, SequenceVar)
|
||||
CS_TYPEMAP_STDVECTOR_OBJECT(operations_research::LocalSearchOperator, LocalSearchOperator)
|
||||
CS_TYPEMAP_STDVECTOR_OBJECT(operations_research::LocalSearchFilter, LocalSearchFilter)
|
||||
CS_TYPEMAP_STDVECTOR_OBJECT(operations_research::SymmetryBreaker, SymmetryBreaker)
|
||||
|
||||
%ignore operations_research::Solver::MakeIntVarArray;
|
||||
%ignore operations_research::Solver::MakeBoolVarArray;
|
||||
%ignore operations_research::Solver::MakeFixedDurationIntervalVarArray;
|
||||
%ignore operations_research::IntVarLocalSearchFilter::FindIndex;
|
||||
%ignore operations_research::VarLocalSearchOperator::Value;
|
||||
%ignore operations_research::VarLocalSearchOperator::OldValue;
|
||||
%ignore operations_research::SequenceVarLocalSearchOperator::Sequence;
|
||||
%ignore operations_research::SequenceVarLocalSearchOperator::OldSequence;
|
||||
%ignore operations_research::SolutionCollector::ForwardSequence;
|
||||
%ignore operations_research::SolutionCollector::BackwardSequence;
|
||||
%ignore operations_research::SolutionCollector::Unperformed;
|
||||
%ignore operations_research::SequenceVarElement::ForwardSequence;
|
||||
%ignore operations_research::SequenceVarElement::BackwardSequence;
|
||||
%ignore operations_research::SequenceVarElement::Unperformed;
|
||||
%ignore operations_research::Assignment::ForwardSequence;
|
||||
%ignore operations_research::Assignment::BackwardSequence;
|
||||
%ignore operations_research::Assignment::Unperformed;
|
||||
|
||||
// Generic rename rule.
|
||||
%rename("%(camelcase)s", %$isfunction) "";
|
||||
@@ -230,199 +232,6 @@ struct FailureProtect {
|
||||
%rename (EndSearchAux) operations_research::Solver::EndSearch;
|
||||
|
||||
%typemap(csinterfaces_derived) operations_research::Constraint "IConstraintWithStatus";
|
||||
%typemap(cscode) operations_research::Constraint %{
|
||||
public static implicit operator IntVar(Constraint eq)
|
||||
{
|
||||
return eq.Var();
|
||||
}
|
||||
|
||||
public static implicit operator IntExpr(Constraint eq)
|
||||
{
|
||||
return eq.Var();
|
||||
}
|
||||
public static IntExpr operator+(Constraint a, Constraint b) {
|
||||
return a.solver().MakeSum(a.Var(), b.Var());
|
||||
}
|
||||
public static IntExpr operator+(Constraint a, long v) {
|
||||
return a.solver().MakeSum(a.Var(), v);
|
||||
}
|
||||
public static IntExpr operator+(long v, Constraint a) {
|
||||
return a.solver().MakeSum(a.Var(), v);
|
||||
}
|
||||
public static IntExpr operator-(Constraint a, Constraint b) {
|
||||
return a.solver().MakeDifference(a.Var(), b.Var());
|
||||
}
|
||||
public static IntExpr operator-(Constraint a, long v) {
|
||||
return a.solver().MakeSum(a.Var(), -v);
|
||||
}
|
||||
public static IntExpr operator-(long v, Constraint a) {
|
||||
return a.solver().MakeDifference(v, a.Var());
|
||||
}
|
||||
public static IntExpr operator*(Constraint a, Constraint b) {
|
||||
return a.solver().MakeProd(a.Var(), b.Var());
|
||||
}
|
||||
public static IntExpr operator*(Constraint a, long v) {
|
||||
return a.solver().MakeProd(a.Var(), v);
|
||||
}
|
||||
public static IntExpr operator*(long v, Constraint a) {
|
||||
return a.solver().MakeProd(a.Var(), v);
|
||||
}
|
||||
public static IntExpr operator/(Constraint a, long v) {
|
||||
return a.solver().MakeDiv(a.Var(), v);
|
||||
}
|
||||
public static IntExpr operator-(Constraint a) {
|
||||
return a.solver().MakeOpposite(a.Var());
|
||||
}
|
||||
public IntExpr Abs() {
|
||||
return this.solver().MakeAbs(this.Var());
|
||||
}
|
||||
public IntExpr Square() {
|
||||
return this.solver().MakeSquare(this.Var());
|
||||
}
|
||||
public static WrappedConstraint operator ==(Constraint a, long v) {
|
||||
return new WrappedConstraint(a.solver().MakeEquality(a.Var(), v));
|
||||
}
|
||||
public static WrappedConstraint operator ==(long v, Constraint a) {
|
||||
return new WrappedConstraint(a.solver().MakeEquality(a.Var(), v));
|
||||
}
|
||||
public static WrappedConstraint operator !=(Constraint a, long v) {
|
||||
return new WrappedConstraint(a.solver().MakeNonEquality(a.Var(), v));
|
||||
}
|
||||
public static WrappedConstraint operator !=(long v, Constraint a) {
|
||||
return new WrappedConstraint(a.solver().MakeNonEquality(a.Var(), v));
|
||||
}
|
||||
public static WrappedConstraint operator >=(Constraint a, long v) {
|
||||
return new WrappedConstraint(a.solver().MakeGreaterOrEqual(a.Var(), v));
|
||||
}
|
||||
public static WrappedConstraint operator >=(long v, Constraint a) {
|
||||
return new WrappedConstraint(a.solver().MakeLessOrEqual(a.Var(), v));
|
||||
}
|
||||
public static WrappedConstraint operator >(Constraint a, long v) {
|
||||
return new WrappedConstraint(a.solver().MakeGreater(a.Var(), v));
|
||||
}
|
||||
public static WrappedConstraint operator >(long v, Constraint a) {
|
||||
return new WrappedConstraint(a.solver().MakeLess(a.Var(), v));
|
||||
}
|
||||
public static WrappedConstraint operator <=(Constraint a, long v) {
|
||||
return new WrappedConstraint(a.solver().MakeLessOrEqual(a.Var(), v));
|
||||
}
|
||||
public static WrappedConstraint operator <=(long v, Constraint a) {
|
||||
return new WrappedConstraint(a.solver().MakeGreaterOrEqual(a.Var(), v));
|
||||
}
|
||||
public static WrappedConstraint operator <(Constraint a, long v) {
|
||||
return new WrappedConstraint(a.solver().MakeLess(a.Var(), v));
|
||||
}
|
||||
public static WrappedConstraint operator <(long v, Constraint a) {
|
||||
return new WrappedConstraint(a.solver().MakeGreater(a.Var(), v));
|
||||
}
|
||||
public static WrappedConstraint operator >=(Constraint a, Constraint b) {
|
||||
return new WrappedConstraint(a.solver().MakeGreaterOrEqual(a.Var(), b.Var()));
|
||||
}
|
||||
public static WrappedConstraint operator >(Constraint a, Constraint b) {
|
||||
return new WrappedConstraint(a.solver().MakeGreater(a.Var(), b.Var()));
|
||||
}
|
||||
public static WrappedConstraint operator <=(Constraint a, Constraint b) {
|
||||
return new WrappedConstraint(a.solver().MakeLessOrEqual(a.Var(), b.Var()));
|
||||
}
|
||||
public static WrappedConstraint operator <(Constraint a, Constraint b) {
|
||||
return new WrappedConstraint(a.solver().MakeLess(a.Var(), b.Var()));
|
||||
}
|
||||
public static ConstraintEquality operator ==(Constraint a, Constraint b) {
|
||||
return new ConstraintEquality(a, b, true);
|
||||
}
|
||||
public static ConstraintEquality operator !=(Constraint a, Constraint b) {
|
||||
return new ConstraintEquality(a, b, false);
|
||||
}
|
||||
%}
|
||||
|
||||
|
||||
// Add arithmetic operators to integer expressions.
|
||||
%typemap(cscode) operations_research::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 IntExprEquality operator ==(IntExpr a, IntExpr b) {
|
||||
return new IntExprEquality(a, b, true);
|
||||
}
|
||||
public static IntExprEquality operator !=(IntExpr a, IntExpr b) {
|
||||
return new IntExprEquality(a, b, false);
|
||||
}
|
||||
public static WrappedConstraint operator ==(IntExpr a, long v) {
|
||||
return new WrappedConstraint(a.solver().MakeEquality(a, v));
|
||||
}
|
||||
public static WrappedConstraint operator !=(IntExpr a, long v) {
|
||||
return new WrappedConstraint(a.solver().MakeNonEquality(a.Var(), v));
|
||||
}
|
||||
public static WrappedConstraint operator >=(IntExpr a, long v) {
|
||||
return new WrappedConstraint(a.solver().MakeGreaterOrEqual(a, v));
|
||||
}
|
||||
public static WrappedConstraint operator >(IntExpr a, long v) {
|
||||
return new WrappedConstraint(a.solver().MakeGreater(a, v));
|
||||
}
|
||||
public static WrappedConstraint operator <=(IntExpr a, long v) {
|
||||
return new WrappedConstraint(a.solver().MakeLessOrEqual(a, v));
|
||||
}
|
||||
public static WrappedConstraint operator <(IntExpr a, long v) {
|
||||
return new WrappedConstraint(a.solver().MakeLess(a, v));
|
||||
}
|
||||
public static WrappedConstraint operator >=(IntExpr a, IntExpr b) {
|
||||
return new WrappedConstraint(a.solver().MakeGreaterOrEqual(a.Var(), b.Var()));
|
||||
}
|
||||
public static WrappedConstraint operator >(IntExpr a, IntExpr b) {
|
||||
return new WrappedConstraint(a.solver().MakeGreater(a.Var(), b.Var()));
|
||||
}
|
||||
public static WrappedConstraint operator <=(IntExpr a, IntExpr b) {
|
||||
return new WrappedConstraint(a.solver().MakeLessOrEqual(a.Var(), b.Var()));
|
||||
}
|
||||
public static WrappedConstraint operator <(IntExpr a, IntExpr b) {
|
||||
return new WrappedConstraint(a.solver().MakeLess(a.Var(), b.Var()));
|
||||
}
|
||||
%}
|
||||
|
||||
CS_TYPEMAP_STDVECTOR_OBJECT(operations_research::IntVar, IntVar)
|
||||
CS_TYPEMAP_STDVECTOR_OBJECT(operations_research::SearchMonitor, SearchMonitor)
|
||||
CS_TYPEMAP_STDVECTOR_OBJECT(operations_research::DecisionBuilder, DecisionBuilder)
|
||||
CS_TYPEMAP_STDVECTOR_OBJECT(operations_research::IntervalVar, IntervalVar)
|
||||
CS_TYPEMAP_STDVECTOR_OBJECT(operations_research::SequenceVar, SequenceVar)
|
||||
CS_TYPEMAP_STDVECTOR_OBJECT(operations_research::LocalSearchOperator, LocalSearchOperator)
|
||||
CS_TYPEMAP_STDVECTOR_OBJECT(operations_research::LocalSearchFilter, LocalSearchFilter)
|
||||
CS_TYPEMAP_STDVECTOR_OBJECT(operations_research::SymmetryBreaker, SymmetryBreaker)
|
||||
|
||||
namespace operations_research {
|
||||
%extend IntervalVar {
|
||||
@@ -568,397 +377,6 @@ namespace operations_research {
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(cscode) Solver %{
|
||||
public IntVar[] MakeIntVarArray(int count, long min, long max) {
|
||||
IntVar[] array = new IntVar[count];
|
||||
for (int i = 0; i < count; ++i) {
|
||||
array[i] = MakeIntVar(min, max);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public IntVar[] MakeIntVarArray(int count, long min, long max, string name) {
|
||||
IntVar[] array = new IntVar[count];
|
||||
for (int i = 0; i < count; ++i) {
|
||||
string var_name = name + i;
|
||||
array[i] = MakeIntVar(min, max, var_name);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public IntVar[] MakeIntVarArray(int count, long[] values) {
|
||||
IntVar[] array = new IntVar[count];
|
||||
for (int i = 0; i < count; ++i) {
|
||||
array[i] = MakeIntVar(values);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public IntVar[] MakeIntVarArray(int count, long[] values, string name) {
|
||||
IntVar[] array = new IntVar[count];
|
||||
for (int i = 0; i < count; ++i) {
|
||||
string var_name = name + i;
|
||||
array[i] = MakeIntVar(values, var_name);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public IntVar[] MakeIntVarArray(int count, int[] values) {
|
||||
IntVar[] array = new IntVar[count];
|
||||
for (int i = 0; i < count; ++i) {
|
||||
array[i] = MakeIntVar(values);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public IntVar[] MakeIntVarArray(int count, int[] values, string name) {
|
||||
IntVar[] array = new IntVar[count];
|
||||
for (int i = 0; i < count; ++i) {
|
||||
string var_name = name + i;
|
||||
array[i] = MakeIntVar(values, var_name);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public IntVar[] MakeBoolVarArray(int count) {
|
||||
IntVar[] array = new IntVar[count];
|
||||
for (int i = 0; i < count; ++i) {
|
||||
array[i] = MakeBoolVar();
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public IntVar[] MakeBoolVarArray(int count, string name) {
|
||||
IntVar[] array = new IntVar[count];
|
||||
for (int i = 0; i < count; ++i) {
|
||||
string var_name = name + i;
|
||||
array[i] = MakeBoolVar(var_name);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public IntVar[,] MakeIntVarMatrix(int rows, int cols, long min, long max) {
|
||||
IntVar[,] array = new IntVar[rows, cols];
|
||||
for (int i = 0; i < rows; ++i) {
|
||||
for (int j = 0; j < cols; ++j) {
|
||||
array[i,j] = MakeIntVar(min, max);
|
||||
}
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public IntVar[,] MakeIntVarMatrix(int rows, int cols,
|
||||
long min, long max, string name) {
|
||||
IntVar[,] array = new IntVar[rows, cols];
|
||||
for (int i = 0; i < rows; ++i) {
|
||||
for (int j = 0; j < cols; ++j) {
|
||||
string var_name = name + "["+ i + ", " + j +"]";
|
||||
array[i,j] = MakeIntVar(min, max, var_name);
|
||||
}
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public IntVar[,] MakeIntVarMatrix(int rows, int cols, long[] values) {
|
||||
IntVar[,] array = new IntVar[rows, cols];
|
||||
for (int i = 0; i < rows; ++i) {
|
||||
for (int j = 0; j < cols; ++j) {
|
||||
array[i,j] = MakeIntVar(values);
|
||||
}
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public IntVar[,] MakeIntVarMatrix(int rows, int cols,
|
||||
long[] values, string name) {
|
||||
IntVar[,] array = new IntVar[rows, cols];
|
||||
for (int i = 0; i < rows; ++i) {
|
||||
for (int j = 0; j < cols; ++j) {
|
||||
string var_name = name + "["+ i + ", " + j +"]";
|
||||
array[i,j] = MakeIntVar(values, var_name);
|
||||
}
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public IntVar[,] MakeIntVarMatrix(int rows, int cols, int[] values) {
|
||||
IntVar[,] array = new IntVar[rows, cols];
|
||||
for (int i = 0; i < rows; ++i) {
|
||||
for (int j = 0; j < cols; ++j) {
|
||||
array[i,j] = MakeIntVar(values);
|
||||
}
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public IntVar[,] MakeIntVarMatrix(int rows, int cols,
|
||||
int[] values, string name) {
|
||||
IntVar[,] array = new IntVar[rows, cols];
|
||||
for (int i = 0; i < rows; ++i) {
|
||||
for (int j = 0; j < cols; ++j) {
|
||||
string var_name = name + "["+ i + ", " + j +"]";
|
||||
array[i,j] = MakeIntVar(values, var_name);
|
||||
}
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public IntVar[,] MakeBoolVarMatrix(int rows, int cols) {
|
||||
IntVar[,] array = new IntVar[rows, cols];
|
||||
for (int i = 0; i < rows; ++i) {
|
||||
for (int j = 0; j < cols; ++j) {
|
||||
array[i,j] = MakeBoolVar();
|
||||
}
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public IntVar[,] MakeBoolVarMatrix(int rows, int cols, string name) {
|
||||
IntVar[,] array = new IntVar[rows, cols];
|
||||
for (int i = 0; i < rows; ++i) {
|
||||
for (int j = 0; j < cols; ++j) {
|
||||
string var_name = name + "["+ i + ", " + j +"]";
|
||||
array[i,j] = MakeBoolVar(var_name);
|
||||
}
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public IntervalVar[] MakeFixedDurationIntervalVarArray(int count,
|
||||
long start_min,
|
||||
long start_max,
|
||||
long duration,
|
||||
bool optional) {
|
||||
IntervalVar[] array = new IntervalVar[count];
|
||||
for (int i = 0; i < count; ++i) {
|
||||
array[i] = MakeFixedDurationIntervalVar(start_min,
|
||||
start_max,
|
||||
duration,
|
||||
optional,
|
||||
"");
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public IntervalVar[] MakeFixedDurationIntervalVarArray(int count,
|
||||
long start_min,
|
||||
long start_max,
|
||||
long duration,
|
||||
bool optional,
|
||||
string name) {
|
||||
IntervalVar[] array = new IntervalVar[count];
|
||||
for (int i = 0; i < count; ++i) {
|
||||
array[i] = MakeFixedDurationIntervalVar(start_min,
|
||||
start_max,
|
||||
duration,
|
||||
optional,
|
||||
name + i);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public IntervalVar[] MakeFixedDurationIntervalVarArray(int count,
|
||||
long[] start_min,
|
||||
long[] start_max,
|
||||
long[] duration,
|
||||
bool optional,
|
||||
string name) {
|
||||
IntervalVar[] array = new IntervalVar[count];
|
||||
for (int i = 0; i < count; ++i) {
|
||||
array[i] = MakeFixedDurationIntervalVar(start_min[i],
|
||||
start_max[i],
|
||||
duration[i],
|
||||
optional,
|
||||
name + i);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public IntervalVar[] MakeFixedDurationIntervalVarArray(int count,
|
||||
int[] start_min,
|
||||
int[] start_max,
|
||||
int[] duration,
|
||||
bool optional,
|
||||
string name) {
|
||||
IntervalVar[] array = new IntervalVar[count];
|
||||
for (int i = 0; i < count; ++i) {
|
||||
array[i] = MakeFixedDurationIntervalVar(start_min[i],
|
||||
start_max[i],
|
||||
duration[i],
|
||||
optional,
|
||||
name + i);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
public IntervalVar[] MakeFixedDurationIntervalVarArray(IntVar[] starts,
|
||||
int[] durations,
|
||||
string name) {
|
||||
int count = starts.Length;
|
||||
IntervalVar[] array = new IntervalVar[count];
|
||||
for (int i = 0; i < count; ++i) {
|
||||
array[i] = MakeFixedDurationIntervalVar(starts[i],
|
||||
durations[i],
|
||||
name + i);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
public IntervalVar[] MakeFixedDurationIntervalVarArray(IntVar[] starts,
|
||||
long[] durations,
|
||||
string name) {
|
||||
int count = starts.Length;
|
||||
IntervalVar[] array = new IntervalVar[count];
|
||||
for (int i = 0; i < count; ++i) {
|
||||
array[i] = MakeFixedDurationIntervalVar(starts[i],
|
||||
durations[i],
|
||||
name + i);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
public void NewSearch(DecisionBuilder db) {
|
||||
pinned_decision_builder_ = db;
|
||||
pinned_search_monitors_.Clear();
|
||||
NewSearchAux(db);
|
||||
}
|
||||
|
||||
public void NewSearch(DecisionBuilder db, SearchMonitor sm1) {
|
||||
pinned_decision_builder_ = db;
|
||||
pinned_search_monitors_.Clear();
|
||||
pinned_search_monitors_.Add(sm1);
|
||||
NewSearchAux(db, sm1);
|
||||
}
|
||||
|
||||
|
||||
public void NewSearch(DecisionBuilder db,
|
||||
SearchMonitor sm1,
|
||||
SearchMonitor sm2) {
|
||||
pinned_decision_builder_ = db;
|
||||
pinned_search_monitors_.Clear();
|
||||
pinned_search_monitors_.Add(sm1);
|
||||
pinned_search_monitors_.Add(sm2);
|
||||
NewSearchAux(db, sm1, sm2);
|
||||
}
|
||||
|
||||
public void NewSearch(DecisionBuilder db,
|
||||
SearchMonitor sm1,
|
||||
SearchMonitor sm2,
|
||||
SearchMonitor sm3) {
|
||||
pinned_decision_builder_ = db;
|
||||
pinned_search_monitors_.Clear();
|
||||
pinned_search_monitors_.Add(sm1);
|
||||
pinned_search_monitors_.Add(sm2);
|
||||
pinned_search_monitors_.Add(sm3);
|
||||
NewSearchAux(db, sm1, sm2, sm3);
|
||||
}
|
||||
|
||||
public void NewSearch(DecisionBuilder db,
|
||||
SearchMonitor sm1,
|
||||
SearchMonitor sm2,
|
||||
SearchMonitor sm3,
|
||||
SearchMonitor sm4) {
|
||||
pinned_decision_builder_ = db;
|
||||
pinned_search_monitors_.Clear();
|
||||
pinned_search_monitors_.Add(sm1);
|
||||
pinned_search_monitors_.Add(sm2);
|
||||
pinned_search_monitors_.Add(sm3);
|
||||
pinned_search_monitors_.Add(sm4);
|
||||
NewSearchAux(db, sm1, sm2, sm3, sm4);
|
||||
}
|
||||
|
||||
public void NewSearch(DecisionBuilder db, SearchMonitor[] monitors) {
|
||||
pinned_decision_builder_ = db;
|
||||
pinned_search_monitors_.Clear();
|
||||
pinned_search_monitors_.AddRange(monitors);
|
||||
NewSearchAux(db, monitors);
|
||||
}
|
||||
|
||||
public void EndSearch() {
|
||||
pinned_decision_builder_ = null;
|
||||
pinned_search_monitors_.Clear();
|
||||
EndSearchAux();
|
||||
}
|
||||
|
||||
private System.Collections.Generic.List<SearchMonitor> pinned_search_monitors_
|
||||
= new System.Collections.Generic.List<SearchMonitor>();
|
||||
private DecisionBuilder pinned_decision_builder_;
|
||||
%}
|
||||
|
||||
%extend Assignment {
|
||||
int ForwardSequenceSize(const SequenceVar* const v) const {
|
||||
return $self->ForwardSequence(v).size();
|
||||
}
|
||||
int ForwardSequenceValueAt(const SequenceVar* const v, int i) const {
|
||||
return $self->ForwardSequence(v)[i];
|
||||
}
|
||||
int BackwardSequenceSize(const SequenceVar* const v) const {
|
||||
return $self->BackwardSequence(v).size();
|
||||
}
|
||||
int BackwardSequenceValueAt(const SequenceVar* const v, int position) const {
|
||||
return $self->BackwardSequence(v)[position];
|
||||
}
|
||||
int UnperformedSize(const SequenceVar* const v) const {
|
||||
return $self->Unperformed(v).size();
|
||||
}
|
||||
int UnperformedValueAt(const SequenceVar* const v, int position) const {
|
||||
return $self->Unperformed(v)[position];
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(cscode) Assignment %{
|
||||
public int[] ForwardSequence(SequenceVar v) {
|
||||
int size = ForwardSequenceSize(v);
|
||||
int[] result = new int[size];
|
||||
for (int i = 0; i < size; ++i) result[i] = ForwardSequenceValueAt(v, i);
|
||||
return result;
|
||||
}
|
||||
public int[] BackwardSequence(SequenceVar v) {
|
||||
int size = BackwardSequenceSize(v);
|
||||
int[] result = new int[size];
|
||||
for (int i = 0; i < size; ++i) result[i] = BackwardSequenceValueAt(v, i);
|
||||
return result;
|
||||
}
|
||||
public int[] Unperformed(SequenceVar v) {
|
||||
int size = UnperformedSize(v);
|
||||
int[] result = new int[size];
|
||||
for (int i = 0; i < size; ++i) result[i] = UnperformedValueAt(v, i);
|
||||
return result;
|
||||
}
|
||||
%}
|
||||
|
||||
%extend SequenceVarLocalSearchOperator {
|
||||
int SequenceSize(int index) const {
|
||||
return $self->Sequence(index).size();
|
||||
}
|
||||
int SequenceValueAt(int index, int position) const {
|
||||
return $self->Sequence(index)[position];
|
||||
}
|
||||
int OldSequenceSize(int index) const {
|
||||
return $self->OldSequence(index).size();
|
||||
}
|
||||
int OldSequenceValueAt(int index, int position) const {
|
||||
return $self->OldSequence(index)[position];
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(cscode) SequenceVarLocalSearchOperator %{
|
||||
public int[] Sequence(int index) {
|
||||
int size = SequenceSize(index);
|
||||
int[] result = new int[size];
|
||||
for (int position = 0; position < size; ++position) {
|
||||
result[position] = SequenceValueAt(index, position);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public int[] OldSequence(int index) {
|
||||
int size = OldSequenceSize(index);
|
||||
int[] result = new int[size];
|
||||
for (int position = 0; position < size; ++position) {
|
||||
result[position] = OldSequenceValueAt(index, position);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
%}
|
||||
|
||||
%extend IntVarLocalSearchFilter {
|
||||
int Index(IntVar* const var) {
|
||||
int64 index = -1;
|
||||
@@ -985,14 +403,4 @@ namespace operations_research {
|
||||
%template(RevBool) Rev<bool>;
|
||||
typedef Assignment::AssignmentContainer AssignmentContainer;
|
||||
%template(AssignmentIntContainer) AssignmentContainer<IntVar, IntVarElement>;
|
||||
|
||||
// We can't use VarLocalSearchOperator::[Old]Value() because it's problematic
|
||||
// when instantiated on the SequenceVarLocalSearchOperator subclass (because
|
||||
// their return type is a const std::vector<int>&). So we ignore them and
|
||||
// redefine them here, only for the base class of IntVarLocalSearchOperator.
|
||||
%extend VarLocalSearchOperator<operations_research::IntVar, int64,
|
||||
operations_research::IntVarLocalSearchHandler> {
|
||||
int64 Value(int64 i) const { return $self->Value(i); }
|
||||
int64 OldValue(int64 i) const { return $self->OldValue(i); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#include "constraint_solver/routing.h"
|
||||
%}
|
||||
|
||||
%module(directors="1") operations_research;
|
||||
|
||||
// Convert RoutingModel::NodeIndex to (32-bit signed) integers.
|
||||
%typemap(ctype) operations_research::RoutingModel::NodeIndex "int"
|
||||
%typemap(imtype) operations_research::RoutingModel::NodeIndex "int"
|
||||
@@ -45,12 +47,28 @@
|
||||
}
|
||||
%}
|
||||
|
||||
// Convert std::vector<RoutingModel::NodeIndex> to/from int arrays.
|
||||
// This typemap will transform a .net array into a pair length, c array.
|
||||
// This pair is then used to rebuild a vector from it.
|
||||
%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>& %{
|
||||
$1 = new std::vector<TYPE>;
|
||||
$1->reserve(length$argnum);
|
||||
for(int i = 0; i < length$argnum; ++i) {
|
||||
$1->emplace_back($input[i]);
|
||||
}
|
||||
%}
|
||||
%enddef // CS_TYPEMAP_STDVECTOR
|
||||
|
||||
CS_TYPEMAP_STDVECTOR(operations_research::RoutingModel::NodeIndex, int, int);
|
||||
CS_TYPEMAP_STDVECTOR_IN1(operations_research::RoutingModel::NodeIndex, int, int);
|
||||
|
||||
// Create input mapping for NodeEvaluator2
|
||||
%module(directors="1") main
|
||||
%feature("director") NodeEvaluator2;
|
||||
%{
|
||||
class NodeEvaluator2 : private operations_research::RoutingModel::NodeEvaluator2 {
|
||||
|
||||
@@ -640,13 +640,13 @@ class RoutingModel {
|
||||
indices->clear();
|
||||
}
|
||||
}
|
||||
#ifndef SWIG
|
||||
#if !defined(SWIGPYTHON) && !defined(SWIGJAVA)
|
||||
// Returns the variable indices of the nodes in the disjunction of index
|
||||
// 'index'.
|
||||
const std::vector<int>& GetDisjunctionIndices(DisjunctionIndex index) const {
|
||||
return disjunctions_[index].nodes;
|
||||
}
|
||||
#endif
|
||||
#endif // !defined(SWIGPYTHON) && !defined(SWIGJAVA)
|
||||
// Returns the penalty of the node disjunction of index 'index'.
|
||||
int64 GetDisjunctionPenalty(DisjunctionIndex index) const {
|
||||
return disjunctions_[index].penalty;
|
||||
@@ -886,14 +886,14 @@ class RoutingModel {
|
||||
// Returns true if the route of 'vehicle' is non empty in 'assignment'.
|
||||
bool IsVehicleUsed(const Assignment& assignment, int vehicle) const;
|
||||
// Variables
|
||||
#if !defined(SWIG)
|
||||
#if !defined(SWIGPYTHON) && !defined(SWIGJAVA)
|
||||
// Returns all next variables of the model, such that Nexts(i) is the next
|
||||
// variable of the node corresponding to i.
|
||||
const std::vector<IntVar*>& Nexts() const { return nexts_; }
|
||||
// Returns all vehicle variables of the model, such that VehicleVars(i) is
|
||||
// the vehicle variable of the node corresponding to i.
|
||||
const std::vector<IntVar*>& VehicleVars() const { return vehicle_vars_; }
|
||||
#endif
|
||||
#endif // !defined(SWIGPYTHON) && !defined(SWIGJAVA)
|
||||
// Returns the next variable of the node corresponding to index.
|
||||
IntVar* NextVar(int64 index) const { return nexts_[index]; }
|
||||
// Returns the active variable of the node corresponding to index.
|
||||
@@ -1039,9 +1039,9 @@ class RoutingModel {
|
||||
int64 GetDimensionSpanCost(const std::string& d) const;
|
||||
int64 GetTransitValue(const std::string& d, int64 from, int64 to,
|
||||
int64 vehicle) const;
|
||||
#ifndef SWIG
|
||||
#if !defined(SWIGPYTHON) && !defined(SWIGJAVA)
|
||||
const std::vector<IntVar*>& CumulVars(const std::string& dimension_name) const;
|
||||
#endif
|
||||
#endif // !defined(SWIGPYTHON) && !defined(SWIGJAVA)
|
||||
// All the methods below are replaced by public methods with the same name
|
||||
// on the RoutingDimension class. See those.
|
||||
IntVar* CumulVar(int64 index, const std::string& dimension_name) const;
|
||||
@@ -1300,12 +1300,13 @@ class RoutingDimension {
|
||||
IntVar* CumulVar(int64 index) const { return cumuls_[index]; }
|
||||
IntVar* TransitVar(int64 index) const { return transits_[index]; }
|
||||
IntVar* SlackVar(int64 index) const { return slacks_[index]; }
|
||||
#ifndef SWIG
|
||||
#if !defined(SWIGPYTHON) && !defined(SWIGJAVA)
|
||||
// Like CumulVar(), TransitVar(), SlackVar() but return the whole variable
|
||||
// vectors instead (indexed by int64 var index).
|
||||
const std::vector<IntVar*>& cumuls() const { return cumuls_; }
|
||||
const std::vector<IntVar*>& transits() const { return transits_; }
|
||||
const std::vector<IntVar*>& slacks() const { return slacks_; }
|
||||
#if !defined(SWIGCSHARP)
|
||||
// Returns the callback evaluating the capacity for vehicle indices.
|
||||
RoutingModel::VehicleEvaluator* capacity_evaluator() const {
|
||||
return capacity_evaluator_.get();
|
||||
@@ -1316,6 +1317,7 @@ class RoutingDimension {
|
||||
return transit_evaluators_[vehicle];
|
||||
}
|
||||
#endif
|
||||
#endif // !defined(SWIGPYTHON) && !defined(SWIGJAVA)
|
||||
// Sets an upper bound on the dimension span on a given vehicle. This is the
|
||||
// preferred way to limit the "length" of the route of a vehicle according to
|
||||
// a dimension.
|
||||
|
||||
@@ -21,32 +21,6 @@ using std::string;
|
||||
|
||||
%include base/base.swig
|
||||
|
||||
////////////////////////////////////////////////
|
||||
//
|
||||
// CS_TYPEMAP_STDVECTOR
|
||||
//
|
||||
// Map c# arrays to c++ vectors for POD types.
|
||||
//
|
||||
////////////////////////////////////////////////
|
||||
|
||||
// This typemap will transform a .net array into a pair length, c array.
|
||||
// This pair is then used to rebuild a vector from it.
|
||||
%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>& %{
|
||||
$1 = new std::vector<TYPE>;
|
||||
$1->reserve(length$argnum);
|
||||
for(int i = 0; i < length$argnum; ++i) {
|
||||
$1->emplace_back($input[i]);
|
||||
}
|
||||
%}
|
||||
%enddef // CS_TYPEMAP_STDVECTOR
|
||||
|
||||
////////////////////////////////////////////////
|
||||
//
|
||||
// CS_TYPEMAP_STDVECTOR_IN1
|
||||
@@ -85,75 +59,9 @@ using std::string;
|
||||
%}
|
||||
%enddef // CS_TYPEMAP_STDVECTOR_IN1
|
||||
|
||||
////////////////////////////////////////////////
|
||||
//
|
||||
// CS_TYPEMAP_PTRARRAY
|
||||
//
|
||||
////////////////////////////////////////////////
|
||||
/* allow partial c# classes */
|
||||
%typemap(csclassmodifiers) SWIGTYPE "public partial class"
|
||||
|
||||
// This typemap will perform the same transformation for an array of object.
|
||||
// The result is an vector of the C objects.
|
||||
%define CS_TYPEMAP_PTRARRAY(CTYPE, TYPE)
|
||||
|
||||
%typemap(cscode) CTYPE %{
|
||||
public static IntPtr[] getCPtr(TYPE[] arr) {
|
||||
IntPtr[] pointers = new IntPtr[arr.Length];
|
||||
for (int i = 0; i < arr.Length; i++) {
|
||||
pointers[i] = (IntPtr)TYPE.getCPtr(arr[i]);
|
||||
}
|
||||
return pointers;
|
||||
}
|
||||
%}
|
||||
|
||||
%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** ""
|
||||
|
||||
%enddef // CS_TYPEMAP_PTRARRAY
|
||||
|
||||
////////////////////////////////////////////////
|
||||
//
|
||||
// CS_TYPEMAP_STDVECTOR_OBJECT
|
||||
//
|
||||
// Map c# arrays to c++ vectors for swiged C++ objects.
|
||||
//
|
||||
////////////////////////////////////////////////
|
||||
|
||||
%define CS_TYPEMAP_STDVECTOR_OBJECT(CTYPE, TYPE)
|
||||
|
||||
%typemap(cscode) CTYPE %{
|
||||
public static IntPtr[] getCPtr(TYPE[] arr) {
|
||||
IntPtr[] pointers = new IntPtr[arr.Length];
|
||||
for (int i = 0; i < arr.Length; i++)
|
||||
pointers[i] = (IntPtr)TYPE.getCPtr(arr[i]);
|
||||
return pointers;
|
||||
}
|
||||
%}
|
||||
|
||||
%typemap(ctype) const std::vector<CTYPE*>& "int length$argnum, CTYPE**"
|
||||
%typemap(imtype) const std::vector<CTYPE*>& "int length$argnum, IntPtr[]"
|
||||
%typemap(cstype) const std::vector<CTYPE*>& "TYPE[]"
|
||||
%typemap(csin) const std::vector<CTYPE*>& "$csinput.Length, TYPE.getCPtr($csinput)"
|
||||
%typemap(in) const std::vector<CTYPE*>& (std::vector<CTYPE*> result) {
|
||||
result.reserve(length$argnum);
|
||||
for (int i = 0; i < length$argnum; i++) {
|
||||
result.emplace_back($input[i]);
|
||||
}
|
||||
$1 = &result;
|
||||
}
|
||||
%enddef // CS_TYPEMAP_STDVECTOR_OBJECT
|
||||
|
||||
CS_TYPEMAP_STDVECTOR(int64, int64, long)
|
||||
CS_TYPEMAP_STDVECTOR(int, int, int)
|
||||
CS_TYPEMAP_STDVECTOR_IN1(int64, int64, long)
|
||||
CS_TYPEMAP_STDVECTOR_IN1(int, int, int)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user