RE: Transladate problem from Octave to R

Sebastián Kruk Gencarelli <[email protected]> Thu, 15 Sep 2022 12:17:37 +0000
Newsgroups gmane.comp.gnu.glpk
Message-ID <PH0PR06MB8381767026EF9E3FD9CA2A4CF59C9@PH0PR06MB8381.namprd06.prod.outlook.com>
--_004_PH0PR06MB8381767026EF9E3FD9CA2A4CF59C9PH0PR06MB8381namp_
Content-Type: multipart/alternative;
	boundary="_000_PH0PR06MB8381767026EF9E3FD9CA2A4CF59C9PH0PR06MB8381namp_"

--_000_PH0PR06MB8381767026EF9E3FD9CA2A4CF59C9PH0PR06MB8381namp_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Joseph,

Thank you for your advice.

See you!

Sebasti=E1.



Enviado desde Correo<https://go.microsoft.com/fwlink/?LinkId=3D550986> para=
 Windows

De: Atwood, Joseph<mailto:[email protected]>
Enviado: martes, 2 de agosto de 2022 17:14
Para: Sebasti=E1n Kruk Gencarelli<mailto:[email protected]>; help-glpk=
@gnu.org<mailto:[email protected]>
Asunto: Re: Transladate problem from Octave to R

Sebastian

The matrix arguments you are passing to the Rglpk_solve_LP function are not=
 of conformable dimensions.   (In addition, I don't think the Rglpk functio=
n will replicate the elements of argument dir =3D c("<=3D", "<=3D", "<=3D")=
 to be of the appropriate dimension either.  With R the script dir=3Dc("<=
=3D", "<=3D", "<=3D") will generate a vector of length of dimension 3)
From the code (and your email) the object c is of length 30, the matrix A i=
s a 21 by 30 matrix,

b is of length  50, the 'dir' vector will be of length 3, vlb is of length =
30, vub is of length 30



In addition, if used, the types argument must be a character string  vector=
.

> str(ctype)

chr [1:21] "S" "S" "S" "S" "S" "S" "S" "S" "S" "S" "S" "U" "U" "U" "U" "U" =
"U" "U" "U" "U" "U"



ctype is a vector



> str(vartype)

chr [1:3, 1:10] "C" "I" "C" "C" "I" "C" "C" "I" "C" "C" "I" "C" "C" "I" "C"=
 "C" "I" "C" "C" "I" "C" "C" "I" "C" "C" "I" "C" "C" "I" "C"


The matrix 3x10 vartype can be converted to a vector using the command as.v=
ector(vartype) but will read the matrix in column-major-order.


In any case in the command:
Rglpk_solve_LP(obj =3D c, mat =3D A, dir =3D c("<=3D", "<=3D", "<=3D"), rhs=
 =3D b)

the length of the c vector (30) must match the number of columns in the A m=
atrix (30), the length of the b vector i.e. (50) must match the number of r=
ows in the A matrix (21), and the length of the dir vector (3) must match t=
he number of rows in the A matrix (21).

This is why the error message:



Error in Rglpk_call(obj =3D obj, mat =3D mat, dir =3D dir, rhs =3D rhs, bou=
nds =3D bounds,  :

  Arguments 'mat', 'dir', and/or 'rhs' not conformable.


Joseph Atwood
208 Linfield Hall
Montana State University
Bozeman, MT 59717
406-994-5614

From: Help-glpk <[email protected]> on behalf=
 of Sebasti=E1n Kruk Gencarelli <[email protected]>
Sent: Tuesday, August 2, 2022 9:18 AM
To: [email protected] <[email protected]>
Subject: Transladate problem from Octave to R


**External Sender**

Dear glpk-users,



In Octave:



[z_opt,f_min,errnum,extra]=3Dglpk(c,A,b,vlb,vub,ctype,vartype,sense)



How can be transformed to use it in R?



If I use it:



Rglpk_solve_LP(obj =3D c, mat =3D A, dir =3D c("<=3D", "<=3D", "<=3D"), rhs=
 =3D b)



Give me an error:



Error in Rglpk_call(obj =3D obj, mat =3D mat, dir =3D dir, rhs =3D rhs, bou=
nds =3D bounds,  :

  Arguments 'mat', 'dir', and/or 'rhs' not conformable.



Where:



> str(c)

num [1:30, 1] 0 0 0 0 0 0 0 0 0 0 ...



> str(A)

num [1:21, 1:30] 1 0 0 0 0 0 0 0 0 0 ...



> str(b)

num [1:50, 1] 22 37 37 37 37 37 37 37 37 37 ...



> str(vlb)

num [1:30, 1] 0 0 0 0 0 0 0 0 0 0 ...



> str(vub)

num [1:30, 1] 150 150 150 150 150 150 150 150 150 150 ...



> str(ctype)

chr [1:21] "S" "S" "S" "S" "S" "S" "S" "S" "S" "S" "S" "U" "U" "U" "U" "U" =
"U" "U" "U" "U" "U"



> str(vartype)

chr [1:3, 1:10] "C" "I" "C" "C" "I" "C" "C" "I" "C" "C" "I" "C" "C" "I" "C"=
 "C" "I" "C" "C" "I" "C" "C" "I" "C" "C" "I" "C" "C" "I" "C"

- attr(*, "dimnames")=3DList of 2

  ..$ : chr [1:3] "varcont" "varint" "varcont"

  ..$ : NULL



> str(sense)

num 1



My script in R is:



#1) Datos



#Per=EDodo de estudio (d=EDas)

T =3D 10



#Demanda diaria

dda =3D 37*matrix(1,T,1)



#Capacidad de cami=F3n (m3)

K=3D30



#Capacidad de tanque (m3)

cap_tqe=3D40



#Stock inicial (m3)

s0=3D15



#Max cantidad diaria de camiones

y_max=3D5



#Max volumen entrega diaria

x_max=3DK*y_max



#2) Modelo sin entrega los domingos



#Variables: z=3D[x; y; s], entega x(t), cant camiones y(t), stock final s(t=
)

c =3D matrix(rep(c(0,1,0),each =3D T)) #solo cuestan los viajes

vlb =3D matrix(rep(0,3*T))

vub =3D matrix(c(x_max*rep(1,T),y_max*rep(1,T), cap_tqe*rep(1,T)))

#



#Restricciones grupo1: balanceen cada t,  s(t)=3Ds(t-1)+x(t)-dda(t)

A1=3Dmatrix(0,nrow=3DT,ncol=3D3*T)

A1[,1:T]=3Ddiag(1,dim(A1[,1:T]))

library(pracma)

A1[,(2*T+1):(3*T)]=3D-diag(1,T,T)+Diag(rep(1,T-1),-1)

b1 =3D dda

b1[1] =3D b1[1]-s0



#Restricciones grupo2: balanceen cada t,  s(t)=3Ds(t-1)+x(t)-dda(t)

n7=3Dfloor(T/7)

A2=3Dmatrix(0,ncol=3D3*T,nrow=3Dn7)

b2=3Dmatrix(0,nrow=3D3*T,ncol=3D1)

ifelse(rem(col(A2),7)=3D=3D0,1,0)



#Restricciones grupo3: vol entregado menor y cant camiones, x(t)<K*y(t)

A3=3Dmatrix(0,nrow=3DT,ncol=3D3*T)

A3[,1:T]=3Ddiag(1,T)

A3[,(T+1):(2*T)]=3Ddiag(-K,T)

b3=3Dmatrix(0,nrow=3DT,ncol=3D1)



#

A =3D rbind(A1,A2,A3)

b =3D rbind(b1,b2,b3)



#Tipo de variables y restricciones

varint=3Drep("I",T)

varcont=3Drep("C",T)

ctype=3Drep("S",T)

vartype=3Drbind(varcont, varint, varcont)

ctype=3Dc(ctype, rep("S",n7))

ctype=3Dc(ctype, rep("U",T))



#

sense=3D1;



Thanks in advance!



See you!



Sebasti=E1n.




--_000_PH0PR06MB8381767026EF9E3FD9CA2A4CF59C9PH0PR06MB8381namp_
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr=
osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:=
//www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Diso-8859-=
1">
<meta name=3D"Generator" content=3D"Microsoft Word 15 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0cm;
	font-size:11.0pt;
	font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:blue;
	text-decoration:underline;}
p.xmsonormal, li.xmsonormal, div.xmsonormal
	{mso-style-name:x_msonormal;
	margin:0cm;
	font-size:11.0pt;
	font-family:"Calibri",sans-serif;}
.MsoChpDefault
	{mso-style-type:export-only;}
@page WordSection1
	{size:612.0pt 792.0pt;
	margin:70.85pt 3.0cm 70.85pt 3.0cm;}
div.WordSection1
	{page:WordSection1;}
--></style>
</head>
<body lang=3D"ES-UY" link=3D"blue" vlink=3D"#954F72" style=3D"word-wrap:bre=
ak-word">
<div class=3D"WordSection1">
<p class=3D"MsoNormal"><span lang=3D"ES">Joseph,<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"ES"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"ES">Thank you for your advice.<o:p></o=
:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"ES"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"ES">See you!<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"ES"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"ES">Sebasti=E1.<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"ES"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">Enviado desde <a href=3D"https://go.microsoft.com/fw=
link/?LinkId=3D550986">
Correo</a> para Windows</p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<div style=3D"mso-element:para-border-div;border:none;border-top:solid #E1E=
1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class=3D"MsoNormal" style=3D"border:none;padding:0cm"><b>De: </b><a href=
=3D"mailto:[email protected]">Atwood, Joseph</a><br>
<b>Enviado: </b>martes, 2 de agosto de 2022 17:14<br>
<b>Para: </b><a href=3D"mailto:[email protected]">Sebasti=E1n Kruk Gen=
carelli</a>;
<a href=3D"mailto:[email protected]">[email protected]</a><br>
<b>Asunto: </b>Re: Transladate problem from Octave to R</p>
</div>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<div>
<p class=3D"MsoNormal"><span style=3D"font-size:12.0pt;color:black">Sebasti=
an<o:p></o:p></span></p>
</div>
<div>
<p class=3D"MsoNormal"><span style=3D"font-size:12.0pt;color:black"><o:p>&n=
bsp;</o:p></span></p>
</div>
<div>
<p class=3D"MsoNormal"><span style=3D"font-size:12.0pt;color:black">The mat=
rix arguments you are passing to the Rglpk_solve_LP function are not of con=
formable dimensions.&nbsp; &nbsp;(In addition, I don't think the Rglpk func=
tion will replicate the elements of argument&nbsp;</span><span style=3D"col=
or:#201F1E;background:white">dir
 =3D c(&quot;&lt;=3D&quot;, &quot;&lt;=3D&quot;, &quot;&lt;=3D&quot;) to be=
 of the appropriate dimension either.&nbsp; With R the script dir=3Dc(&quot=
;&lt;=3D&quot;, &quot;&lt;=3D&quot;, &quot;&lt;=3D&quot;) will generate a v=
ector of length of dimension 3)</span><span style=3D"font-size:12.0pt;color=
:black"><o:p></o:p></span></p>
</div>
<div>
<p class=3D"MsoNormal"><span style=3D"color:#201F1E;background:white">From =
the code (and your email) the object c is of length 30, the matrix A is a 2=
1 by 30 matrix,&nbsp;</span><span style=3D"font-size:12.0pt;color:black"><o=
:p></o:p></span></p>
</div>
<div>
<p class=3D"xmsonormal" style=3D"background:white"><span style=3D"color:#20=
1F1E;background:white">b is of length&nbsp; 50, the 'dir' vector will be of=
 length 3, vlb is of length 30, vub is of length 30&nbsp;<o:p></o:p></span>=
</p>
<p class=3D"xmsonormal" style=3D"background:white"><span style=3D"color:#20=
1F1E;background:white"><o:p>&nbsp;</o:p></span></p>
<p class=3D"xmsonormal" style=3D"background:white"><span style=3D"color:#20=
1F1E;background:white">In addition,<b> if used</b>, the types argument must=
 be a character string&nbsp; vector.&nbsp;&nbsp;<o:p></o:p></span></p>
<p class=3D"xmsonormal" style=3D"background:white"><span style=3D"color:#20=
1F1E;background:white">&gt; str(ctype)<o:p></o:p></span></p>
<p class=3D"xmsonormal" style=3D"background:white"><span style=3D"color:#20=
1F1E;background:white">chr [1:21] &quot;S&quot; &quot;S&quot; &quot;S&quot;=
 &quot;S&quot; &quot;S&quot; &quot;S&quot; &quot;S&quot; &quot;S&quot; &quo=
t;S&quot; &quot;S&quot; &quot;S&quot; &quot;U&quot; &quot;U&quot; &quot;U&q=
uot; &quot;U&quot; &quot;U&quot; &quot;U&quot; &quot;U&quot; &quot;U&quot; =
&quot;U&quot; &quot;U&quot;<o:p></o:p></span></p>
<p class=3D"xmsonormal" style=3D"background:white"><span style=3D"color:#20=
1F1E;background:white">&nbsp;<o:p></o:p></span></p>
<p class=3D"xmsonormal" style=3D"background:white"><span style=3D"color:#20=
1F1E;background:white">ctype is a vector<o:p></o:p></span></p>
<p class=3D"xmsonormal" style=3D"background:white"><span style=3D"color:#20=
1F1E;background:white"><o:p>&nbsp;</o:p></span></p>
<p class=3D"xmsonormal" style=3D"background:white"><span style=3D"color:#20=
1F1E;background:white">&gt; str(vartype)<o:p></o:p></span></p>
<p class=3D"xmsonormal" style=3D"background:white"><span style=3D"color:#20=
1F1E;background:white">chr [1:3, 1:10] &quot;C&quot; &quot;I&quot; &quot;C&=
quot; &quot;C&quot; &quot;I&quot; &quot;C&quot; &quot;C&quot; &quot;I&quot;=
 &quot;C&quot; &quot;C&quot; &quot;I&quot; &quot;C&quot; &quot;C&quot; &quo=
t;I&quot; &quot;C&quot; &quot;C&quot; &quot;I&quot; &quot;C&quot; &quot;C&q=
uot; &quot;I&quot; &quot;C&quot; &quot;C&quot; &quot;I&quot; &quot;C&quot; =
&quot;C&quot; &quot;I&quot; &quot;C&quot; &quot;C&quot; &quot;I&quot; &quot=
;C&quot;<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"color:#201F1E;background:white"><br>
<br>
</span><span style=3D"font-size:12.0pt;color:black"><o:p></o:p></span></p>
</div>
<div>
<p class=3D"MsoNormal"><span style=3D"color:#201F1E;background:white">The m=
atrix 3x10 vartype can be converted to a vector using the command as.vector=
(vartype) but will read the matrix in column-major-order.</span><span style=
=3D"font-size:12.0pt;color:black"><o:p></o:p></span></p>
</div>
<div>
<p class=3D"MsoNormal"><span style=3D"color:#201F1E;background:white"><br>
<br>
</span><span style=3D"font-size:12.0pt;color:black"><o:p></o:p></span></p>
</div>
<div>
<p class=3D"MsoNormal"><span style=3D"color:#201F1E;background:white">In an=
y case in the command:</span><span style=3D"font-size:12.0pt;color:black"><=
o:p></o:p></span></p>
</div>
<div>
<p class=3D"MsoNormal"><span style=3D"color:black;background:white">Rglpk_s=
olve_LP(obj =3D c, mat =3D A, dir =3D c(&quot;&lt;=3D&quot;, &quot;&lt;=3D&=
quot;, &quot;&lt;=3D&quot;), rhs =3D b)</span><span style=3D"color:#201F1E;=
background:white"><br>
<br>
</span><span style=3D"font-size:12.0pt;color:black"><o:p></o:p></span></p>
</div>
<div>
<p class=3D"MsoNormal"><span style=3D"color:black">the length of the c vect=
or (30) must match the number of columns in the A matrix (30), the length o=
f the b vector i.e. (50) must match the number of rows in the A matrix (21)=
, and the length of the dir vector (3)
 must match the number of rows in the A matrix (21).<o:p></o:p></span></p>
</div>
<div>
<p class=3D"MsoNormal"><span style=3D"font-size:12.0pt;color:black"><o:p>&n=
bsp;</o:p></span></p>
</div>
<div>
<p class=3D"MsoNormal"><span style=3D"font-size:12.0pt;color:black">This is=
 why the error message:<o:p></o:p></span></p>
</div>
<div>
<p class=3D"xmsonormal" style=3D"background:white"><span style=3D"color:bla=
ck"><o:p>&nbsp;</o:p></span></p>
<p class=3D"xmsonormal" style=3D"background:white"><span lang=3D"ES" style=
=3D"color:black">Error in Rglpk_call(obj =3D obj, mat =3D mat, dir =3D dir,=
 rhs =3D rhs, bounds =3D bounds,&nbsp; :</span><span style=3D"color:black">=
<o:p></o:p></span></p>
<p class=3D"xmsonormal" style=3D"background:white"><span lang=3D"ES" style=
=3D"color:black">&nbsp;&nbsp;Arguments 'mat', 'dir', and/or 'rhs' not confo=
rmable.</span><span style=3D"color:black"><o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:12.0pt;color:black"><o:p>&n=
bsp;</o:p></span></p>
</div>
<div>
<p class=3D"MsoNormal"><span style=3D"font-size:12.0pt;color:black"><o:p>&n=
bsp;</o:p></span></p>
</div>
<div>
<div id=3D"Signature">
<div>
<div>
<p class=3D"MsoNormal"><span style=3D"font-size:12.0pt;color:black">Joseph =
Atwood<o:p></o:p></span></p>
</div>
<div>
<p class=3D"MsoNormal"><span style=3D"font-size:12.0pt;color:black">208 Lin=
field Hall<o:p></o:p></span></p>
</div>
<div>
<p class=3D"MsoNormal"><span style=3D"font-size:12.0pt;color:black">Montana=
 State University<o:p></o:p></span></p>
</div>
<div>
<p class=3D"MsoNormal"><span style=3D"font-size:12.0pt;color:black">Bozeman=
, MT 59717<o:p></o:p></span></p>
</div>
<div>
<p class=3D"MsoNormal"><span style=3D"font-size:12.0pt;color:black">406-994=
-5614<o:p></o:p></span></p>
</div>
</div>
</div>
</div>
<p class=3D"MsoNormal"><img border=3D"0" width=3D"578" height=3D"2" style=
=3D"width:6.0208in;height:.0208in" id=3D"Horizontal_x0020_Line_x0020_1" src=
=3D"cid:[email protected]"><o:p></o:p></p>
<div id=3D"divRplyFwdMsg">
<p class=3D"MsoNormal"><b><span style=3D"color:black">From:</span></b><span=
 style=3D"color:black"> Help-glpk &lt;help-glpk-bounces+jatwood=3Dmontana.e=
[email protected]&gt; on behalf of Sebasti=E1n Kruk Gencarelli &lt;zloto_kruk@hotm=
ail.com&gt;<br>
<b>Sent:</b> Tuesday, August 2, 2022 9:18 AM<br>
<b>To:</b> [email protected] &lt;[email protected]&gt;<br>
<b>Subject:</b> Transladate problem from Octave to R</span> <o:p></o:p></p>
<div>
<p class=3D"MsoNormal">&nbsp;<o:p></o:p></p>
</div>
</div>
<div>
<p style=3D"line-height:12.0pt;background:#FFCC66"><strong><span style=3D"f=
ont-size:12.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:black">**E=
xternal Sender**</span></strong><span style=3D"font-size:12.0pt;color:black=
">
</span></p>
<div>
<div>
<p class=3D"xmsonormal"><span lang=3D"ES">Dear glpk-users,</span></p>
<p class=3D"xmsonormal"><span lang=3D"ES">&nbsp;</span></p>
<p class=3D"xmsonormal"><span lang=3D"ES">In Octave:</span></p>
<p class=3D"xmsonormal"><span lang=3D"ES">&nbsp;</span></p>
<p class=3D"xmsonormal"><span lang=3D"ES">[z_opt,f_min,errnum,extra]=3Dglpk=
(c,A,b,vlb,vub,ctype,vartype,sense)</span></p>
<p class=3D"xmsonormal"><span lang=3D"ES">&nbsp;</span></p>
<p class=3D"xmsonormal"><span lang=3D"ES">How can be transformed to use it =
in R?</span></p>
<p class=3D"xmsonormal"><span lang=3D"ES">&nbsp;</span></p>
<p class=3D"xmsonormal"><span lang=3D"ES">If I use it:</span></p>
<p class=3D"xmsonormal"><span lang=3D"ES">&nbsp;</span></p>
<p class=3D"xmsonormal"><span lang=3D"ES">Rglpk_solve_LP(obj =3D c, mat =3D=
 A, dir =3D c(&quot;&lt;=3D&quot;, &quot;&lt;=3D&quot;, &quot;&lt;=3D&quot;=
), rhs =3D b)</span></p>
<p class=3D"xmsonormal"><span lang=3D"ES">&nbsp;</span></p>
<p class=3D"xmsonormal"><span lang=3D"ES">Give me an error:</span></p>
<p class=3D"xmsonormal"><span lang=3D"ES">&nbsp;</span></p>
<p class=3D"xmsonormal"><span lang=3D"ES">Error in Rglpk_call(obj =3D obj, =
mat =3D mat, dir =3D dir, rhs =3D rhs, bounds =3D bounds,&nbsp; :
</span></p>
<p class=3D"xmsonormal"><span lang=3D"ES">&nbsp;&nbsp;Arguments 'mat', 'dir=
', and/or 'rhs' not conformable.</span></p>
<p class=3D"xmsonormal"><span lang=3D"ES">&nbsp;</span></p>
<p class=3D"xmsonormal"><span lang=3D"ES">Where:</span></p>
<p class=3D"xmsonormal"><span lang=3D"ES">&nbsp;</span></p>
<p class=3D"xmsonormal"><span lang=3D"ES">&gt; str(c)</span></p>
<p class=3D"xmsonormal"><span lang=3D"ES">num [1:30, 1] 0 0 0 0 0 0 0 0 0 0=
 ...</span></p>
<p class=3D"xmsonormal"><span lang=3D"ES">&nbsp;</span></p>
<p class=3D"xmsonormal"><span lang=3D"ES">&gt; str(A)</span></p>
<p class=3D"xmsonormal"><span lang=3D"ES">num [1:21, 1:30] 1 0 0 0 0 0 0 0 =
0 0 ...</span></p>
<p class=3D"xmsonormal"><span lang=3D"ES">&nbsp;</span></p>
<p class=3D"xmsonormal">&gt; str(b)</p>
<p class=3D"xmsonormal">num [1:50, 1] 22 37 37 37 37 37 37 37 37 37 ...</p>
<p class=3D"xmsonormal">&nbsp;</p>
<p class=3D"xmsonormal">&gt; str(vlb)</p>
<p class=3D"xmsonormal">num [1:30, 1] 0 0 0 0 0 0 0 0 0 0 ...</p>
<p class=3D"xmsonormal">&nbsp;</p>
<p class=3D"xmsonormal">&gt; str(vub)</p>
<p class=3D"xmsonormal">num [1:30, 1] 150 150 150 150 150 150 150 150 150 1=
50 ...</p>
<p class=3D"xmsonormal">&nbsp;</p>
<p class=3D"xmsonormal">&gt; str(ctype)</p>
<p class=3D"xmsonormal">chr [1:21] &quot;S&quot; &quot;S&quot; &quot;S&quot=
; &quot;S&quot; &quot;S&quot; &quot;S&quot; &quot;S&quot; &quot;S&quot; &qu=
ot;S&quot; &quot;S&quot; &quot;S&quot; &quot;U&quot; &quot;U&quot; &quot;U&=
quot; &quot;U&quot; &quot;U&quot; &quot;U&quot; &quot;U&quot; &quot;U&quot;=
 &quot;U&quot; &quot;U&quot;</p>
<p class=3D"xmsonormal">&nbsp;</p>
<p class=3D"xmsonormal">&gt; str(vartype)</p>
<p class=3D"xmsonormal">chr [1:3, 1:10] &quot;C&quot; &quot;I&quot; &quot;C=
&quot; &quot;C&quot; &quot;I&quot; &quot;C&quot; &quot;C&quot; &quot;I&quot=
; &quot;C&quot; &quot;C&quot; &quot;I&quot; &quot;C&quot; &quot;C&quot; &qu=
ot;I&quot; &quot;C&quot; &quot;C&quot; &quot;I&quot; &quot;C&quot; &quot;C&=
quot; &quot;I&quot; &quot;C&quot; &quot;C&quot; &quot;I&quot; &quot;C&quot;=
 &quot;C&quot; &quot;I&quot; &quot;C&quot; &quot;C&quot; &quot;I&quot; &quo=
t;C&quot;</p>
<p class=3D"xmsonormal">- attr(*, &quot;dimnames&quot;)=3DList of 2</p>
<p class=3D"xmsonormal">&nbsp; ..$ : chr [1:3] &quot;varcont&quot; &quot;va=
rint&quot; &quot;varcont&quot;</p>
<p class=3D"xmsonormal">&nbsp; ..$ : NULL</p>
<p class=3D"xmsonormal">&nbsp;</p>
<p class=3D"xmsonormal">&gt; str(sense)</p>
<p class=3D"xmsonormal">num 1</p>
<p class=3D"xmsonormal">&nbsp;</p>
<p class=3D"xmsonormal">My script in R is:</p>
<p class=3D"xmsonormal">&nbsp;</p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">#1) Datos</span></b></=
p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">&nbsp;</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">#Per=EDodo de estudio =
(d=EDas)</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">T =3D 10</span></b></p=
>
<p class=3D"xmsonormal"><b><span style=3D"color:red">&nbsp;</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">#Demanda diaria</span>=
</b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">dda =3D 37*matrix(1,T,=
1)</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">&nbsp;</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">#Capacidad de cami=F3n=
 (m3)</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">K=3D30</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">&nbsp;</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">#Capacidad de tanque (=
m3)</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">cap_tqe=3D40</span></b=
></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">&nbsp;</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">#Stock inicial (m3)</s=
pan></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">s0=3D15</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">&nbsp;</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">#Max cantidad diaria d=
e camiones</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">y_max=3D5</span></b></=
p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">&nbsp;</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">#Max volumen entrega d=
iaria</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">x_max=3DK*y_max</span>=
</b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">&nbsp;</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">#2) Modelo sin entrega=
 los domingos</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">&nbsp;</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">#Variables: z=3D[x; y;=
 s], entega x(t), cant camiones y(t), stock final s(t)</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">c =3D matrix(rep(c(0,1=
,0),each =3D T)) #solo cuestan los viajes</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">vlb =3D matrix(rep(0,3=
*T))</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">vub =3D matrix(c(x_max=
*rep(1,T),y_max*rep(1,T), cap_tqe*rep(1,T)))</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">#</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">&nbsp;</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">#Restricciones grupo1:=
 balanceen cada t,&nbsp; s(t)=3Ds(t-1)+x(t)-dda(t)</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">A1=3Dmatrix(0,nrow=3DT=
,ncol=3D3*T)</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">A1[,1:T]=3Ddiag(1,dim(=
A1[,1:T]))</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">library(pracma)</span>=
</b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">A1[,(2*T+1):(3*T)]=3D-=
diag(1,T,T)+Diag(rep(1,T-1),-1)</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">b1 =3D dda</span></b><=
/p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">b1[1] =3D b1[1]-s0</sp=
an></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">&nbsp;</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">#Restricciones grupo2:=
 balanceen cada t,&nbsp; s(t)=3Ds(t-1)+x(t)-dda(t)</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">n7=3Dfloor(T/7)</span>=
</b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">A2=3Dmatrix(0,ncol=3D3=
*T,nrow=3Dn7)</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">b2=3Dmatrix(0,nrow=3D3=
*T,ncol=3D1)</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">ifelse(rem(col(A2),7)=
=3D=3D0,1,0)</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">&nbsp;</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">#Restricciones grupo3:=
 vol entregado menor y cant camiones, x(t)&lt;K*y(t)</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">A3=3Dmatrix(0,nrow=3DT=
,ncol=3D3*T)</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">A3[,1:T]=3Ddiag(1,T)</=
span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">A3[,(T+1):(2*T)]=3Ddia=
g(-K,T)</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">b3=3Dmatrix(0,nrow=3DT=
,ncol=3D1)</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">&nbsp;</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">#</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">A =3D rbind(A1,A2,A3)<=
/span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">b =3D rbind(b1,b2,b3)<=
/span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">&nbsp;</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">#Tipo de variables y r=
estricciones</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">varint=3Drep(&quot;I&q=
uot;,T)</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">varcont=3Drep(&quot;C&=
quot;,T)</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">ctype=3Drep(&quot;S&qu=
ot;,T)</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">vartype=3Drbind(varcon=
t, varint, varcont)</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">ctype=3Dc(ctype, rep(&=
quot;S&quot;,n7))</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">ctype=3Dc(ctype, rep(&=
quot;U&quot;,T))</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">&nbsp;</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">#</span></b></p>
<p class=3D"xmsonormal"><b><span style=3D"color:red">sense=3D1;</span></b><=
/p>
<p class=3D"xmsonormal">&nbsp;</p>
<p class=3D"xmsonormal">Thanks in advance!</p>
<p class=3D"xmsonormal">&nbsp;</p>
<p class=3D"xmsonormal">See you!</p>
<p class=3D"xmsonormal">&nbsp;</p>
<p class=3D"xmsonormal">Sebasti=E1n.</p>
</div>
</div>
</div>
<p class=3D"xmsonormal">&nbsp;</p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
</body>
</html>

--_000_PH0PR06MB8381767026EF9E3FD9CA2A4CF59C9PH0PR06MB8381namp_--

--_004_PH0PR06MB8381767026EF9E3FD9CA2A4CF59C9PH0PR06MB8381namp_
Content-Type: image/png; name="C8ED3611D47B4624B621AA77D5679E91.png"
Content-Description: C8ED3611D47B4624B621AA77D5679E91.png
Content-Disposition: inline; filename="C8ED3611D47B4624B621AA77D5679E91.png";
	size=143; creation-date="Thu, 15 Sep 2022 12:17:34 GMT";
	modification-date="Thu, 15 Sep 2022 12:17:34 GMT"
Content-ID: <[email protected]>
Content-Transfer-Encoding: base64

iVBORw0KGgoAAAANSUhEUgAAAkIAAAACCAYAAAC0YLNFAAAAAXNSR0IArs4c6QAAAARnQU1BAACx
jwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAkSURBVFhH7chBDQAACMQw/Js+EIAC6JJ+VlMA
AJ5aJwDAcZUGi4V/ubu2WIQAAAAASUVORK5CYII=

--_004_PH0PR06MB8381767026EF9E3FD9CA2A4CF59C9PH0PR06MB8381namp_--