Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
93a341f
Add test for unconstrained_initialization + change Dockerfile
Jan 4, 2023
1f8b424
blackboard structure
guillaumemaranwoop Jan 5, 2023
5526865
add KS : create_matrices.py
Jan 5, 2023
50c5772
add new KS
Jan 5, 2023
91009b4
add knowledge sources
guillaumemaranwoop Jan 5, 2023
b4889a2
add new KS + bugfix
Jan 5, 2023
2deae9b
add new KS + bugfix
Jan 5, 2023
f3764ee
Merge branch 'blackboard' of github.com:guillaumemaran/optimizer-api …
Jan 5, 2023
1abb63c
Add dictionnary index_id to parse solution with the correct ids
Jan 6, 2023
d32dae1
add tests for get arguments
guillaumemaranwoop Jan 6, 2023
b2446e5
Create matrices tests and add problem schema validation
guillaumemaranwoop Jan 6, 2023
4a8ec6c
add data attributes to BB
guillaumemaranwoop Jan 6, 2023
27de60c
add service_attributes creation tests + fix some bugs
Jan 6, 2023
332893b
get arguments, add checks
guillaumemaranwoop Jan 6, 2023
5d7306f
add some tests for create_service_attributes process() function
Jan 6, 2023
b4f37bb
Merge branch 'blackboard' of github.com:guillaumemaran/optimizer-api …
Jan 6, 2023
a11e189
fix tests
guillaumemaranwoop Jan 7, 2023
a543199
Add service_attributes creation tests + fix some bugs
Jan 9, 2023
8291baa
Add new unit tests
Jan 12, 2023
77a7631
Now fastvrpy can handle multiple units for capacity constraints, and …
Pierre-Graber Jan 23, 2023
e89937b
[U-I] multiple warehouses management
Pierre-Graber Feb 8, 2023
f0ed05c
add KS to check if we can solve the problem with fastvrpy + test it
Pierre-Graber Feb 9, 2023
811e81c
[U-I] Multi TW Management
Pierre-Graber Feb 16, 2023
895ebc8
fix solution parser + adapt tests for multi depot
Pierre-Graber Feb 16, 2023
8b599ce
for now process initial solution should return None for unassigned_se…
Pierre-Graber Feb 16, 2023
013586d
for now process_initial_solution should return None for unassigned_se…
Pierre-Graber Feb 16, 2023
58c48b2
Merge branch 'blackboard' of github.com:guillaumemaran/optimizer-api …
Pierre-Graber Feb 16, 2023
57ad22f
Revert "for now process_initial_solution should return None for unass…
Pierre-Graber Feb 16, 2023
8c90927
for now process_initial_solution should return None for unassigned se…
Pierre-Graber Feb 16, 2023
4b0de3e
`bumb fastvrpy to 0.3.0 : add matrix_index and force_start
Pierre-Graber Mar 20, 2023
7129c97
fastvrpy : handles free_approach and free_return
Pierre-Graber Mar 22, 2023
267944a
refacto : services attributes, vehicles attributes + matrices creation
Pierre-Graber Mar 27, 2023
fc8bba4
fastvrpy : add rest managament to the wrapper + duration constraints …
Pierre-Graber Mar 30, 2023
76861c5
UI : Fastvrpy starts from existing route if it exists + fixes
Pierre-Graber Apr 6, 2023
c92123d
Add 'strict_skills' field to 'resolution' for strict skills management
Pierre-Graber Apr 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add KS to check if we can solve the problem with fastvrpy + test it
  • Loading branch information
Pierre-Graber committed Feb 9, 2023
commit f0ed05cfa6e8a52c668afc50268148f47bff76b4
94 changes: 94 additions & 0 deletions unconstrained-initialization/knowledge_sources/check_resolution.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#base imports
from knowledge_sources.abstract_knowledge_source import AbstractKnowledgeSource
import logging as log
log = log.getLogger(__file__)

#KS imports
import numpy
from marshmallow import fields, validate
from schema import Schema, And, Use, Optional, SchemaError, Or

class CheckResolution(AbstractKnowledgeSource):
"""
Create all services attributes from problem
"""

def verify(self):

problem = self.blackboard.problem

if self.blackboard.problem is None:
raise AttributeError("Problem is None, not possible to check if the possible")

if not isinstance(self.blackboard.problem, dict):
raise AttributeError("Problem is not of type dict, not possible to create the dictionnary")

if "relations" in problem :
for relation in problem["relations"]:
if relation["type"] in ["order", "sequence"]:
raise NotImplementedError("This algorithm can't handle with sequence or order relations")
if relation["type"] in ["never_first", "never_last", "always_first", "always_last"]:
raise NotImplementedError("Can't handle positions for services")


for vehicle in problem["vehicles"]:
if "shiftPreference" in vehicle:
if vehicle["shiftPreference"] in ["force_start", "force_end"]:
raise NotImplementedError("This algorithm can't handle with vehicles shift_preferences for now")

for service in problem["services"]:
if "activity" in service:
if "position" in service["activity"]:
if service["activity"]["position"] in ["always_first", "always_last", "never_first"]:
raise NotImplementedError("This algorithm can't handle with services positions for now")
elif "activities" in service:
for activity in service["activities"]:
if activity["positions"] in ["always_first", "always_last", "never_first"]:
raise NotImplementedError("This algorithm can't handle with services positions for now")





problem_schema = Schema(
{
"matrices" : [{
"time":[Or(float, int)],
"distance":[Or(float, int)]
}],
"vehicles" : [{
'endIndex': int,
'startIndex': int,
'matrixIndex': int
}],
"services" :
[
{
'matrixIndex':int,
'id' : str,
Optional('priority'):int,
Optional("activity") :{
'timeWindows':Or([{
"start": Or(int,float),
"end": Or(int,float),
"maximumLateness": Or(int, float)
}],[])},
Optional("activities"):
[{
'timeWindows':Or([{
"start": Or(int,float),
"end": Or(int,float),
"maximumLateness": Or(int, float)
}],[])
}]
}
]
},
ignore_extra_keys=True
)
problem_schema.validate(self.blackboard.problem)

return True

def process(self):
return None
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
from unittest.mock import Mock, patch
import pytest
import copy
from schema import Schema, And, Use, Optional, SchemaError, Or
import pdb

from knowledge_sources.check_resolution import CheckResolution


problem_missing_keys = { "services": [
{'id': "service_1"},
{'id': "service_2"},
{'id': "service_3"},
],
"vehicles": [

],
"matrices":[]
}

problem = { "services": [
{
'id': "service_1",
'matrixIndex': 0,

},
{
'id': "service_2",
'matrixIndex': 1,

}
],
"vehicles": [
{
"matrixIndex": 0,
"endIndex": 0,
"startIndex": 0,
}
],
"matrices": [
{
"time": [0,1,1,0],
"distance": [0,1,1,0]
}
]
}

def test_order_relation():
blackboard = Mock(problem = copy.deepcopy(problem))
knowledge_source = CheckResolution(blackboard)
blackboard.problem["relations"] = [
{
"type" : "order",
"linked_ids" : ["1","2"]
}
]

with pytest.raises(NotImplementedError):
knowledge_source.verify()

def test_sequence_relation():
blackboard = Mock(problem = copy.deepcopy(problem))
knowledge_source = CheckResolution(blackboard)
blackboard.problem["relations"] = [
{
"type" : "sequence",
"linked_ids" : ["1","2"]
}
]

with pytest.raises(NotImplementedError):
knowledge_source.verify()

def test_always_last_position():
blackboard = Mock(problem = copy.deepcopy(problem))
knowledge_source = CheckResolution(blackboard)
activity = {
"position": "always_last"
}
blackboard.problem["services"][0]["activity"] = activity

with pytest.raises(NotImplementedError):
knowledge_source.verify()

def test_always_first_position():
blackboard = Mock(problem = copy.deepcopy(problem))
knowledge_source = CheckResolution(blackboard)
activity = {
"position": "always_first"
}
blackboard.problem["services"][0]["activity"] = activity

with pytest.raises(NotImplementedError):
knowledge_source.verify()

def test_missing_keys():
blackboard = Mock(problem = problem_missing_keys)
knowledge_source = CheckResolution(blackboard)

with pytest.raises(SchemaError):
knowledge_source.verify()

def test_ok_for_resolution():
blackboard = Mock(problem = problem)
knowledge_source = CheckResolution(blackboard)

assert knowledge_source.verify()