0% found this document useful (0 votes)
255 views4 pages

Roll No.: 101 Practical 18: Program To Implement Minimin Criterion

This document contains code for a C++ program that implements the minimax criterion for decision making under uncertainty. It defines a class called Optimism with methods to get user input for the number of states and alternatives, store the payoff matrix, calculate the opportunity loss matrix, find the minimum loss for each alternative, and output the overall payoff. The main method creates an Optimism object and calls its methods to run the algorithm and display the results.

Uploaded by

virusyadav
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
255 views4 pages

Roll No.: 101 Practical 18: Program To Implement Minimin Criterion

This document contains code for a C++ program that implements the minimax criterion for decision making under uncertainty. It defines a class called Optimism with methods to get user input for the number of states and alternatives, store the payoff matrix, calculate the opportunity loss matrix, find the minimum loss for each alternative, and output the overall payoff. The main method creates an Optimism object and calls its methods to run the algorithm and display the results.

Uploaded by

virusyadav
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

Roll No.

: 101
Practical 18 : Program to implement Minimin criterion.
#include<iostream.h>
#include<conio.h>
class Optimism
{
private :
int r,c;
long int ns[20][20],maxn[20],mins[20],payoff;
public :
void showdata();
private :
void getdata();
void calculate();
void showmat();
};
void Optimism :: getdata()
{
cout<<"\nEnter the no. of states of nature : ";
cin>>r;
cout<<"\nEnter the no. of alternatives : ";
cin>>c;
cout<<"\nEnter "<<r*c<<" values :";
for (int i=1;i<=r;i++)
{
for (int j=1;j<=c;j++)
{
cin>>ns[i][j];
}
}
}
void Optimism :: showmat()
{
for (int i=1;i<=r;i++)
{
for (int j=1;j<=c;j++)
{
cout<<ns[i][j]<<"\t";
}
cout<<"\n";
}
}

void Optimism :: calculate()


{
getdata();
cout<<"\nThe Payoff Matrix : \n";
showmat();
int i,j;
long int max;
for (i=1;i<=r;i++)
{
max = ns[i][1];
for (j=1;j<=c;j++)
{
if (max < ns[i][j])
{
max = ns[i][j];
}
maxn[i] = max;
}
}
for (i=1;i<=r;i++)
{
for (j=1;j<=c;j++)
{
ns[i][j] = maxn[i] - ns[i][j];
}
}
cout<<"\nOpportunity Loss Matrix : \n";
showmat();
long int min;
for (i=1;i<=c;i++)
{
min = ns[1][i];
for (j=1;j<=r;j++)
{
if (min > ns[j][i])
{
min = ns[j][i];
}
mins[i] = min;
}
}
min = mins[1];
for (i=1;i<=c;i++)
{
if (min > mins[i])

{
min = mins[i];
}
}
payoff = min;
}
void Optimism :: showdata()
{
calculate();
cout<<"\nPayoff = "<<payoff;
}
void main()
{
clrscr();
Optimism O;
O.showdata();
getch();
}
Output :
Enter the no. of states of nature : 3
Enter the no. of alternatives : 3
Enter 9 values :700000 500000 300000 300000 450000 300000 150000 0 300000
The Payoff Matrix :
700000 500000 300000
300000 450000 300000
150000 0
300000
Opportunity Loss Matrix :
0
200000 400000
150000 0
150000
150000 300000 0
Payoff = 0

You might also like