This repository has been archived by the owner on May 10, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #128 from garciparedes/issue-127
Issue 127
- Loading branch information
Showing
33 changed files
with
462 additions
and
328 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,106 @@ | ||
@startuml | ||
skinparam linetype ortho | ||
skinparam nodesep 100 | ||
skinparam ranksep 100 | ||
|
||
hide empty methods | ||
hide empty attributes | ||
|
||
entity Job <<models>> | ||
entity Fleet <<models>> | ||
|
||
entity Result <<models>> | ||
|
||
abstract class Algorithm <<algorithms>> | ||
|
||
class MilpAlgorithm <<algorithms>> | ||
|
||
abstract class LinearModel <<algorithms>> | ||
class ThreeIndexLinearModel <<algorithms>> | ||
|
||
class InsertionAlgorithm <<algorithms>> | ||
|
||
class InsertionIterator <<algorithms>> | ||
class RankingInsertionIterator <<algorithms>> | ||
class StatelessInsertionIterator <<algorithms>> | ||
|
||
class InsertionStrategy <<algorithms>> | ||
class IntensiveInsertionStrategy <<algorithms>> | ||
class SamplingInsertionStrategy <<algorithms>> | ||
class TailInsertionStrategy <<algorithms>> | ||
|
||
class LocalSearchAlgorithm <<algorithms>> | ||
|
||
abstract class LocalSearchStrategy <<algorithms>> | ||
class ReallocationLocalSearchStrategy <<algorithms>> | ||
class OneShiftLocalSearchStrategy <<algorithms>> | ||
class TwoOPTLocalSearchStrategy <<algorithms>> | ||
|
||
class GRASPAlgorithm <<algorithms>> | ||
class IterativeAlgorithm <<algorithms>> | ||
class SequentialAlgorithm <<algorithms>> | ||
|
||
|
||
InsertionAlgorithm -up-|> Algorithm | ||
Algorithm <|-- LocalSearchAlgorithm | ||
Algorithm <|-- GRASPAlgorithm | ||
MilpAlgorithm --|> Algorithm | ||
IterativeAlgorithm --|> Algorithm | ||
SequentialAlgorithm --|> Algorithm | ||
|
||
|
||
|
||
InsertionStrategy <|- IntensiveInsertionStrategy | ||
InsertionStrategy <|-- SamplingInsertionStrategy | ||
InsertionStrategy <|-- TailInsertionStrategy | ||
|
||
RankingInsertionIterator --|> InsertionIterator | ||
StatelessInsertionIterator --|> InsertionIterator | ||
|
||
LinearModel <|-up- ThreeIndexLinearModel | ||
|
||
LocalSearchStrategy <|-- ReallocationLocalSearchStrategy | ||
LocalSearchStrategy <|-- OneShiftLocalSearchStrategy | ||
LocalSearchStrategy <|-- TwoOPTLocalSearchStrategy | ||
|
||
|
||
|
||
InsertionAlgorithm -up- InsertionIterator | ||
InsertionAlgorithm -down- InsertionStrategy | ||
|
||
MilpAlgorithm -up- LinearModel | ||
|
||
LocalSearchAlgorithm -down- LocalSearchStrategy | ||
|
||
|
||
GRASPAlgorithm -down- LocalSearchAlgorithm | ||
GRASPAlgorithm -down- InsertionAlgorithm | ||
|
||
|
||
note "composed of" as N1 | ||
N1 --o IterativeAlgorithm | ||
Algorithm - N1 | ||
|
||
note "composed of" as N2 | ||
N2 --o SequentialAlgorithm | ||
Algorithm - N2 | ||
|
||
|
||
Job "receives "-o Algorithm | ||
Fleet "receives"-o Algorithm | ||
Result "generates"- Algorithm | ||
|
||
Job -down[hidden]- Fleet | ||
Fleet -down[hidden]- Result | ||
|
||
|
||
ReallocationLocalSearchStrategy -down[hidden]- OneShiftLocalSearchStrategy | ||
OneShiftLocalSearchStrategy -down[hidden]- TwoOPTLocalSearchStrategy | ||
|
||
IntensiveInsertionStrategy -down[hidden]- SamplingInsertionStrategy | ||
SamplingInsertionStrategy -down[hidden]- TailInsertionStrategy | ||
|
||
RankingInsertionIterator -down[hidden]- StatelessInsertionIterator | ||
|
||
@enduml | ||
|
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,42 @@ | ||
@startuml | ||
skinparam linetype ortho | ||
skinparam nodesep 100 | ||
skinparam ranksep 100 | ||
|
||
hide empty methods | ||
hide empty attributes | ||
|
||
entity Job <<models>> | ||
entity Fleet <<models>> | ||
entity Surface <<models>> | ||
|
||
abstract class Loader <<loaders>> { | ||
} | ||
|
||
class FileLoader <<loaders>> { | ||
} | ||
|
||
abstract class LoaderFormatter <<loaders>> { | ||
} | ||
|
||
class CordeauLaporteLoaderFormatter <<loaders>> { | ||
} | ||
|
||
class HashCodeLoaderFormatter <<loaders>> { | ||
} | ||
|
||
|
||
Loader -up-"loads" Job | ||
Loader -up-"loads" Fleet | ||
Loader -up-"loads" Surface | ||
|
||
LoaderFormatter "uses"-right-o Loader | ||
|
||
Loader <|-down- FileLoader | ||
|
||
LoaderFormatter <|-down- CordeauLaporteLoaderFormatter | ||
LoaderFormatter <|-down- HashCodeLoaderFormatter | ||
|
||
|
||
@enduml | ||
|
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,14 @@ | ||
@startuml | ||
|
||
package "jinete" { | ||
[models] | ||
[loaders] | ||
[algorithms] | ||
[storers] | ||
[dispachers] | ||
[solvers] | ||
[exceptions] | ||
[utils] | ||
} | ||
|
||
@enduml |
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,52 @@ | ||
@startuml | ||
skinparam linetype ortho | ||
skinparam nodesep 100 | ||
skinparam ranksep 100 | ||
|
||
hide empty methods | ||
hide empty attributes | ||
|
||
entity Result <<models>> | ||
|
||
entity Storer <<storers>> { | ||
} | ||
|
||
abstract class FileStorer <<storers>> { | ||
} | ||
class SetStorer <<storers>> { | ||
} | ||
class PromptStorer <<storers>> { | ||
} | ||
class GraphPlotStorer <<storers>> { | ||
} | ||
|
||
abstract class StorerFormatter <<storers>> { | ||
} | ||
class ColumnarStorerFormatter <<storers>> { | ||
} | ||
class HashCodeStorerFormatter <<storers>> { | ||
} | ||
|
||
|
||
Storer -up-"stores" Result | ||
|
||
StorerFormatter "uses"-right-o Storer | ||
|
||
note "composed of" as N2 | ||
N2 --o SetStorer | ||
N2 - Storer | ||
|
||
|
||
Storer <|-down- FileStorer | ||
Storer <|-down- PromptStorer | ||
Storer <|-down- SetStorer | ||
|
||
|
||
Storer <|-down- GraphPlotStorer | ||
|
||
StorerFormatter <|-down- ColumnarStorerFormatter | ||
StorerFormatter <|-down- HashCodeStorerFormatter | ||
|
||
|
||
@enduml | ||
|
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,45 @@ | ||
import logging | ||
import traceback | ||
from concurrent import ( | ||
futures, | ||
) | ||
from pathlib import ( | ||
Path, | ||
) | ||
from subprocess import ( | ||
STDOUT, | ||
TimeoutExpired, | ||
check_output, | ||
) | ||
|
||
logging.basicConfig(level=logging.INFO) | ||
logger = logging.getLogger(__name__) | ||
|
||
DATASETS_PATH = Path(__file__).absolute().parents[2] / "res" / "datasets" / "cordeau-laporte" | ||
INSTANCE_TIMEOUT = 7200 | ||
|
||
|
||
def main(): | ||
with futures.ProcessPoolExecutor() as executor: | ||
for file_path in DATASETS_PATH.glob("*.txt"): | ||
executor.submit(run_one, file_path) | ||
|
||
|
||
def run_one(file_path): | ||
try: | ||
command = ["python3", "benchmark_solve.py", str(file_path.absolute())] | ||
print(f'COMMAND: "{" ".join(command)}"') | ||
try: | ||
output = check_output(command, timeout=INSTANCE_TIMEOUT, stderr=STDOUT, cwd=Path(__file__).parent).decode() | ||
except TimeoutExpired as exc: | ||
print(exc) | ||
output = exc.output.decode() | ||
with (file_path.parent / f"{file_path.name}.log").open("w") as file: | ||
file.write(output) | ||
except Exception as exc: | ||
traceback.print_exc() | ||
raise exc | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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,42 @@ | ||
import logging | ||
import sys | ||
import traceback | ||
from functools import ( | ||
partial, | ||
) | ||
from pathlib import ( | ||
Path, | ||
) | ||
|
||
import jinete as jit | ||
|
||
logging.basicConfig(level=logging.INFO) | ||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def main(): | ||
logger.info("Starting...") | ||
file_path = Path(sys.argv[1]) | ||
solver = jit.Solver( | ||
loader_kwargs={"file_path": file_path}, | ||
algorithm=jit.GraspAlgorithm, | ||
algorithm_kwargs={"first_solution_kwargs": {"episodes": 1, "randomized_size": 2}, "episodes": 5}, | ||
storer=jit.StorerSet, | ||
storer_kwargs={ | ||
"storer_cls_set": { | ||
jit.PromptStorer, | ||
partial(jit.GraphPlotStorer, file_path=file_path.parent / f"{file_path.name}.png"), | ||
partial(jit.FileStorer, file_path=file_path.parent / f"{file_path.name}.output"), | ||
} | ||
}, | ||
) | ||
result = solver.solve() # noqa | ||
logger.info("Finished...") | ||
|
||
|
||
if __name__ == "__main__": | ||
try: | ||
main() | ||
except Exception as exc: | ||
traceback.print_exc() | ||
raise exc |
Oops, something went wrong.