Parcourir la source

pre build command

Jérôme BUISINE il y a 3 ans
Parent
commit
8b94dce1d8

+ 4 - 3
.github/workflows/docs.yml

@@ -12,11 +12,12 @@ jobs:
     steps:
     - uses: actions/checkout@v1
     # Standard drop-in approach that should work for most people.
-    - name: Download sphinx theme
-      run: pip3 install asteroid-sphinx-theme
     - uses: ammaraskar/sphinx-action@master
       with:
-        docs-folder: "docs/"
+      with:
+        pre-build-command: "pip install asteroid-sphinx-theme"
+        build-command: "make html"
+        docs-folder: "docs"
     # Publish built docs to gh-pages branch.
     # ===============================
     - name: Commit documentation changes

+ 2 - 1
docs/source/documentations/index.rst

@@ -15,4 +15,5 @@ It will gradually take up the major ideas developed within `Macop` to allow for
 
    introduction
    problem
-   solutions
+   solutions
+   validator

+ 1 - 1
docs/source/documentations/problem.rst

@@ -40,7 +40,7 @@ Hence, we now define our problem in Python:
 .. code-block:: python
     
     """
-    Problem definition
+    Problem instance definition
     """
 
     elements_score = [ 4, 2, 10, 1, 2 ] # value of each object

+ 1 - 7
docs/source/documentations/solutions.rst

@@ -133,10 +133,4 @@ Using this new Solution representation, we can now generate solution randomly:
 
     solution = BinarySolution.random(5)
 
-
-3.3. Validate a solution
-~~~~~~~~~~~~~~~~~~~~~~~~~
-
-When an optimization problem requires respecting certain constraints, Macop allows you to quickly verify that a solution is valid. 
-It is based on a defined function taking a solution as input and returning the validity criterion (true or false).
-
+In the next part, we will see how to verify that a solution meets certain modeling constraints of the problem.

+ 35 - 0
docs/source/documentations/validator.rst

@@ -0,0 +1,35 @@
+4. Validate a solution
+======================
+
+When an optimization problem requires respecting certain constraints, Macop allows you to quickly verify that a solution is valid. 
+It is based on a defined function taking a solution as input and returning the validity criterion (true or false).
+
+4.1. Validator definition
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+
+.. code-block:: python
+
+    """
+    Problem instance definition
+    """
+
+    elements_score = [ 4, 2, 10, 1, 2 ] # value of each object
+    elements_weight = [ 12, 1, 4, 1, 2 ] # weight of each object
+
+    """
+    validator function definition
+    """
+    def validator(solution):
+
+        weight_sum = 0
+
+        for i, w in enumerate(elements_weight):
+            weight_sum += w * solution._data[i]
+        
+        return weight_sum <= 15
+
+
+4.2. Use of validator
+~~~~~~~~~~~~~~~~~~~~~