-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
minor updates, added script for paper and configs
- Loading branch information
Philipp Brendel
committed
May 18, 2021
1 parent
b61af35
commit c1610c2
Showing
6 changed files
with
296 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#################### | ||
# initial settings # | ||
#################### | ||
t_0: '10:30' # initial clock time | ||
T: 2.0 # [h] | ||
delta_t: 0.25 # [h] | ||
c_init: 1.0 # initial soc of nodes | ||
p_init: 0.0 # initial soc of producers | ||
vehicle_init: 0.1 # initial soc of vehicles | ||
|
||
|
||
################## | ||
# Data locations # | ||
################## | ||
vehicle_dir: 'data/vehicles' | ||
depot_dir: 'data/depots' | ||
consumer_dir: 'data/paper/c_easy.csv' | ||
producer_dir: 'data/paper/p_all.csv' | ||
other_dir: 'data/others' | ||
|
||
|
||
##################### | ||
# Data restrictions # | ||
##################### | ||
v_max: 40 | ||
c_max: 1 | ||
p_max: 1 | ||
o_max: 0 | ||
d_max: 1 | ||
lat: [49.00, 49.90] # min and max vals | ||
lon: [7.50, 7.90] | ||
|
||
|
||
################## | ||
# Model settings # | ||
################## | ||
objective: 0 | ||
constr_j: True # (1j) valid inequality | ||
min_vehicles: True # toggle obj and constraints connected to z | ||
limit_vehicles: True # (1l) limit charging vehicles at locations | ||
visualize: False # visualize solution | ||
constrain_vehicles: 12 # only allow leq this many vehicles being used | ||
|
||
###################### | ||
# Heuristic settings # | ||
###################### | ||
h_init_time_limit: 120 | ||
h_time_limit: 60 | ||
h_init: quick # [quick, greedy] | ||
|
||
|
||
################### | ||
# Gurobi settings # | ||
################### | ||
TimeLimit: 100000 | ||
threads: 1 | ||
# multiple threads for parallel work | ||
# can be restricted in order to save RAM | ||
method: -1 | ||
# method used to solve root relaxation (only root!) | ||
# -1: default 1: dual-simplex 2: barrier | ||
MIPFocus: 0 | ||
# 0: default, balance between both | ||
# 1: focus on finding feasible solutions | ||
# 2: more attention on proving optimality | ||
# 3: if best bound is barely moving | ||
MIPGap: 0.0001 | ||
# default: 0.0001 | ||
CutPasses: -1 | ||
# default: -1 | ||
write_lp: False | ||
LogToConsole: True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#################### | ||
# initial settings # | ||
#################### | ||
t_0: '10:30' # initial clock time | ||
T: 2.0 # [h] | ||
delta_t: 0.25 # [h] | ||
c_init: 1.0 # initial soc of nodes | ||
p_init: 0.0 # initial soc of producers | ||
vehicle_init: 0.1 # initial soc of vehicles | ||
|
||
|
||
################## | ||
# Data locations # | ||
################## | ||
vehicle_dir: 'data/vehicles' | ||
depot_dir: 'data/depots' | ||
consumer_dir: 'data/paper/c_extreme.csv' | ||
producer_dir: 'data/paper/p_all.csv' | ||
other_dir: 'data/others' | ||
|
||
|
||
##################### | ||
# Data restrictions # | ||
##################### | ||
v_max: 40 | ||
c_max: 1 | ||
p_max: 1 | ||
o_max: 0 | ||
d_max: 1 | ||
lat: [49.00, 49.90] # min and max vals | ||
lon: [7.50, 7.90] | ||
|
||
|
||
################## | ||
# Model settings # | ||
################## | ||
objective: 0 | ||
constr_j: True # (1j) valid inequality | ||
min_vehicles: True # toggle obj and constraints connected to z | ||
limit_vehicles: True # (1l) limit charging vehicles at locations | ||
visualize: False # visualize solution | ||
constrain_vehicles: 12 # only allow leq this many vehicles being used | ||
|
||
###################### | ||
# Heuristic settings # | ||
###################### | ||
h_init_time_limit: 120 | ||
h_time_limit: 60 | ||
h_init: quick # [quick, greedy] | ||
|
||
|
||
################### | ||
# Gurobi settings # | ||
################### | ||
TimeLimit: 100000 | ||
threads: 1 | ||
# multiple threads for parallel work | ||
# can be restricted in order to save RAM | ||
method: -1 | ||
# method used to solve root relaxation (only root!) | ||
# -1: default 1: dual-simplex 2: barrier | ||
MIPFocus: 0 | ||
# 0: default, balance between both | ||
# 1: focus on finding feasible solutions | ||
# 2: more attention on proving optimality | ||
# 3: if best bound is barely moving | ||
MIPGap: 0.0001 | ||
# default: 0.0001 | ||
CutPasses: -1 | ||
# default: -1 | ||
write_lp: False | ||
LogToConsole: True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#################### | ||
# initial settings # | ||
#################### | ||
t_0: '10:30' # initial clock time | ||
T: 2.0 # [h] | ||
delta_t: 0.25 # [h] | ||
c_init: 1.0 # initial soc of nodes | ||
p_init: 0.0 # initial soc of producers | ||
vehicle_init: 0.1 # initial soc of vehicles | ||
|
||
|
||
################## | ||
# Data locations # | ||
################## | ||
vehicle_dir: 'data/vehicles' | ||
depot_dir: 'data/depots' | ||
consumer_dir: 'data/paper/c_moderate.csv' | ||
producer_dir: 'data/paper/p_all.csv' | ||
other_dir: 'data/others' | ||
|
||
|
||
##################### | ||
# Data restrictions # | ||
##################### | ||
v_max: 40 | ||
c_max: 1 | ||
p_max: 1 | ||
o_max: 0 | ||
d_max: 1 | ||
lat: [49.00, 49.90] # min and max vals | ||
lon: [7.50, 7.90] | ||
|
||
|
||
################## | ||
# Model settings # | ||
################## | ||
objective: 0 | ||
constr_j: True # (1j) valid inequality | ||
min_vehicles: True # toggle obj and constraints connected to z | ||
limit_vehicles: True # (1l) limit charging vehicles at locations | ||
visualize: False # visualize solution | ||
constrain_vehicles: 12 # only allow leq this many vehicles being used | ||
|
||
###################### | ||
# Heuristic settings # | ||
###################### | ||
h_init_time_limit: 120 | ||
h_time_limit: 60 | ||
h_init: quick # [quick, greedy] | ||
|
||
|
||
################### | ||
# Gurobi settings # | ||
################### | ||
TimeLimit: 100000 | ||
threads: 1 | ||
# multiple threads for parallel work | ||
# can be restricted in order to save RAM | ||
method: -1 | ||
# method used to solve root relaxation (only root!) | ||
# -1: default 1: dual-simplex 2: barrier | ||
MIPFocus: 0 | ||
# 0: default, balance between both | ||
# 1: focus on finding feasible solutions | ||
# 2: more attention on proving optimality | ||
# 3: if best bound is barely moving | ||
MIPGap: 0.0001 | ||
# default: 0.0001 | ||
CutPasses: -1 | ||
# default: -1 | ||
write_lp: False | ||
LogToConsole: True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# execute python file | ||
|
||
import os | ||
import glob | ||
import logging | ||
from sys import platform | ||
import yaml | ||
|
||
from utils import * | ||
from smart_krit import my_sk | ||
|
||
|
||
# Read configs | ||
if platform in ['linux','linux2']: | ||
configs = glob.glob(os.path.join('configs', '*.YAML')) + glob.glob(os.path.join('configs', '*.yaml')) | ||
elif platform == 'win32': | ||
configs = glob.glob(os.path.join('configs', '*.YAML')) | ||
else: | ||
print('Unknown platform!') | ||
exit() | ||
|
||
# logging | ||
# TODO: | ||
|
||
|
||
for config in configs: | ||
with open(config) as config_file: | ||
yaml_dict = yaml.load(config_file, | ||
Loader=yaml.FullLoader) | ||
print(f'Config file: {config}') | ||
|
||
for t in [2.0, 3.0, 4.0, 5.0, 10.0]: | ||
# Part B: objective 0 | ||
yaml_dict['objective'] = 0 | ||
yaml_dict['T'] = t | ||
best_limit = None | ||
best_res = None | ||
for v_limit in [40, 30, 20, 15, 10, 5, 4, 3, 2, 1]: | ||
print(f'Limit: {v_limit}') | ||
yaml_dict['constrain_vehicles'] = v_limit | ||
sk = my_sk(yaml_dict) | ||
sk.preprocess() | ||
grb_mod = sk.solve() | ||
sk.postprocess(grb_mod) | ||
|
||
# Check feasibility | ||
if grb_mod.status == 2: | ||
best_limit = v_limit | ||
best_res = sk.instance_str + '.txt' | ||
print('Feasible') | ||
else: | ||
print('Infeasible') | ||
|
||
print(f'Finished part B: Best Limit: {v_limit} in file {best_res}') | ||
#exit() | ||
|
||
# Part C: warm-start with remaining time | ||
yaml_dict['constrain_vehicles'] = best_limit | ||
yaml_dict['objective'] = 1 | ||
sk = my_sk(yaml_dict) | ||
sk.preprocess() | ||
w, s_n, s_v, f, z, e = read_results(os.path.join('output', best_res)) | ||
grb_mod = sk.solve(w_start=w, s_n_start=s_n, s_v_start=s_v, | ||
f_start=f, z_start=z, e_start=e) | ||
sk.postprocess(grb_mod) | ||
|
||
exit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters