[gecode-users] How do you debug your progam?

Roberto Pinto librarama at gmail.com
Thu Jul 27 18:38:57 CEST 2006


Dear all,

I'm not referring to the C++ code, but to the set of constraint that
describe your problem:
I don't know if my question will be relevant for most of you, anyway,
I would ask how do you debug your constraint program?

Of course, from a theoretical point of view, thinking before doing is
a best-practice, but a bug could always occur and maybe you are not
able to find it even after a deep analysis.

In my case, I have e (theoretically) really simple involving two
cumulatives constraints (just a bunch of code hereafter):

[...]

for(int i = 0; i < NUM_JOB; i++)
		{
		post(this, e_1[i] <= s_2[i], opt.icl);  //second stage starts after
the end of the first
		post(this, e_2[i] <= duedates[i], opt.icl); //meet the due-date
		}

	cumulatives(this, m_1, s_1, duration, e_1, requirements,  limit, true);
              //cumulative constraint on the first stage machines
	cumulatives(this, m_2, s_2, duration, e_2, requirements,  limit, true);
              //cumulative constraint on the first stage machines
[...]

I think it is clear enough: it is just a job-shop scheduling problem
with assigned due-date.
If I fix the routing (that is, if I assign the machine variables m_1
and m_2 to each job) the solution is immediate.
With flexible routing (that is, the machines are not assigned a
priori), even in little cases (5 job, 2 machines in each stage) the
solver goes around without converging to any solution.

Any idea where to look?

I would also ask if it is somewhat possible to "follow" the variable
assignment procedure step-by-step (of course, on very simple example
with few variables) in order to "visualize" the propagation of
constraints and the backtracking points.

In other words, I would like to print out all the variable assignment,
one by one, along with a message saying "Hey, I'm backtracking now!"
or something like that.
Why that? because this is the only way I know to understand where my
simple programs stuck into.
Maybe, I mistakenly posted a constraint and I'm not aware of that, but
following the evolution of the assignment could be possible to
highlight the  problem.

Do you think it would be possible (easily) with Gecode?
Or better, you could give me more clever hints in ordet to debug my programs.

TIA
Roberto




More information about the gecode-users mailing list