<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Log Opt Blog</title>
	<atom:link href="http://www.logopt.com/wp_blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.logopt.com/wp_blog</link>
	<description>Log Opt Research Memo and News</description>
	<lastBuildDate>Tue, 05 Jul 2011 05:49:41 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.5</generator>
		<item>
		<title>SCOP 5th Example: traveling salesman problem</title>
		<link>http://www.logopt.com/wp_blog/?p=341</link>
		<comments>http://www.logopt.com/wp_blog/?p=341#comments</comments>
		<pubDate>Tue, 05 Jul 2011 05:48:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[SCOP]]></category>

		<guid isPermaLink="false">http://www.logopt.com/wp_blog/?p=341</guid>
		<description><![CDATA[SCOP is a constrained programming solver. In the example we call SCOP from Python language. In the graph the number is the distances between locations and the green line is the optimal solution. The problem is to find a shortest &#8230; <a href="http://www.logopt.com/wp_blog/?p=341">続きを読む <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>SCOP is a constrained programming solver.<br />
In the example we call SCOP from Python language.</p>
<p><a href="http://www.logopt.com/wp_blog/wp-content/uploads/2011/07/travelling-sailesman.jpg"><img src="http://www.logopt.com/wp_blog/wp-content/uploads/2011/07/travelling-sailesman-300x218.jpg" alt="" title="travelling sailesman" width="300" height="218" class="aligncenter size-medium wp-image-342" /></a></p>
<p>In the graph the number is the distances between locations and the green line is the optimal solution.</p>
<p>The problem is to find a shortest possible tour that visits each location exactly once.                     </p>
<p>The Python code can be written as follows:<br />
************************************<br />
<code>"""<br />
tsp-scop.py:<br />
Using SCOP for solving the traveling salesman problem<br />
Copyright (c) by Joao Pedro PEDROSO and Mikio KUBO, 2011<br />
"""</code></p>
<p><code>from scop2 import *<br />
m=Model()</code></p>
<p><code>cities=["T","L","M","R","B"]<br />
d=[[0,476,774,434,408],[476,0,784,894,569],[774,784,0,852,1154],[434,894,852,0,569],[408,569,1154,569,0]]<br />
n=len(cities)</p>
<p>varlist=m.addVariables(cities,range(n))</p>
<p>con1=Alldiff("AD",varlist,"inf")<br />
m.addConstraint(con1)</code></p>
<p><code>obj=Quadratic("obj")<br />
for i in range(n):<br />
    <code style="padding-left: 30px;">for j in range(n):<br />
        <code style="padding-left: 60px;">if i!=j:<br />
            <code style="padding-left: 90px;">for k in range(n):<br />
                <code style="padding-left: 120px;">if k ==n-1:<br />
                    <code style="padding-left: 150px;">ell=0<br />
                <code style="padding-left: 120px;">else:<br />
                    <code style="padding-left: 150px;">ell=k+1<br />
                <code style="padding-left: 120px;">obj.addTerms(d[i][j],varlist[i],k,varlist[j],ell)<br />
m.addConstraint(obj)</code></p>
<p><code>m.Params.TimeLimit=1<br />
sol,violated=m.optimize()</code></p>
<p><code>print "solution"<br />
for x in sol:<br />
    <code style="padding-left: 30px;">print x,sol[x]<br />
print "violated constraint(s)"<br />
for v in violated:<br />
    <code style="padding-left: 30px;">print v,violated[v]</code><br />
************************************</p>
<p>We get the following result:<br />
************************************<br />
<code>##solution<br />
##B  2<br />
##R  0<br />
##M  4<br />
##T  1<br />
##L  3<br />
##violated constraint(s)<br />
##obj  3047</code><br />
************************************</p>
]]></content:encoded>
			<wfw:commentRss>http://www.logopt.com/wp_blog/?feed=rss2&#038;p=341</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SCOP 4th Example: quadratic assignment problem</title>
		<link>http://www.logopt.com/wp_blog/?p=331</link>
		<comments>http://www.logopt.com/wp_blog/?p=331#comments</comments>
		<pubDate>Mon, 04 Jul 2011 09:12:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[SCOP]]></category>

		<guid isPermaLink="false">http://www.logopt.com/wp_blog/?p=331</guid>
		<description><![CDATA[SCOP is a constrained programming solver. In the example we call SCOP from Python language. graph (A) is the flow between facilities. graph (B) is the distances of locations. The problem is to assign all facilities to different locations with &#8230; <a href="http://www.logopt.com/wp_blog/?p=331">続きを読む <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>SCOP is a constrained programming solver.<br />
In the example we call SCOP from Python language.</p>
<p><a href="http://www.logopt.com/wp_blog/wp-content/uploads/2011/07/quadratic3.jpg"><img src="http://www.logopt.com/wp_blog/wp-content/uploads/2011/07/quadratic3-1024x415.jpg" alt="" title="quadratic" width="640" height="259" class="aligncenter size-large wp-image-337" /></a></p>
<p>graph (A) is the flow between facilities.<br />
graph (B) is the distances of locations.</p>
<p>The problem is to assign all facilities to different locations with the goal of minimizing the sum of the distances multiplied by the corresponding flows.</p>
<p>The Python code can be written as follows:<br />
************************************<br />
<code>"""<br />
Using SCOP for solving the quadratic assignment problem<br />
Copyright (c) by Joao Pedro PEDROSO and Mikio KUBO, 2011<br />
"""</code></p>
<p><code>from scop2 import *<br />
m=Model()</code></p>
<p><code>n=3<br />
d=[[0,2,3],[2,0,1],[3,1,0]]<br />
f=[[0,5,1],[5,0,2],[1,2,0]]<br />
nodes=["n"+str(i) for i in range(n)]</p>
<p>varlist=m.addVariables(nodes,range(n))</p>
<p>con1=Alldiff("AD",varlist,"inf")<br />
m.addConstraint(con1)</code></p>
<p><code>obj=Quadratic("obj")<br />
for i in range(n-1):<br />
    <code style="padding-left: 30px;">for j in range(i+1,n):<br />
        <code style="padding-left: 60px;">for k in range(n):<br />
            <code style="padding-left: 90px;">for ell in range(n):<br />
                <code style="padding-left: 120px;">if k !=ell:<br />
                    <code style="padding-left: 150px;">obj.addTerms(f[i][j]*d[k][ell],varlist[i],k,varlist[j],ell)<br />
m.addConstraint(obj)</code></p>
<p><code>m.Params.TimeLimit=1<br />
sol,violated=m.optimize()</code></p>
<p><code>print "solution"<br />
for x in sol:<br />
    <code style="padding-left: 30px;">print x,sol[x]<br />
print "violated constraint(s)"<br />
for v in violated:<br />
    <code style="padding-left: 30px;">print v,violated[v]</code><br />
************************************</p>
<p>We get the following result:<br />
************************************<br />
<code>##solution<br />
##n0  2<br />
##n1  1<br />
##n2  0<br />
##violated constraint(s)<br />
##obj  12</code><br />
************************************</p>
]]></content:encoded>
			<wfw:commentRss>http://www.logopt.com/wp_blog/?feed=rss2&#038;p=331</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OptSeq 5th Example: Resource Constrained Scheduling</title>
		<link>http://www.logopt.com/wp_blog/?p=326</link>
		<comments>http://www.logopt.com/wp_blog/?p=326#comments</comments>
		<pubDate>Mon, 20 Jun 2011 07:44:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[OptSeq]]></category>

		<guid isPermaLink="false">http://www.logopt.com/wp_blog/?p=326</guid>
		<description><![CDATA[Here, we introduce the 5th example of OptSeq Python module. Consider a 4-activity problem with a resource whose capacity is 2 units on day 1, 2, 4, 5, 6, and 1 unit on day 3. The processing times (durations) of &#8230; <a href="http://www.logopt.com/wp_blog/?p=326">続きを読む <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Here, we introduce the 5th example of OptSeq Python module.</p>
<p>Consider a 4-activity problem with a resource whose capacity is 2 units on day 1, 2, 4, 5, 6, and 1 unit on day 3.<br />
The processing times (durations) of the activities are kept in the dictionary<br />
 duration ={1:1,2:3,3:2,4:2}.<br />
Precedence constraints are give by:<br />
 Activity 1 -> Activity 2;<br />
 Activity 1 -> Activity 3;<br />
 Activity 2 -> Activity 4.<br />
Activity 1 requires 2 units of resource the first day.<br />
Activity 2 requires 2 units of resource the first day and 1 unit on other days.<br />
Activity 3 requires 1 unit of resource all the days.<br />
Activity 4 requires 1 unit of the resource the first day and 2 units on the second day.<br />
The objective is to find the maximum completion time (makespan).</p>
<p><a href="http://www.logopt.com/wp_blog/wp-content/uploads/2011/06/optseq-example5.jpg"><img src="http://www.logopt.com/wp_blog/wp-content/uploads/2011/06/optseq-example5-1024x433.jpg" alt="" title="optseq example5" width="640" height="270" class="aligncenter size-large wp-image-327" /></a></p>
<p>graph (A) is the problem.<br />
graph (B) is the solution.</p>
<p>Now the Python code can be written as follows:<br />
******************************************<br />
<code>from optseq2 import *</p>
<p>m1=Model()<br />
duration ={1:1,2:3,3:2,4:2}<br />
req={}<br />
req[1]={(0,1):2 }<br />
req[2]={(0,1):2 ,(1,3):1}<br />
req[3]={(0,2):1 }<br />
req[4]={(0,1):1,(1,2):2 }</p>
<p>res=m1.addResource("worker")<br />
res.addCapacity(0,2,2)<br />
res.addCapacity(2,3,1)<br />
res.addCapacity(3,"inf",2)</p>
<p>act={}<br />
mode={}</code></p>
<p><code>for i in duration:<br />
    <code style="padding-left: 30px;">act[i]=m1.addActivity("Act[%s]"%i)<br />
    <code style="padding-left: 30px;">mode[i]=Mode("Mode[%s]"%i,duration[i])<br />
    <code style="padding-left: 30px;">mode[i].addResource(res,req[i])<br />
    <code style="padding-left: 30px;">act[i].addModes(mode[i])</code></p>
<p><code>m1.addTemporal(act[1],act[2])<br />
m1.addTemporal(act[1],act[3])<br />
m1.addTemporal(act[2],act[4])</p>
<p>m1.Params.TimeLimit=1<br />
m1.Params.Makespan=True<br />
m1.Params.OutputFlag=True<br />
m1.optimize()</code><br />
******************************************</p>
<p>We get the following result:<br />
******************************************<br />
<code>##source --- 0 0<br />
##sink --- 6 6<br />
##Act[1] --- 0 1<br />
##Act[2] --- 1 4<br />
##Act[3] --- 3 5<br />
##Act[4] --- 4 6<br />
##planning horizon= 6</code><br />
******************************************</p>
]]></content:encoded>
			<wfw:commentRss>http://www.logopt.com/wp_blog/?feed=rss2&#038;p=326</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SCOP 3rd Example: graph coloring problem</title>
		<link>http://www.logopt.com/wp_blog/?p=298</link>
		<comments>http://www.logopt.com/wp_blog/?p=298#comments</comments>
		<pubDate>Thu, 02 Jun 2011 07:02:17 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[SCOP]]></category>

		<guid isPermaLink="false">http://www.logopt.com/wp_blog/?p=298</guid>
		<description><![CDATA[SCOP is a constrained programming solver. In the example we call SCOP from Python language. A B The problem is to label the graph’s vertices (6 vertices) with colors (in this example, we use 3 colors) such that no two &#8230; <a href="http://www.logopt.com/wp_blog/?p=298">続きを読む <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>SCOP is a constrained programming solver.<br />
In the example we call SCOP from Python language.</p>
<p><a href="http://www.logopt.com/wp_blog/wp-content/uploads/2011/06/gcp1.jpg"><img src="http://www.logopt.com/wp_blog/wp-content/uploads/2011/06/gcp1-1024x455.jpg" alt="" title="gcp" width="640" height="284" class="aligncenter size-large wp-image-303" /></a><br />
 <code style="padding-left: 160px;">  A   <code style="padding-left: 300px;">  B </code></p>
<p>The problem is to label the graph’s vertices (6 vertices) with colors (in this example, we use 3 colors) such that no two vertices sharing the same edge have the same color.</p>
<p>graph (A) is the problem.<br />
graph (B) is the solution.</p>
<p>The Python code can be written as follows:<br />
************************************<br />
<code>"""<br />
Using SCOP for solving the graph coloring problem<br />
Copyright (c) by Joao Pedro PEDROSO and Mikio KUBO, 2011<br />
"""</code></p>
<p><code>from scop2 import *<br />
m=Model()</code></p>
<p><code>K=3<br />
nodes=["n"+str(i) for i in range(6)]<br />
adj=[[2],[3],[0,3,4,5],[1,2,5],[2],[2,3]]<br />
n=len(nodes)</code></p>
<p><code>varlist=m.addVariables(nodes,range(K))</code></p>
<p><code>for i in range(n):<br />
    <code style="padding-left: 30px;">for j in adj[i]:<br />
        <code style="padding-left: 60px;">if i < j:</code><br />
            <code style="padding-left: 90px;">con1=Alldiff("alldiff"+str(i)+str(j),[varlist[i],varlist[j]],"inf")<br />
            <code style="padding-left: 90px;">m.addConstraint(con1)</code></p>
<p><code>m.Params.TimeLimit=1<br />
sol,violated=m.optimize()</code></p>
<p><code>print "solution"<br />
for x in sol:<br />
    <code style="padding-left: 30px;">print x,sol[x]<br />
print "violated constraint(s)"<br />
for v in violated:<br />
    <code style="padding-left: 30px;">print v,violated[v]</code><br />
************************************</p>
<p>We get the following result:<br />
************************************<br />
<code>##solution<br />
##n0  0<br />
##n1  0<br />
##n2  1<br />
##n3  2<br />
##n4  2<br />
##n5  0<br />
##violated constraint(s)</code><br />
************************************</p>
]]></content:encoded>
			<wfw:commentRss>http://www.logopt.com/wp_blog/?feed=rss2&#038;p=298</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SCOP 2nd Example: graph partitioning problem</title>
		<link>http://www.logopt.com/wp_blog/?p=268</link>
		<comments>http://www.logopt.com/wp_blog/?p=268#comments</comments>
		<pubDate>Mon, 14 Mar 2011 14:16:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[SCOP]]></category>

		<guid isPermaLink="false">http://www.logopt.com/wp_blog/?p=268</guid>
		<description><![CDATA[SCOP is a constrained programming solver. In the example we call SCOP from Python language. graph (A) is the problem. graph (B) is the solution. The Python code can be written as follows: ************************************ """ Using SCOP for solving the &#8230; <a href="http://www.logopt.com/wp_blog/?p=268">続きを読む <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>SCOP is a constrained programming solver.<br />
In the example we call SCOP from Python language.</p>
<p><a href="http://www.logopt.com/wp_blog/wp-content/uploads/2011/03/gpp1.jpg"><img src="http://www.logopt.com/wp_blog/wp-content/uploads/2011/03/gpp1-1024x520.jpg" alt="" title="gpp" width="640" height="325" class="aligncenter size-large wp-image-148" /></a></p>
<p>graph (A) is the problem.<br />
graph (B) is the solution.</p>
<p>The Python code can be written as follows:<br />
************************************<br />
<code>"""<br />
Using SCOP for solving the graph partitioning problem<br />
Copyright (c) by Joao Pedro PEDROSO and Mikio KUBO, 2011<br />
"""</code></p>
<p><code>from scop2 import *<br />
m=Model()</code></p>
<p><code>nodes=["n"+str(i) for i in range(6)]<br />
adj=[[1,4],[0,2,4],[1],[4,5],[0,1,3,5],[3,4]]<br />
n=len(nodes)</code></p>
<p><code>varlist=m.addVariables(nodes,[0,1])</code></p>
<p><code>con1=Linear("constraint","inf",n/2,"=")<br />
for i in range(len(nodes)):<br />
    <code style="padding-left: 30px;">con1.addTerms(1,varlist[i],1)<br />
m.addConstraint(con1)</code></p>
<p><code>con2=Quadratic("obj")<br />
for i in range(n):<br />
    <code style="padding-left: 30px;">for j in adj[i]:<br />
        <code style="padding-left: 60px;">con2.addTerms(1,varlist[i],1,varlist[j],0)<br />
        <code style="padding-left: 60px;">con2.addTerms(1,varlist[i],0,varlist[j],1)<br />
m.addConstraint(con2)</code></p>
<p><code>m.Params.TimeLimit=1<br />
sol,violated=m.optimize()</code></p>
<p><code>print "solution"<br />
for x in sol:<br />
    <code style="padding-left: 30px;">print x,sol[x]<br />
print "violated constraint(s)"<br />
for v in violated:<br />
    <code style="padding-left: 30px;">print v,violated[v]</code></p>
<p>************************************</p>
<p>We get the following result:<br />
************************************<br />
<code>##solution<br />
##n0  0<br />
##n1  0<br />
##n2  0<br />
##n3  1<br />
##n4  1<br />
##n5  1<br />
##violated constraint(s)<br />
##obj  4</code><br />
************************************</p>
]]></content:encoded>
			<wfw:commentRss>http://www.logopt.com/wp_blog/?feed=rss2&#038;p=268</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OptSeq 4th Example: Parallel Shop Problem using Modes</title>
		<link>http://www.logopt.com/wp_blog/?p=256</link>
		<comments>http://www.logopt.com/wp_blog/?p=256#comments</comments>
		<pubDate>Mon, 14 Mar 2011 13:12:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[OptSeq]]></category>

		<guid isPermaLink="false">http://www.logopt.com/wp_blog/?p=256</guid>
		<description><![CDATA[Here, we introduce the 4th example of OptSeq Python module. Consider a 10-activity problem in which each activity is processed on three identical parallel machines. The processing times (durations) of the activities are kept in the dictionary duration ={1:3, 2:2, &#8230; <a href="http://www.logopt.com/wp_blog/?p=256">続きを読む <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Here, we introduce the 4th example of OptSeq Python module.</p>
<p>Consider a 10-activity problem in which each activity is processed on three identical parallel machines.<br />
The processing times (durations) of the activities are kept in the dictionary<br />
 duration ={1:3, 2:2, 3:2, 4:2, 5:4, 6:4, 7:4, 8:4, 9:11, 10:2 }.<br />
Precedence constraints are given by:<br />
 Activity 1 -> Activity 9;<br />
 Activities 5,6,7,8 are processed after Activity 4 and before Activity 10.<br />
Activity 1 can be processed in one of the following three modes:<br />
 Mode 1 with duration 3 that requires 1 unit of worker resource,<br />
 Mode 2 with duration 2 that requires 2 units of worker resource, and<br />
 Mode 3 with duration 1 that requires 3 units of worker resource.<br />
The objective is to find the maximum completion time (makespan).</p>
<p>Now the Python code can be written as follows:<br />
******************************************<br />
<code>from optseq2 import *<br />
m1=Model()<br />
duration ={1:3, 2:2, 3:2, 4:2, 5:4, 6:4, 7:4, 8:4, 9:11, 10:2 }<br />
res=m1.addResource("worker",capacity={(0,"inf"):3})<br />
act={}<br />
mode={}</code></p>
<p><code>for i in duration:<br />
    <code style="padding-left: 30px;">act[i]=m1.addActivity("Act[%s]"%i)<br />
    <code style="padding-left: 30px;">if i==1:<br />
        <code style="padding-left: 60px;">mode[1,1]=Mode("Mode[1_1]",3)<br />
        <code style="padding-left: 60px;">mode[1,1].addResource(res,{(0,"inf"):1})<br />
        <code style="padding-left: 60px;">mode[1,2]=Mode("Mode[1_2]",2)<br />
        <code style="padding-left: 60px;">mode[1,2].addResource(res,{(0,"inf"):2})<br />
        <code style="padding-left: 60px;">mode[1,3]=Mode("Mode[1_3]",1)<br />
        <code style="padding-left: 60px;">mode[1,3].addResource(res,{(0,"inf"):3})<br />
        <code style="padding-left: 60px;">act[i].addModes(mode[1,1],mode[1,2],mode[1,3])<br />
   <code style="padding-left: 30px;"> else:<br />
        <code style="padding-left: 60px;">mode[i]=Mode("Mode[%s]"%i,duration[i])<br />
        <code style="padding-left: 60px;">mode[i].addResource(res,{(0,"inf"):1})<br />
        <code style="padding-left: 60px;">act[i].addModes(mode[i])</code></p>
<p><code>#temporal (precedense) constraints<br />
m1.addTemporal(act[1],act[9])<br />
for i in range(5,9):<br />
    <code style="padding-left: 30px;">m1.addTemporal(act[4],act[i])<br />
    <code style="padding-left: 30px;">m1.addTemporal(act[i],act[10])</code></p>
<p><code>m1.Params.TimeLimit=1<br />
m1.Params.Makespan=True<br />
m1.optimize()</code><br />
******************************************</p>
<p>We get the following result:<br />
******************************************<br />
<code>##source --- 0 0<br />
##sink --- 13 13<br />
##Act[1] Mode[1_3] 0 1<br />
##Act[2] --- 1 3<br />
##Act[3] --- 11 13<br />
##Act[4] --- 1 3<br />
##Act[5] --- 7 11<br />
##Act[6] --- 3 7<br />
##Act[7] --- 7 11<br />
##Act[8] --- 3 7<br />
##Act[9] --- 1 12<br />
##Act[10] --- 11 13<br />
##planning horizon= 13</code><br />
******************************************</p>
]]></content:encoded>
			<wfw:commentRss>http://www.logopt.com/wp_blog/?feed=rss2&#038;p=256</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OptSeq 3rd Example: Parallel Shop Problem</title>
		<link>http://www.logopt.com/wp_blog/?p=225</link>
		<comments>http://www.logopt.com/wp_blog/?p=225#comments</comments>
		<pubDate>Sun, 13 Mar 2011 18:21:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[OptSeq]]></category>

		<guid isPermaLink="false">http://www.logopt.com/wp_blog/?p=225</guid>
		<description><![CDATA[Here, we introduce the 3rd example of OptSeq Python module. Consider a 10-activity problem in which each activity is processed on three identical parallel machines. The processing times (durations) of the activities are kept in the dictionary duration ={1:3, 2:2, &#8230; <a href="http://www.logopt.com/wp_blog/?p=225">続きを読む <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Here, we introduce the 3rd example of OptSeq Python module.</p>
<p>Consider a 10-activity problem in which each activity is processed on three identical parallel machines.<br />
The processing times (durations) of the activities are kept in the dictionary<br />
 <code>duration ={1:3, 2:2, 3:2, 4:2, 5:4, 6:4, 7:4, 8:4, 9:11, 10:2 }</code>.<br />
Precedence constraints are given by:<br />
 Activity 1 -> Activity 9;<br />
 Activities 5,6,7,8 are processed after Activity 4 and before Activity 10.<br />
The objective is to find the maximum completion time (makespan).</p>
<p>Now the Python code can be written as follows:<br />
******************************************<br />
<code>from optseq2 import *<br />
m1=Model()<br />
duration ={1:3, 2:2, 3:2, 4:2, 5:4, 6:4, 7:4, 8:4, 9:11, 10:2 }<br />
res=m1.addResource("worker",capacity={(0,"inf"):3})<br />
act={}<br />
mode={}<br />
for i in duration:</code><br />
    <code style="padding-left: 30px;">act[i]=m1.addActivity("Act[%s]"%i)<br />
    <code style="padding-left: 30px;">mode[i]=Mode("Mode[%s]"%i,duration[i])<br />
    <code style="padding-left: 30px;">mode[i].addResource(res,{(0,"inf"):1})<br />
    <code style="padding-left: 30px;">act[i].addModes(mode[i])</code></p>
<p><code>#temporal (precedense) constraints<br />
m1.addTemporal(act[1],act[9])<br />
for i in range(5,9):</code><br />
    <code style="padding-left: 30px;">m1.addTemporal(act[4],act[i])<br />
    <code style="padding-left: 30px;">m1.addTemporal(act[i],act[10])</code><br />
<code>m1.Params.TimeLimit=1<br />
m1.Params.Makespan=True<br />
m1.optimize() </code></p>
<p>******************************************</p>
<p>We get the following result:<br />
******************************************<br />
<code>##source --- 0 0<br />
##sink --- 14 14<br />
##Act[1] --- 0 3<br />
##Act[2] --- 0 2<br />
##Act[3] --- 0 2<br />
##Act[4] --- 2 4<br />
##Act[5] --- 8 12<br />
##Act[6] --- 4 8<br />
##Act[7] --- 8 12<br />
##Act[8] --- 4 8<br />
##Act[9] --- 3 14<br />
##Act[10] --- 12 14<br />
##planning horizon= 14</code><br />
******************************************</p>
]]></content:encoded>
			<wfw:commentRss>http://www.logopt.com/wp_blog/?feed=rss2&#038;p=225</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OptSeq 2nd Example: PERT with resource constraint</title>
		<link>http://www.logopt.com/wp_blog/?p=156</link>
		<comments>http://www.logopt.com/wp_blog/?p=156#comments</comments>
		<pubDate>Sun, 13 Mar 2011 14:20:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[OptSeq]]></category>

		<guid isPermaLink="false">http://www.logopt.com/wp_blog/?p=156</guid>
		<description><![CDATA[Here, we introduce the 2nd example of OptSeq Python module. Consider a 5-activity problem with precedence constraints between the activities. The processing times (durations) of the activities are kept in the dictionary duration ={1:13, 2:25, 3:15, 4:27, 5:22 }. Precedence &#8230; <a href="http://www.logopt.com/wp_blog/?p=156">続きを読む <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Here, we introduce the 2nd example of OptSeq Python module.</p>
<p>Consider a 5-activity problem with precedence constraints between the activities.<br />
The processing times (durations) of the activities are kept in the dictionary<br />
 duration ={1:13, 2:25, 3:15, 4:27, 5:22 }.<br />
Precedence constraints are given by:<br />
 Activity 1 -> Activity 3; Activity 2 -> Activity 4;<br />
 Activity 3 -> Activity 4; and Activity 3 -> Activity 5.<br />
Each activity requires one unit of worker resource whose capacity (maximum amount of availability for each time period) is 1.<br />
The objective is to find the maximum completion time (makespan) for all 5 activities</p>
<p>Now the Python code can be written as follows:<br />
******************************************<br />
<code>from optseq2 import *<br />
m1=Model()<br />
duration ={1:13, 2:25, 3:15, 4:27, 5:22 }<br />
res=m1.addResource("worker",capacity={(0,"inf"):1})<br />
act={}<br />
mode={}  </code></p>
<p><code>for i in duration: </code><br />
    <code style="padding-left: 30px;">act[i]=m1.addActivity("Act[%s]"%i)<br />
    <code style="padding-left: 30px;">mode[i]=Mode("Mode[%s]"%i,duration[i])<br />
    <code style="padding-left: 30px;">mode[i].addResource(res,{(0,"inf"):1})<br />
    <code style="padding-left: 30px;">act[i].addModes(mode[i])</code></p>
<p><code>#temporal (precedense) constraints<br />
m1.addTemporal(act[1],act[3])<br />
m1.addTemporal(act[2],act[4])<br />
m1.addTemporal(act[2],act[5])<br />
m1.addTemporal(act[3],act[4])</code></p>
<p><code>m1.Params.TimeLimit=1<br />
m1.Params.OutputFlag=True<br />
m1.Params.Makespan=True<br />
m1.optimize()</code><br />
******************************************</p>
<p>We get the following result:<br />
******************************************<br />
<code>##source --- 0 0<br />
##sink --- 102 102<br />
##Act[1] --- 47 60<br />
##Act[2] --- 0 25<br />
##Act[3] --- 60 75<br />
##Act[4] --- 75 102<br />
##Act[5] --- 25 47<br />
##planning horizon= 102</code><br />
******************************************</p>
]]></content:encoded>
			<wfw:commentRss>http://www.logopt.com/wp_blog/?feed=rss2&#038;p=156</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AMPL問題例７：グラフ分割問題</title>
		<link>http://www.logopt.com/wp_blog/?p=140</link>
		<comments>http://www.logopt.com/wp_blog/?p=140#comments</comments>
		<pubDate>Sat, 12 Mar 2011 16:21:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AMPL]]></category>

		<guid isPermaLink="false">http://www.logopt.com/wp_blog/?p=140</guid>
		<description><![CDATA[**以下に記述するAMPLモデルとデータには漢字コメントを使用しているため，そのまま実行するとエラーします．コピーして実行するときはコメント文を削除して下さい．** 問題概要 ６つの点を L と R の２つのグループに等分割しようとする． 点と点の間には図 A のように枝がある． L と R をまたぐ枝の数が最小になるように等分割するにはどのように分ければよいのか． 図 B は最適解． 以下はAMPLのモデルです． *********************************** param n ;　　　　　　　　　#点の数 set V := {0 .. n-1}; 　　　#点の集合 set E within {V,V}; 　　　#枝の集合 var x {V} binary;　　　　　#点 i が &#8230; <a href="http://www.logopt.com/wp_blog/?p=140">続きを読む <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>**以下に記述するAMPLモデルとデータには漢字コメントを使用しているため，そのまま実行するとエラーします．コピーして実行するときはコメント文を削除して下さい．**</p>
<p>問題概要<br />
６つの点を L と R の２つのグループに等分割しようとする．<br />
点と点の間には図 A のように枝がある．<br />
L と R をまたぐ枝の数が最小になるように等分割するにはどのように分ければよいのか．<br />
図 B は最適解．</p>
<p><a href="http://www.logopt.com/wp_blog/wp-content/uploads/2011/03/gpp1.jpg"><img src="http://www.logopt.com/wp_blog/wp-content/uploads/2011/03/gpp1-1024x520.jpg" alt="" title="gpp" width="640" height="325" class="aligncenter size-large wp-image-148" /></a></p>
<p>以下はAMPLのモデルです．</p>
<p>***********************************<br />
<code>param n ;　　　　　　　　　#点の数</code></p>
<p><code>set V := {0 .. n-1};     　　　#点の集合<br />
set E within {V,V};      　　　#枝の集合</code></p>
<p><code>var x {V} binary;　　　　　#点 i が L 側に含まれるとき１，その他のとき（R 側に含まれるとき）０<br />
var y {E} binary ;　　　　　#枝が L と R をまたいでいるとき１，その他のとき０</code></p>
<p><code>minimize Adjacency: 　　<br />
sum{(i,j) in E}y[i,j] ;　　　　　# L と R をまたぐ枝の本数を最小化</code></p>
<p><code>subject to constraint1:<br />
sum{i in V} x[i] = n/2 ;　　　　　#等分割を表す制約</code></p>
<p><code>subject to constraint2 {(i,j) in E} :<br />
x[i]-x[j]<=y[i,j] ;　　　　　　　　　　　　　　　<br />
# i が L に入っていて，j が L に入っていないとき y[i,j] が 1 になることを規定する制約</code></p>
<p><code>subject to constraint3 {(i,j) in E} :<br />
x[j]-x[i]<=y[i,j] ;<br />
# ｊ が L に入っていて，i が L に入っていないとき y[i,j] が 1 になることを規定する制約</code><br />
***********************************</p>
<p>以下はAMPLのデータです．</p>
<p>***********************************<br />
<code>param n =6 ;<br />
set E := 0 1  0 4  1 2  1 4  3 4  3 5  4 5 ;</code><br />
***********************************</p>
]]></content:encoded>
			<wfw:commentRss>http://www.logopt.com/wp_blog/?feed=rss2&#038;p=140</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AMPL問題例６：箱詰め問題（ビンパッキング問題）</title>
		<link>http://www.logopt.com/wp_blog/?p=131</link>
		<comments>http://www.logopt.com/wp_blog/?p=131#comments</comments>
		<pubDate>Fri, 11 Mar 2011 13:26:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AMPL]]></category>

		<guid isPermaLink="false">http://www.logopt.com/wp_blog/?p=131</guid>
		<description><![CDATA[**以下に記述するAMPLモデルとデータには漢字コメントを使用しているため，そのまま実行するとエラーします．コピーして実行するときはコメント文を削除して下さい．** 問題概要 ビン：１３個，入れられる上限重量９ｋｇ アイテム：２０個，各アイテムの重量はＡＭＰＬデータのパラメータ ｓ の通り アイテムをどのようにビンに入れれば必要なビンの数を最小化できるのか． 以下はAMPLのモデルです． *********************************** param Item ;　　　　　　　　　　#アイテムの数 param Bins ;　　　　　　　　　　#ビンの数 set I:={1 .. Item} ; 　　　　#アイテムの集合 set J:={1 .. Bins} ; 　　　　#ビンの集合 param B ;　　　　　　　　　　　　#ビンの重さ param s {I} ;　　　　　　　　　#アイテムの重さ var x {I,J} binary;　　　　　　#アイテム i をビン &#8230; <a href="http://www.logopt.com/wp_blog/?p=131">続きを読む <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>**以下に記述するAMPLモデルとデータには漢字コメントを使用しているため，そのまま実行するとエラーします．コピーして実行するときはコメント文を削除して下さい．**</p>
<p>問題概要<br />
ビン：１３個，入れられる上限重量９ｋｇ<br />
アイテム：２０個，各アイテムの重量はＡＭＰＬデータのパラメータ ｓ の通り<br />
アイテムをどのようにビンに入れれば必要なビンの数を最小化できるのか．</p>
<p>以下はAMPLのモデルです．</p>
<p>***********************************<br />
<code>param Item ;　　　　　　　　　　#アイテムの数<br />
param Bins ;　　　　　　　　　　#ビンの数</code></p>
<p><code>set I:={1 .. Item} ; 　　　　#アイテムの集合<br />
set J:={1 .. Bins} ; 　　　　#ビンの集合</code></p>
<p><code>param B ;　　　　　　　　　　　　#ビンの重さ<br />
param s {I} ;　　　　　　　　　#アイテムの重さ</code></p>
<p><code>var x {I,J} binary;　　　　　　#アイテム i をビン j に入れるとき１，その他のとき０<br />
var y {J} binary ;　　　　　　#ビン j を使うとき１，その他のとき０</code></p>
<p><code>minimize Bins_Num:<br />
 sum{j in J}y[j] ;　　　　　　　#ビンの数を最小化</code></p>
<p><code>subject to Assign {i in I}:<br />
sum{j in J}x[i,j]=1 ;　　　　　#アイテムは必ずビンに割り当てられなければならない</code></p>
<p><code>subject to Capacity {j in J} :<br />
sum{i in I} s[i]*x[i,j]<=B*y[j] ;　　#各ビンに入れるアイテムの合計重量はビンの上限重量以下</code></p>
<p><code>subject to Tighten_Con {i in I, j in J} :　<br />
x[i,j] <= y[j] ;　　　　　　　　　#ビンを使用しないときはアイテムは入れられない</code><br />
***********************************</p>
<p>以下はAMPLのデータです．</p>
<p>***********************************<br />
<code>param Item:= 20 ;<br />
param Bins:=13 ;<br />
param B :=9 ;<br />
param s :=<br />
1 6<br />
2 6<br />
3 5<br />
4 5<br />
5 5<br />
6 4<br />
7 4<br />
8 4<br />
9 4<br />
10 2<br />
11 2<br />
12 2<br />
13 2<br />
14 3<br />
15 3<br />
16 7<br />
17 7<br />
18 5<br />
19 8<br />
20 8<br />
;</code><br />
***********************************</p>
]]></content:encoded>
			<wfw:commentRss>http://www.logopt.com/wp_blog/?feed=rss2&#038;p=131</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

