![]() |
'Clingo' sounds like 'Klingon'. Klingons remind me of space. So I made this digital painting of Europa, lol. |
What is Clingo?
Clingo is a simple and powerful Answer Set Programming (ASP) language.
Clingo takes a logic program and computes answer sets that represent solutions to a given problem.
It’s part of the Potassco project for ASP.
Check out the Potassco GitHub page for more info.
It's used in university logic classes, such as ASU's CSE 259
How do I get Clingo?
Glad you asked!
1. Download Clingo
You can find the latest versions on their GitHub download page.
(Here’s a direct link to Clingo 5.3.0 for Windows though: clingo-5.3.0-win64.zip)
If the version is newer, I would recommend using the latest stable version from
their GitHub page. If
your professor recommends a specific version, scroll down on the page and it
should be there!
2. Extract Clingo
Navigate to your Downloads folder (or wherever you downloaded the file to) and
find the file you just downloaded.
Right click on the file and click Extract All... to extract it.
A folder should appear in your downloads folder called clingo-5.3.0-win64.
(Sometimes there’s a folder in that folder containing the files)
Open the folder and you'll find something like this:
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhotc_3RQ_0WEAOT8zWV6fFx0hJd-XeeT2L9Wg28TuYB0V7wL4Cf5ODlQvr1Fn5rVgVuH7zrw0pcSuGyDyUtxmVwidwxUimvUt2qo4S2hxXhBZyjiuw-WnS49eyv4ZCULi3KOcuA0Rd0il_/s640/pic4.png)
Awesome, now you have Clingo, let’s set it up.
3. Move Clingo to a more permanent location.
I recommend moving Clingo to your root directory for ease of
access.
To do so, open up a file explorer window and
click This PC on the left panel.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrkaXRg2kAI2QvOghdCVYoEnp75D8Jp2oNx2vKwZ-PBic94ur3R0mCoQFF_81TJ7CWam998yJd7WWfjlGDDuiOyKIgruPWmZ05xT7gvOVIUc_sTQJEfy_HNQCPTlWpMtKA7sUj827L_N-5/s320/pic5.png)
Then select your
primary hard drive, (Your C: drive, unless you've changed it)
Make a new folder
there called Clingo and copy the contents of the folder you extracted
earlier into it.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAW_gg1-JqGSWGmJMeqlKGxtbTppYWd_0HY4ViDfxGIHX_5A1Zbw7DwnpDhO7XMHptxRKhtlRlMGyeKBtBgqD2o-BwGWzFIdCT1tdH44XMSE6jFabiXkdLW9SLZWSVKm1Tw7mwd3zCmKtu/s640/pic7.png)
Yay.
4. Add Clingo to your Windows Path.
Adding Clingo to your windows path allows you to call Cingo
from any directory in the Command Prompt or PowerShell
First, search Advanced System Settings in Windows search
and click the first result.
A new window should pop up called System Properties.
In that window, click Environment Variables on the bottom
right.
Another window should pop up called Environment Variables.
Now click on the line
with the variable name Path on the top section of the window containing User variables,
then click the Edit button under the top section.
Another window should appear called Edit environment
variable.
Click New on the top right of this window.
Type in C:\clingo where the cursor appears, then
click Enter.
Then click OK on the Edit environment variable window.
Then OK again on the Environment Variables window.
Then click OK yet again in the System Properties
window.
There ya go!
5. Test Clingo
Open up a Command Prompt window by searching Command
Prompt in Windows search and selecting the first option.
Type Clingo and click enter in the command prompt
window.
You should see something like this:
Seeing the version number means Clingo was successfully added to your path! Yee Haw.
Using Clingo
Clingo is pretty simple to use, so I'll make it fast.
- Save the Clingo program file you would like in any directory.
- Open that directory in a File Explorer window.
- While holding the Shift key, right click in the folder where your program is saved.
- In the drop down menu, you should see the Open in PowerShell, click on it. A PowerShell window should pop up. (Powershell is a lot like Command Prompt, just more blue)
- In the PowerShell window type clingo and then the file name and extension of the clingo program you would like to run then click Enter.
Here's an example:
clingo test.lp
If you'd like to see all the models, add a 0 on the end of the command
clingo test.lp 0
There ya go!
As always, any comments, suggestions, or questions are greatly appreciated!
Leave a comment, or message me on twitter 🚀
Thank you very much!
ReplyDelete