Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7751171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:28:46+00:00 2026-06-01T11:28:46+00:00

I am writing a multi-agent system in 2APL. In my agent file, I have

  • 0

I am writing a multi-agent system in 2APL. In my agent file, I have the following call in a PC-rules function:

B(zoekBod(Location,Destination,Amount,PriceCorrection,PrevOrders,Price));

In a beliefs file, I have defined this prolog function as follows:

  zoekBod(Afz, Best, Aant, PC, [], Bod) :-
    Max is abs(Best-Afz)*Aant*PC,
    random( 1, Max, Bod ).

  zoekBod(Afz, Best, Aant, PC, [opdracht(_,Aantal,Afzender,Bestemming,Prijs)|_], Bod) :-
    OudeMaat=abs(Bestemming-Afzender)*Aantal,
    Maat=abs(Best-Afz)*Aant,
    0.75=<(Maat/OudeMaat),
    (Maat/OudeMaat)=<1.33,
    Bod=PC*Prijs.

  zoekBod(Afz, Best, Aant, PC, [opdracht(_,Aantal,Afzender,Bestemming,_)|R], Bod) :-
    OudeMaat=abs(Bestemming-Afzender)*Aantal,
    Maat=abs(Best-Afz)*Aant,
    (0.75>(Maat/OudeMaat); (Maat/OudeMaat)>1.33),
    zoekBod(Afz, Best, Aant, PC, [R], Bod).

It’s in Dutch, but essentially the goal is that based on any previous orders, it calculates a price for the new order. When this belief is tested in 2APL, it gives me an error:

[STEP: Execute all plans]
Failed to execute:
B(zoekBod(1, 3, 15, 1, [], Prijs))

If I test it in gprolog with trace on, I get this result:

| ?- zoekBod(1,3,15,1,[],Prijs).
      1    1  Call: zoekBod(1,3,15,1,[],_17) ? 
      2    2  Call: _101 is abs(3-1)*15*1 ? 
      2    2  Exit: 30 is abs(3-1)*15*1 ? 
      3    2  Call: random(1,30,_17) ? 
      3    2  Exit: random(1,30,25) ? 
      1    1  Exit: zoekBod(1,3,15,1,[],25) ? 

Prijs = 25 ? 

(2 ms) yes
{trace}
| ?- 

Which is exactly as intended. My relevant mas section looks like this:

<agent name="v1" file="vervoerder_voorbeeld.2apl">
      <beliefs file="vervoerderext_voorbeeld.pl" shadow="true"/>
</agent>

I am completely stumped why it fails to execute. Could anyone help me out a bit here? Thanks in advance!

Sorry, found the answer:

zoekBod(Afz, Best, Aant, PC, [], Bod) :-
Max is abs(Best-Afz)*Aant*PC,
random( 1, Max, Bod ).

should be:

zoekBod(Afz, Best, Aant, PC, [], Bod) :-
Max is abs(Best-Afz)*Aant*PC,
Bod is int(random(Max)+0.5).
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T11:28:48+00:00Added an answer on June 1, 2026 at 11:28 am

    Sorry, found the answer:

    zoekBod(Afz, Best, Aant, PC, [], Bod) :-
    Max is abs(Best-Afz)*Aant*PC,
    random( 1, Max, Bod ).

    should be:

    zoekBod(Afz, Best, Aant, PC, [], Bod) :-
    Max is abs(Best-Afz)*Aant*PC,
    Bod is int(random(Max)+0.5).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a multi-project ASP.NET + C# solution. I was planning on writing a
I am writing a multi threaded application and I have concerns with 2 threads
I have writing a multi threaded code. I am not sure, whether I would
In a multi-threaded program I'm writing a custom print function which accepts a variable
I am writing a new authorization system and permission system for my multi tenant
We have a large, multi-module product we are writing in Flex 4.1 running on
If you are writing a multi-threaded application that uses system/library calls that make use
I'm writing a multi-threaded Java web crawler. From what I understand of the web,
I've been writing a multi-threaded DLL for database access using ADO/ODBC for use with
I am on MacOSX. I am writing a multi threaded program. One thread does

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.