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
Create matrices tests and add problem schema validation
  • Loading branch information
guillaumemaranwoop committed Jan 6, 2023
commit b2446e57b69b60fb2797b47623d3b0c66c23e0bf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#KS imports
import math
import numpy

from schema import Use, Const, And, Schema, Or

class CreateMatricesFromProblem(AbstractKnowledgeSource):
"""
Expand All @@ -21,6 +21,27 @@ def verify(self):
if not isinstance(self.blackboard.problem, dict):
raise AttributeError("Problem is not of type dict, not possible to create matrices")


problem_schema = Schema(
{
"matrices" : [{
"time":[[Or(float, int)]],
"distance":[[Or(float, int)]]
}],
"vehicles" : [{
'endIndex': int,
'startIndex': int,
}],
"services" : [
{
'matrixIndex':int,
}
]
},
ignore_extra_keys=True
)
problem_schema.validate(self.blackboard.problem)

return True

def process(self):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
from unittest.mock import Mock, patch
import pytest

from knowledge_sources.create_matrices_from_problem import CreateMatricesFromProblem
import schema
import numpy

@pytest.mark.parametrize("problem", [None, "Coucou"])
def test_verify_problem_error(problem):
blackboard = Mock(problem = problem)
knowledge_source = CreateMatricesFromProblem(blackboard)

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


def test_verify_problem_missing_keys():
blackboard = Mock(problem = {})
knowledge_source = CreateMatricesFromProblem(blackboard)

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


problem = {
"matrices" : [{
"time":[[1,2,3],[4,5,6],[7,8,9]],
"distance":[[1,2,3],[4,5,6],[7,8,9]]
}],
"vehicles" : [{
'endIndex': 0,
'startIndex': 0,
},
{
'endIndex': 0,
'startIndex': 0,
}],
"services" : [
{
'matrixIndex':0,
},
{
'matrixIndex':0,
}
]
}

def test_verify_problem_ok():
blackboard = Mock(problem = problem)
knowledge_source = CreateMatricesFromProblem(blackboard)

assert knowledge_source.verify() == True


def test_process():
blackboard = Mock(problem = problem)
knowledge_source = CreateMatricesFromProblem(blackboard)

knowledge_source.process()
print(blackboard.distance_matrices)

print(blackboard.time_matrices)
assert (blackboard.distance_matrices == numpy.array([[[1,2,3],[4,5,6],[7,8,9]]], dtype=numpy.float64)).all()
assert (blackboard.time_matrices == numpy.array([[[1,2,3],[4,5,6],[7,8,9]]], dtype=numpy.float64)).all()