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 7494785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T17:46:41+00:00 2026-05-29T17:46:41+00:00

I am trying to solve a specific problem using prologs constraint solvers, and I’m

  • 0

I am trying to solve a specific problem using prologs constraint solvers, and I’m stuck 😀
A more general version of my problem requirement is the like this:

:- lib(ic).:- lib(ic).
solve( [A1*X+B1*Y=C1, A2*X+B2*Y=C2] ):-
X::[0..999],
Y::[0..999],
X #\= 0,
Y #\= 0,

A1*X+B1*Y#=C1, % line1
A2*X+B2*Y#=C2. % line2

And this is the query/goal I use:

solve( [2*X+3*Y=5, 3*X+2*Y=5] ).

And the program will compute the values of X and Y (in this case X=1, Y=1 is the solution).
What I am thinking is, what if the number of arguments in the goal/query can vary..in this case, my prolog program needs to have a dynamic suspended goals in place of lines commented with %line1 and %line2..

Question is, how do i make these expressions delayed..? I do not want to hard code these in the problem and think that only two expressions will be passed over through the goal..

Hope the question is clear.
Thanks.

  • 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-05-29T17:46:42+00:00Added an answer on May 29, 2026 at 5:46 pm

    I think you mean something like:

    :- lib(ic).
    
    solve([]).
    solve([Eq | Eqs]) :-
            term_variables(Eq, Vars),
            Vars :: [0..999],
            ( foreach(Var, Vars) do Var #\= 0 ),
            Eq  = (Lhs  = Rhs),
            Eq0 = (Lhs #= Rhs),
            call(Eq0),
            solve(Eqs).
    

    Note that this is ECLiPSe-CLP specific code (the foreach-loop which could be translated to a recursive helper predicate, of course, and the IC library).

    Also note that call(Eq0) and writing just Lhs #= Rhs should have the same effect (afaik). But when the variables in Lhs #= Rhs are solver variables, that seems not to the case, at least I encountered such a problem some months ago using lib(cplex).

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

Sidebar

Related Questions

Trying to solve this problem . I would like to learn how the bootstrapper
This is more out of personal curiosity/interest than a specific problem I'm trying to
I found problem when trying to retrieve specific name column that using syntax/statement/command using
Trying to solve a problem with templatetags. I have two templatetags: @register.inclusion_tag('directory/_alphabet.html') def alphabet_list(names):
In trying to solve the ajax back button problem I have found the Really
Am trying to solve a labyrinth by DFS, using adj List to represent the
I'm trying to solve the 3n+1 problem and I have a for loop that
I was trying to solve my XNA Font problem , when I found this
I'm trying to solve this flickering problem on the iphone (open gl es game).
I'm trying to solve the problem of passing a 2-dimensional table into JavaScript AJAX

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.