๐ฌ Help#
Logging
The first thing to try when things are not working as expected is to turn on the logs and inspect the console.
The log level can be set to DEBUG
in the command line by adding the flag --server-log-level DEBUG
.
These logs will show the communication between the client and the server, as well as every call made to the Clingo API internally.
Information regarding the domain-control will be logged in magenta, and information regarding the ui-control will be logged in cyan.
These logs will also show the atoms that are part of the domain-state which are passed to your UI encoding.
Unexpected atoms in brave/cautious consequences
If you inspect the logs and the domain-state does not have the expected atoms in your brave _any
or cautious _all
consequences,
make sure your domain-files donโt have any #show
statements.
The show statements in your domain-files will impact the atoms present in the domain-state.
If you are using show statements and want to use _any(a)
for an atom a
that is not part of your show statements,
you need to add #project a.
to your domain-files to get the desired output.
Furthermore, any show statements that output a tuple (function without name) will lead to syntactic issues, so they should be removed.
Exception: Could not parse โฆ
If you get an exception Exception: Could not parse ...
, this is likely due to using uppercase names as arguments to an operation which in Clingo is a variable.
If the arguments come from text that was user input, ensure it is transformed into a string when using _context_value.
See the Context section for details.
Example
Using the following code ensures that the input saved in name
is transformed into a string.
If the input is Ana
, the operation becomes: add_assumption("Ana",true)
instead of add_assumption(Ana,true)
.
when(b1, click, call, add_assumption(_context_value(name, str)), true).
Unsure how to use a feature
If you are unsure how to use a feature, you can check the ๐ก Examples section for inspiration. You can also use the search bar to see which examples use the feature you are interested in.
Long response time
If the server is taking too long to respond, first check the logs to make sure the server has not crashed and is still processing the request.
With the DEBUG
log level, you can see the last call that was made to the Clingo API.
- Brave or cautious consequences
If the call is to compute the brave or cautious consequences, the problem might be that your encoding has a very large search space. If possible, avoid using
all
orany
in your UI encoding. This way, these calls will be skipped (similarly forall_opt
andany_opt
).- Optimizing
If the problem is finding an optimal model, you can pass a timeout to the server in the command line with the flag
--out-timeout 10
. This will make the server stop searching for models with a better cost after10
seconds. Note that the response time might be longer than this timeout if the solver is already searching when the timeout is reached. If you pass a timeout of0
, the server will only get the first model; you can then keep calling the operationnext_solution(optN)
to improve the cost, one at a time. Check out the placement example.
Canโt manage to place or style things in my UI
If you are having trouble placing or styling elements in your UI, first make sure that they are part of your UI state by checking the logs in the command line.
- Not in my ui-state
If your expected attribute is not in the ui-state, then you need to check your ui-files to make sure the atom is generated. If you are using the
;
operator for theclass
attribute, make sure you did not make a mistake and haveattr(elem,class,(c1,c2);
instead ofattr(elem,class,(c1;c2).
.- Is part of my ui-state
Then we recommend you use the browserโs developer tools to inspect the elements and see if the styles are being applied. You can also move the HTML directly in your browser to find the right settings. Once you find them, you can copy them to your ui-files. We recommend taking a look at bootstrap flex for the classes you can use for flexible alignments.
You can also add a border to all of your containers to see where they are placed, and then remove them once you have the right settings. To do so, just add the following line to your UI encoding:
attr(E,class,("border-1";"border";"border-dark")):- elem(E, container, _).
Try the cache
If you are still having trouble or your browser does not seem to be sending the requests properly, you can try clearing the cache. There is usually an option in the browser to clear the cache that might help solve the problem.
Still need help
If none of the above tips help you solve your problem, please open an issue in the Clinguin repository.