Writing Solutions to Constraint Program to a File

Torsten Anders torstenanders at gmx.de
Fri Apr 6 19:43:04 CEST 2007


Here you are. Select the corresponding action 'Output to file' from 
Explorer menu Nodes -> 'Information Action'. Then just 
mouse-doubleclick on the solution.

Best,
Torsten

proc {WriteToFile Output Path}
    File = {New Open.file
	   init(name: Path
		flags: [write create truncate]
		mode: mode(owner: [read write]
			   group: [read write]))}
in
    {System.showInfo "writing to "#Path}
    {File write(vs:Output)}
    {File close}
end
proc {OutputFile I X}
    {WriteToFile {Value.toVirtualString X 1000 1000}
     {Tk.return tk_getSaveFile}}
end
{Explorer.object
  add(information OutputFile
      label: 'Output to file')}

%% demo CSP
{ExploreOne
  proc {$ Solution}
     X = {FD.int 1#10}
     Y = {FD.int 1#10}
     Z = {FD.int 1#10}
  in
     Solution = [X Y Z]
     X + Y =: Z
     X <: Y
     %% search strategy
     {FD.distribute ff Solution}
  end}

On 05.04.2007, at 21:09, George Rudolph wrote:
> Torsten,
>  
> After reading Section 6 of the Oz online documentation,
> I still cannot figure out how to trigger writing solutions >from a 
> constraint program
> (so flow of control is not sequential, nor imperative) out to a file. 
>  
> I can open a file at the beginning of my program, and close it at the 
> end,  but I don’t
> understand how to tell the Explorer to write green diamonds 
> (solutions) out to a file.
>  
> Could you send me an example of something you have done that works?
>  
> --------------------
> George Rudolph
> Assistant Professor
> Thompson Hall 225
> Math & Computer Science Dept.
> The Citadel
> 171 Moultrie St.
> Charleston, SC 29414
>  
>
--
Torsten Anders
Sonic Arts Research Centre • Queen's University Belfast
Frankstr. 49 • D-50996 Köln
Tel: +49-221-3980750
http://strasheela.sourceforge.net
http://www.torsten-anders.de


--
Torsten Anders
Sonic Arts Research Centre • Queen's University Belfast
Frankstr. 49 • D-50996 Köln
Tel: +49-221-3980750
http://strasheela.sourceforge.net
http://www.torsten-anders.de



More information about the mozart-users mailing list