Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
Bachelorarbeit
Discrete Optimization Library
Commits
e31b2f71
Commit
e31b2f71
authored
Jan 11, 2021
by
jonasseidel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
abysmally slow but correct
parent
6c4c3a5b
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
903 additions
and
878 deletions
+903
-878
Linear_Programming/Constraint.cpp
Linear_Programming/Constraint.cpp
+2
-2
Linear_Programming/Linear_Program.cpp
Linear_Programming/Linear_Program.cpp
+9
-7
Linear_Programming/Linear_Program.h
Linear_Programming/Linear_Program.h
+1
-0
Specialization/LP_Problems/Maintenance_Problem/computational_types/generate_nmp_bendersdecomp.cpp
...roblem/computational_types/generate_nmp_bendersdecomp.cpp
+13
-2
Specialization/LP_Problems/Maintenance_Problem/computational_types/nmp_benders_conshdlr.cpp
...ance_Problem/computational_types/nmp_benders_conshdlr.cpp
+5
-3
lp
lp
+873
-864
No files found.
Linear_Programming/Constraint.cpp
View file @
e31b2f71
...
@@ -34,8 +34,8 @@ SCIP_CONS* Constraint::computational_con(SCIP* scip, std::unordered_map<Variable
...
@@ -34,8 +34,8 @@ SCIP_CONS* Constraint::computational_con(SCIP* scip, std::unordered_map<Variable
SCIP_CONS
*
cons
;
SCIP_CONS
*
cons
;
SCIP_Real
right_inequality
=
this
->
_rhs
.
value
();
SCIP_Real
right_inequality
=
this
->
_rhs
.
value
();
SCIP_Real
left_inequality
=
(
this
->
is_equality
()
?
right_inequality
:
-
SCIPinfinity
(
scip
));
SCIP_Real
left_inequality
=
(
this
->
is_equality
()
?
right_inequality
:
-
SCIPinfinity
(
scip
));
char
*
name
=
new
char
[
this
->
description
().
size
()
+
1
];
SCIP_CALL_ABORT
(
SCIPcreateConsBasicLinear
(
scip
,
&
cons
,
strcpy
(
name
,
this
->
description
().
c_str
()
)
,
SCIP_CALL_ABORT
(
SCIPcreateConsBasicLinear
(
scip
,
&
cons
,
this
->
description
().
c_str
(),
0
,
NULL
,
NULL
,
left_inequality
,
right_inequality
));
0
,
NULL
,
NULL
,
left_inequality
,
right_inequality
));
for
(
std
::
pair
<
Variable
*
,
Coefficient
>
pair
:
this
->
_lhs
){
for
(
std
::
pair
<
Variable
*
,
Coefficient
>
pair
:
this
->
_lhs
){
...
...
Linear_Programming/Linear_Program.cpp
View file @
e31b2f71
...
@@ -42,15 +42,16 @@ Polyeder& Linear_Program::polyeder(){
...
@@ -42,15 +42,16 @@ Polyeder& Linear_Program::polyeder(){
std
::
pair
<
SCIP
*
,
std
::
unordered_map
<
Variable
*
,
SCIP_VAR
*>
>
Linear_Program
::
computational_model
(){
std
::
pair
<
SCIP
*
,
std
::
unordered_map
<
Variable
*
,
SCIP_VAR
*>
>
Linear_Program
::
computational_model
(){
SCIP
*
scip
;
SCIP
*
scip
;
SCIPcreate
(
&
scip
);
SCIP_CALL_ABORT
(
SCIPcreate
(
&
scip
)
)
;
SCIPincludeDefaultPlugins
(
scip
);
SCIPincludeDefaultPlugins
(
scip
);
SCIPcreateProb
(
scip
,
this
->
description
().
c_str
(),
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
);
SCIP_CALL_ABORT
(
SCIPcreateProb
(
scip
,
this
->
description
().
c_str
(),
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
));
if
(
this
->
is_maximum
()){
if
(
this
->
is_maximum
()){
SCIPsetObjsense
(
scip
,
SCIP_OBJSENSE_MAXIMIZE
);
SCIP_CALL_ABORT
(
SCIPsetObjsense
(
scip
,
SCIP_OBJSENSE_MAXIMIZE
)
)
;
}
else
{
}
else
{
SCIPsetObjsense
(
scip
,
SCIP_OBJSENSE_MINIMIZE
);
SCIP_CALL_ABORT
(
SCIPsetObjsense
(
scip
,
SCIP_OBJSENSE_MINIMIZE
)
)
;
}
}
std
::
unordered_map
<
Variable
*
,
SCIP_VAR
*>
variable_lookup
;
std
::
unordered_map
<
Variable
*
,
SCIP_VAR
*>
variable_lookup
;
for
(
auto
pair
:
this
->
_polyeder
.
variables
()){
for
(
auto
pair
:
this
->
_polyeder
.
variables
()){
...
@@ -59,11 +60,12 @@ std::pair<SCIP*, std::unordered_map<Variable*, SCIP_VAR*> > Linear_Program::comp
...
@@ -59,11 +60,12 @@ std::pair<SCIP*, std::unordered_map<Variable*, SCIP_VAR*> > Linear_Program::comp
SCIP_VAR
*
computational_var
=
pair
.
left
->
computational_var
(
scip
,
(
search
!=
this
->
_direction
.
end
()
?
search
->
second
.
value
()
:
0
));
SCIP_VAR
*
computational_var
=
pair
.
left
->
computational_var
(
scip
,
(
search
!=
this
->
_direction
.
end
()
?
search
->
second
.
value
()
:
0
));
variable_lookup
.
insert
({
pair
.
left
,
computational_var
});
variable_lookup
.
insert
({
pair
.
left
,
computational_var
});
SCIPaddVar
(
scip
,
computational_var
);
SCIP_CALL_ABORT
(
SCIPaddVar
(
scip
,
computational_var
)
)
;
}
}
for
(
Constraint
con
:
this
->
_polyeder
.
constraints
()){
for
(
Constraint
con
:
this
->
_polyeder
.
constraints
()){
SCIP_CONS
*
computational_con
=
con
.
computational_con
(
scip
,
variable_lookup
);
SCIP_CONS
*
computational_con
=
con
.
computational_con
(
scip
,
variable_lookup
);
SCIPaddCons
(
scip
,
computational_con
);
SCIP_CALL_ABORT
(
SCIPaddCons
(
scip
,
computational_con
));
SCIP_CALL_ABORT
(
SCIPreleaseCons
(
scip
,
&
computational_con
));
}
}
return
{
scip
,
variable_lookup
};
return
{
scip
,
variable_lookup
};
...
...
Linear_Programming/Linear_Program.h
View file @
e31b2f71
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
#include <boost/bimap.hpp>
#include <boost/bimap.hpp>
#include <scip/scip.h>
#include <scip/scip.h>
#include <scip/scipdefplugins.h>
#include <scip/scipdefplugins.h>
#include <scip/debug.h>
#include "Polyeder.h"
#include "Polyeder.h"
#include "../Common/integrality.h"
#include "../Common/integrality.h"
...
...
Specialization/LP_Problems/Maintenance_Problem/computational_types/generate_nmp_bendersdecomp.cpp
View file @
e31b2f71
...
@@ -408,7 +408,13 @@ SCIP* generate_nmp_bendersdecomp(Maintenance_Problem& nmp, SCIP* basic_scip, SCI
...
@@ -408,7 +408,13 @@ SCIP* generate_nmp_bendersdecomp(Maintenance_Problem& nmp, SCIP* basic_scip, SCI
}
}
SCIP_CALL_ABORT
(
SCIPsetPresolving
(
computational_master_and_lookup
.
first
,
SCIP_PARAMSETTING_OFF
,
true
));
SCIP_CALL_ABORT
(
SCIPsetBoolParam
(
computational_master_and_lookup
.
first
,
"constraints/benders/active"
,
TRUE
)
);
SCIP_CALL_ABORT
(
SCIPsetPresolving
(
computational_master_and_lookup
.
first
,
SCIP_PARAMSETTING_OFF
,
TRUE
)
);
SCIP_CALL_ABORT
(
SCIPsetIntParam
(
computational_master_and_lookup
.
first
,
"propagating/maxrounds"
,
0
)
);
SCIP_CALL_ABORT
(
SCIPsetIntParam
(
computational_master_and_lookup
.
first
,
"propagating/maxroundsroot"
,
0
)
);
SCIP_CALL_ABORT
(
SCIPsetIntParam
(
computational_master_and_lookup
.
first
,
"heuristics/trysol/freq"
,
1
)
);
SCIP_CALL_ABORT
(
SCIPincludeConshdlrNMPBenders
(
computational_master_and_lookup
.
first
,
benders_separators_lpsols
,
benders_separators_heursols
,
nmp
.
number_of_epochs
(),
c
));
SCIP_CALL_ABORT
(
SCIPincludeConshdlrNMPBenders
(
computational_master_and_lookup
.
first
,
benders_separators_lpsols
,
benders_separators_heursols
,
nmp
.
number_of_epochs
(),
c
));
...
@@ -468,12 +474,17 @@ SCIP* generate_nmp_bendersdecomp(Maintenance_Problem& nmp, SCIP* basic_scip, SCI
...
@@ -468,12 +474,17 @@ SCIP* generate_nmp_bendersdecomp(Maintenance_Problem& nmp, SCIP* basic_scip, SCI
}
}
}
}
SCIPpresolve
(
computational_master_and_lookup
.
first
);
SCIPprintTransProblem
(
computational_master_and_lookup
.
first
,
NULL
,
NULL
,
FALSE
);
SCIPsolve
(
computational_master_and_lookup
.
first
);
SCIPsolve
(
computational_master_and_lookup
.
first
);
SCIP_Bool
feas
=
FALSE
;
SCIP_Bool
feas
=
FALSE
;
SCIPcheckSolOrig
(
computational_master_and_lookup
.
first
,
c
->
transopt
,
&
feas
,
TRUE
,
TRUE
);
SCIPcheckSol
(
computational_master_and_lookup
.
first
,
c
->
transopt
,
TRUE
,
TRUE
,
TRUE
,
TRUE
,
TRUE
,
&
feas
);
SCIPprintTransProblem
(
computational_master_and_lookup
.
first
,
NULL
,
NULL
,
FALSE
);
assert
(
feas
);
assert
(
feas
);
std
::
cout
<<
"feas: "
<<
feas
<<
std
::
endl
;
std
::
cout
<<
"feas: "
<<
feas
<<
std
::
endl
;
...
...
Specialization/LP_Problems/Maintenance_Problem/computational_types/nmp_benders_conshdlr.cpp
View file @
e31b2f71
...
@@ -116,6 +116,7 @@ SCIP_RETCODE sepa(SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_SOL* sol, SCIP* sepa
...
@@ -116,6 +116,7 @@ SCIP_RETCODE sepa(SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_SOL* sol, SCIP* sepa
SCIP_Real
tmp
=
vardata
->
capacity
*
SCIPgetSolVal
(
separator
,
sols
[
sol_index
],
separator_vars
[
var_index
]);
SCIP_Real
tmp
=
vardata
->
capacity
*
SCIPgetSolVal
(
separator
,
sols
[
sol_index
],
separator_vars
[
var_index
]);
coeffs
[
edge
]
=
tmp
;
coeffs
[
edge
]
=
tmp
;
aggregate_capacity
+=
tmp
;
aggregate_capacity
+=
tmp
;
//std::cout << tmp << "\t";
...
@@ -129,6 +130,7 @@ SCIP_RETCODE sepa(SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_SOL* sol, SCIP* sepa
...
@@ -129,6 +130,7 @@ SCIP_RETCODE sepa(SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_SOL* sol, SCIP* sepa
}
}
c_check
+=
SCIPgetSolVal
(
data
->
c
->
basic_scip
,
data
->
c
->
opt
,
data
->
c
->
trans
.
find
(
target
)
->
second
);
c_check
+=
SCIPgetSolVal
(
data
->
c
->
basic_scip
,
data
->
c
->
opt
,
data
->
c
->
trans
.
find
(
target
)
->
second
);
//std::cout << std::endl;
std
::
cout
<<
c_check
<<
" <= "
<<
aggregate_capacity
<<
std
::
endl
;
std
::
cout
<<
c_check
<<
" <= "
<<
aggregate_capacity
<<
std
::
endl
;
assert
(
c_check
<=
aggregate_capacity
);
assert
(
c_check
<=
aggregate_capacity
);
assert
(
edge
==
separator_data
->
nedges
);
assert
(
edge
==
separator_data
->
nedges
);
...
@@ -136,7 +138,7 @@ SCIP_RETCODE sepa(SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_SOL* sol, SCIP* sepa
...
@@ -136,7 +138,7 @@ SCIP_RETCODE sepa(SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_SOL* sol, SCIP* sepa
// create cons
// create cons
SCIP_CONS
*
feascut
;
SCIP_CONS
*
feascut
;
SCIPsnprintf
(
name
,
SCIP_MAXSTRLEN
,
"feascut_subp_%d_cons_%d"
,
separator_data
->
epoch
,
separator_data
->
number_of_added_cons
);
// init? sep? enfo? check? prop? local? modif? age? clean? stick?
SCIPsnprintf
(
name
,
SCIP_MAXSTRLEN
,
"feascut_subp_%d_cons_%d"
,
separator_data
->
epoch
,
separator_data
->
number_of_added_cons
);
// init? sep? enfo? check? prop? local? modif? age? clean? stick?
SCIP_CALL
(
SCIPcreateConsLinear
(
scip
,
&
feascut
,
name
,
separator_data
->
nedges
,
master_vars
,
coeffs
,
-
SCIPinfinity
(
scip
),
aggregate_capacity
,
TRUE
,
FALSE
,
TRUE
,
FALSE
,
FALSE
,
FALS
E
,
FALSE
,
FALSE
,
FALSE
,
FALSE
));
SCIP_CALL
(
SCIPcreateConsLinear
(
scip
,
&
feascut
,
name
,
separator_data
->
nedges
,
master_vars
,
coeffs
,
-
SCIPinfinity
(
scip
),
aggregate_capacity
,
TRUE
,
TRUE
,
TRUE
,
TRUE
,
TRUE
,
TRU
E
,
FALSE
,
FALSE
,
FALSE
,
FALSE
));
SCIP_CALL
(
SCIPaddCoefLinear
(
scip
,
feascut
,
target
,
1
));
SCIP_CALL
(
SCIPaddCoefLinear
(
scip
,
feascut
,
target
,
1
));
SCIP_CALL
(
SCIPaddCons
(
scip
,
feascut
));
SCIP_CALL
(
SCIPaddCons
(
scip
,
feascut
));
...
@@ -152,7 +154,7 @@ SCIP_RETCODE sepa(SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_SOL* sol, SCIP* sepa
...
@@ -152,7 +154,7 @@ SCIP_RETCODE sepa(SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_SOL* sol, SCIP* sepa
sol_index
++
;
sol_index
++
;
SCIP_Bool
feas
=
FALSE
;
SCIP_Bool
feas
=
FALSE
;
SCIP_CALL_ABORT
(
SCIPcheckSol
Orig
(
scip
,
data
->
c
->
transopt
,
&
feas
,
TRUE
,
TRUE
));
SCIP_CALL_ABORT
(
SCIPcheckSol
(
scip
,
data
->
c
->
transopt
,
TRUE
,
TRUE
,
TRUE
,
TRUE
,
TRUE
,
&
feas
));
assert
(
feas
);
assert
(
feas
);
}
}
SCIPfreeBufferArray
(
scip
,
&
coeffs
);
SCIPfreeBufferArray
(
scip
,
&
coeffs
);
...
@@ -358,7 +360,7 @@ SCIP_RETCODE SCIPincludeConshdlrNMPBenders(
...
@@ -358,7 +360,7 @@ SCIP_RETCODE SCIPincludeConshdlrNMPBenders(
SCIP_CALL
(
SCIPincludeConshdlrBasic
(
scip
,
&
conshdlr
,
"benderscons"
,
"separates nmp feasibility cuts"
,
SCIP_CALL
(
SCIPincludeConshdlrBasic
(
scip
,
&
conshdlr
,
"benderscons"
,
"separates nmp feasibility cuts"
,
1000000
,
-
1000000
,
-
1
,
FALSE
,
-
1000000
,
-
1000000
,
-
1
,
FALSE
,
enforce_lp
,
enforce_pseudo
,
check
,
lock
,
enforce_lp
,
enforce_pseudo
,
check
,
lock
,
conshdlrdata
)
);
conshdlrdata
)
);
...
...
lp
View file @
e31b2f71
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment