Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Transmitter Clusters
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OROBWorld
Transmitter Clusters
Commits
e4ce60d7
Commit
e4ce60d7
authored
3 years ago
by
Paul A. Rubin
Browse files
Options
Downloads
Patches
Plain Diff
Added a method to hot-start MIPModel.
parent
0c7658a3
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/solvers/MIPModel.java
+42
-0
42 additions, 0 deletions
src/solvers/MIPModel.java
with
42 additions
and
0 deletions
src/solvers/MIPModel.java
+
42
−
0
View file @
e4ce60d7
...
@@ -8,6 +8,7 @@ import ilog.cplex.IloCplex;
...
@@ -8,6 +8,7 @@ import ilog.cplex.IloCplex;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collection
;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
java.util.OptionalInt
;
import
xmtrclusters.Problem
;
import
xmtrclusters.Problem
;
/**
/**
...
@@ -229,4 +230,45 @@ public final class MIPModel {
...
@@ -229,4 +230,45 @@ public final class MIPModel {
}
}
return
clusters
;
return
clusters
;
}
}
/**
* Adds a hot start to the MIP.
* @param start an initial solution (collection of clusters)
* @throws IloException if CPLEX cannot process the starting solution
*/
public
void
hotStart
(
final
Collection
<
Collection
<
Integer
>>
start
)
throws
IloException
{
// Set initial values for the x variables (only).
int
nT
=
problem
.
getNTrans
();
double
[][]
xx
=
new
double
[
nT
][
nT
];
for
(
Collection
<
Integer
>
c
:
start
)
{
for
(
int
t
:
c
)
{
for
(
int
t1
:
c
)
{
if
(
t
<
t1
)
{
xx
[
t
][
t1
]
=
1.0
;
xx
[
t1
][
t
]
=
1.0
;
}
}
}
// Make the smallest element of c the anchor.
OptionalInt
m
=
c
.
stream
().
mapToInt
(
i
->
i
).
min
();
if
(
m
.
isPresent
())
{
int
mm
=
m
.
getAsInt
();
xx
[
mm
][
mm
]
=
1.0
;
}
}
// Flatten x and xx into vectors.
IloNumVar
[]
vars
=
new
IloNumVar
[
nT
*
nT
];
double
[]
vals
=
new
double
[
nT
*
nT
];
int
index
=
0
;
for
(
int
t
=
0
;
t
<
nT
;
t
++)
{
for
(
int
t1
=
0
;
t1
<
nT
;
t1
++)
{
vars
[
index
]
=
x
[
t
][
t1
];
vals
[
index
]
=
xx
[
t
][
t1
];
index
+=
1
;
}
}
// Add the MIP start.
mip
.
addMIPStart
(
vars
,
vals
);
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment