summaryrefslogtreecommitdiff
path: root/code/Symphonymat
diff options
context:
space:
mode:
authorRemyaDebasis2018-07-23 20:08:46 +0530
committerRemyaDebasis2018-07-23 20:08:46 +0530
commit392bc1326ebccd63e40cb55a82116208a54f2478 (patch)
treea98a596b8c4b64baa45966e3cc1ab75651def780 /code/Symphonymat
parent69460c03b8b53068d60fd08d3180efc91e627603 (diff)
downloadFOT_Examples-392bc1326ebccd63e40cb55a82116208a54f2478.tar.gz
FOT_Examples-392bc1326ebccd63e40cb55a82116208a54f2478.tar.bz2
FOT_Examples-392bc1326ebccd63e40cb55a82116208a54f2478.zip
added code files
Diffstat (limited to 'code/Symphonymat')
-rw-r--r--code/Symphonymat/Assignment_Problem.sce79
1 files changed, 79 insertions, 0 deletions
diff --git a/code/Symphonymat/Assignment_Problem.sce b/code/Symphonymat/Assignment_Problem.sce
new file mode 100644
index 0000000..419d9ee
--- /dev/null
+++ b/code/Symphonymat/Assignment_Problem.sce
@@ -0,0 +1,79 @@
+//Reference :H.A. Eiselt and C.-L.SAndblom,"Linear Programming and its Applications",Springer-Verlag Berlin Heidelberg 2007,chapter 2.9
+
+//The public works department of a region has issued contracts for five new projects. Each of the three contractors who have shown interest in the projects has submitted bids for those projects. The bids given by contactors are as given below
+// =====================================================================
+// Project1 Project2 Project3 Project4 Project5
+// ---------------------------------------------------------------------
+// Contractor1 20 - 10 9 15
+// Contractor2 18 12 13 8 16
+// Contractor3 - 11 12 7 17
+// =====================================================================
+//The resource requirement of the contractors for each projects and the total resources available with them are as given
+// =============================================================================
+// Project1 Project2 Project3 Project4 Project5 Available Resources
+// -----------------------------------------------------------------------------
+// Contractor1 70 - 40 30 50 120
+// Contractor2 65 45 40 35 55 100
+// Contractor3 - 45 35 40 50 70
+// ============================================================================
+//The objective of the contractors is to minimize the total cost
+clc;
+nProjects = 5;
+nContractors = 3;
+bids = [20 10000 10 9 15;18 12 13 8 16; 10000 11 12 7 17];
+reqResource = [70 10000 40 30 50;65 40 40 35 55; 10000 45 35 40 50];
+availResource = [120; 100; 70];
+
+nVar = nProjects*nContractors; // Calculated the dimension of the problem
+IntCon = 1:nVar; // Indicating the integer variables
+lb = zeros(1,nVar);
+ub = ones(1,nVar);
+
+// Linear constraints
+// Linear equality constraints
+
+beq = ones(nProjects,1);
+for i = 1:nProjects
+ Aeq(i,i:nProjects:nVar) = 1;
+end
+
+// Linear inequality constraints
+b = availResource;
+for j = 1:nContractors
+ index = (j-1)*nProjects+1:j*nProjects;
+ A(j,index) = reqResource(j,:);
+end
+
+// Objective function
+for j = 1:nContractors
+ index = (j-1)*nProjects+1:j*nProjects;
+ Cost(index,1) = bids(j,:)';
+end
+
+options = list("time_limit", 2500);
+[xopt,fopt,status,output] = symphonymat(Cost,IntCon,A,b,Aeq,beq,lb,ub,options);
+
+// Result representation
+select status
+case 227
+ disp(" Optimal Solution Found")
+case 228
+ disp("Maximum CPU Time exceeded")
+case 229
+ disp("Maximum Number of Node Limit Exceeded")
+case 230
+ disp("Maximum Number of Iterations Limit Exceeded.")
+end
+
+for j = 1:nContractors
+ index = (j-1)*nProjects+1:j*nProjects;
+ Contractor(j).Project = string(find(xopt(index)==1));
+end
+ResolurceUtilized = ((A*xopt)./b)*100;
+
+for j = 1:nContractors
+ disp(strcat(["Projects assigned to contractor",string(j)," : ", Contractor(j).Project],' '));
+ disp(strcat(["Resource utilized by contractor ",string(j)," : ",string(ResolurceUtilized(j)),"%"]));
+end
+disp(strcat(["Total cost : ",string(fopt)]))
+