Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
en:dydaktyka:csp:intro [2019/02/27 22:19]
msl [Polishing rough edges]
en:dydaktyka:csp:intro [2020/10/06 21:33]
ligeza [Solving the Progblem]
Line 7: Line 7:
   * [optional] define optimality criteria, e.g. cost function, which has to be minimized; ​   * [optional] define optimality criteria, e.g. cost function, which has to be minimized; ​
   * [optional] define the search procedure which will be used to find the solution. ​   * [optional] define the search procedure which will be used to find the solution. ​
 +
 +All files required to solve the assignments are available via [[https://​gitlab.com/​agh-krr/​2019-2020/​labs|the repository]],​ so clone it first and follow the Readme instructions.
  
 ===== "Real Life" Example =====  ===== "Real Life" Example ===== 
Line 21: Line 23:
   - Run MiniZinc IDE   - Run MiniZinc IDE
  
-===== Solving the Progblem ​=====+===== Solving the Problem ​=====
  
 Modelling problem in MiniZinc consists of four steps: Modelling problem in MiniZinc consists of four steps:
Line 80: Line 82:
 The simplest way: ''​MiniZincIDE -> Menu -> Minizinc -> Run''​. The simplest way: ''​MiniZincIDE -> Menu -> Minizinc -> Run''​.
  
-To receive more than one solution, check the ''​Configuration'' ​tab, check the ''​User-defined behavior''​ checkbox and select ''​Print all solutions''​. +To receive more than one solution, check the ''​Show configuration editor'' ​button in the right top corner, check the ''​User-defined behavior''​ checkbox and select ''​Print all solutions''​. 
- +X===== Tip 50% =====
-===== Tip 50% =====+
  
 The comic strip claims, that we will receive a tip only if we manage to create a general solution. We like tips, so let's get to work! The comic strip claims, that we will receive a tip only if we manage to create a general solution. We like tips, so let's get to work!
Line 95: Line 96:
 Then, what is the required price of the order: Then, what is the required price of the order:
  
-<​code>​ +<​code>​int:​ money_limit = 1505;
-int: money_limit = 1505;+
 </​code>​ </​code>​
  
Line 129: Line 129:
 === 5. Fifth Step: Output === === 5. Fifth Step: Output ===
  
-Again we will use array comprehension. The '​++' ​operator concatenates strings, while the ''​show''​ function converts number to a string.+Again we will use array comprehension. The double-plus ​operator concatenates strings, while the ''​show''​ function converts number to a string.
  
 <​code>​ <​code>​
Line 174: Line 174:
  
 Now we should have a basic working model for the problem at hand, but there are still few ways to improve it. Now we should have a basic working model for the problem at hand, but there are still few ways to improve it.
 +Also this is a good moment to play with the MiniZinc compiler --- how to debug and find faults in the model.
  
 === Assignments === === Assignments ===
Line 187: Line 188:
       * ''<​test>''​ is something like ''​x < 3''​       * ''<​test>''​ is something like ''​x < 3''​
       * ''<​expression>''​ may be a constraint or anything that returns a value       * ''<​expression>''​ may be a constraint or anything that returns a value
-      * you can use ''​++'' ​and ''​show''​ to build more complicated messages+      * you can use double-plus ​and ''​show''​ to build more complicated messages
   - Ranges, e.g. ''​1..menu_length''​ are special cases of ''​sets''​. Replace all the ranges with named sets to avoid code duplication. The declaration should like this: <​code>​   - Ranges, e.g. ''​1..menu_length''​ are special cases of ''​sets''​. Replace all the ranges with named sets to avoid code duplication. The declaration should like this: <​code>​
 set of <​type>:​ SetName = start..end; set of <​type>:​ SetName = start..end;
 </​code>​ </​code>​
 +  - ''​Show configuration editor''​ is a very tempting button in the right top corner of the MiniZincIDE. Play with the options:
 +    * Check verbose output of the solver.
 +    * Try using the ''​Gecode-gist''​solver. It should display a search tree. Do you understand what does it show?
 +    * Experiment :)
en/dydaktyka/csp/intro.txt · Last modified: 2020/10/06 21:33 by ligeza
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0