The COCOMO Model uses different constant values for different types of projects, such as organic, semi-detached, and embedded.
Constants for the COCOMO model
Below is a table that is generalised for all the constant values depending on model and project type.
Model |
Project Type |
a |
b |
c |
d |
Basic |
Organic |
2.4 |
1.05 |
2.5 |
0.38 |
|
Semi-Detached |
3.0 |
1.12 |
2.5 |
0.35 |
|
Embedded |
3.6 |
1.20 |
2.5 |
0.32 |
Intermediate |
Organic |
3.2 |
1.05 |
2.5 |
0.38 |
|
Semi-Detached |
3.0 |
1.12 |
2.5 |
0.35 |
|
Embedded |
2.8 |
1.20 |
2.5 |
0.32 |
Detailed |
Organic |
3.2 |
1.05 |
2.5 |
0.38 |
|
Semi-Detached |
3.0 |
1.12 |
2.5 |
0.35 |
|
Embedded |
2.8 |
1.20 |
2.5 |
0.32 |
Estimation and Calculation
Several calculations are done to find the effort and the final time to complete the project. For example, let’s take a basic COCOMO model to estimate an organic-type software project.
- KLOC: Estimate size of software product (Kilo Lines Of Code)
- Effort: E = a * (KLOC)^b PM(person-months)
- E = 2.4 x (50)^1.05 ≈ 146 person-months
- Development Time: TDEV = c * (effort)^d
- TDEV = 2.5 x (146)^0.38 ≈ 16 months 19 days
- Person Required: Effort/time
- People required to complete the project are E/TDEV = 146/16.61 ≈ 9
Code Implementation
Python
def cocomo(model_type, size_kloc):
# pre-defined constants
constants = {
‘basic’: {
‘organic’: (2.4, 1.05, 2.5, 0.38),
‘semi_detached’: (3.0, 1.12, 2.5, 0.35),
’embedded’: (3.6, 1.20, 2.5, 0.32)
},
‘intermediate’: {
‘organic’: (3.2, 1.05, 2.5, 0.38),
‘semi_detached’: (3.0, 1.12, 2.5, 0.35),
’embedded’: (2.8, 1.20, 2.5, 0.32)
},
‘detailed’: {
‘organic’: (3.2, 1.05, 2.5, 0.38),
‘semi_detached’: (3.0, 1.12, 2.5, 0.35),
’embedded’: (2.8, 1.20, 2.5, 0.32)
}
}
# Check the project type according to KLOC size
if(size_kloc >= 2 and size_kloc <= 50):
mode = 0
elif(size_kloc > 50 and size_kloc <= 300):
mode = 1
elif(size_kloc > 300):
mode = 2
projects = [“organic”,”semi_detached”,”embedded”]
project_type = projects[mode]
print(f”This is an {project_type.upper()} type project”)
a, b, c, d = constants[model_type][project_type]
effort = a * (size_kloc ** b)
tdev = c * (effort ** d)
persons = effort/tdev
return effort, tdev, persons
# Example Input
model_type = ‘intermediate’ # ‘basic’, ‘intermediate’, ‘detailed’
size_kloc = 200
effort, time, person = cocomo(model_type, size_kloc)
#Outputs
print(f”–> Effort: {effort} Person-Months”)
print(f”–> Development Time: {time} Months”)
print(f”–> Estimated Staff Required: {person} Persons”)
Output
C++
#include <iostream>
#include <cmath>
using namespace std;
// Predefined constants as a 2D array
double constants[3][3][4] = {
// Basic
{
{2.4, 1.05, 2.5, 0.38},
{3.0, 1.12, 2.5, 0.35},
{3.6, 1.20, 2.5, 0.32}
},
// Intermediate
{
{3.2, 1.05, 2.5, 0.38},
{3.0, 1.12, 2.5, 0.35},
{2.8, 1.20, 2.5, 0.32}
},
// Detailed
{
{3.2, 1.05, 2.5, 0.38},
{3.0, 1.12, 2.5, 0.35},
{2.8, 1.20, 2.5, 0.32}
}
};
double* cocomo(string modelType, double sizeKLOC) {
// Determine project type based on KLOC size
string projectType;
int mode;
if (sizeKLOC >= 2 && sizeKLOC <= 50) {
projectType = “organic”;
mode = 0;
} else if (sizeKLOC > 50 && sizeKLOC <= 300) {
projectType = “semi_detached”;
mode = 1;
} else if (sizeKLOC > 300) {
projectType = “embedded”;
mode = 2;
} else {
throw invalid_argument(“Invalid size KLOC”);
}
// Retrieve constants for the specified model type and project type
double* modelConstants = constants[mode][0]; // Point to the right 1D array
double a = modelConstants[0];
double b = modelConstants[1];
double c = modelConstants[2];
double d = modelConstants[3];
// Calculate effort, development time, and estimated staff required
double effort = a * pow(sizeKLOC, b);
double tdev = c * pow(effort, d);
double persons = effort / tdev;
double* results = new double[3];
results[0] = effort;
results[1] = tdev;
results[2] = persons;
return results;
}
int main() {
string modelType = “intermediate”; // ‘basic’, ‘intermediate’, ‘detailed’
double sizeKLOC = 200;
double* results = cocomo(modelType, sizeKLOC);
// Outputs
cout << “–> Effort: ” << results[0] << ” Person-Months” << endl;
cout << “–> Development Time: ” << results[1] << ” Months” << endl;
cout << “–> Estimated Staff Required: ” << results[2] << ” Persons” << endl;
delete[] results; // Free allocated memory
return 0;
}
Output
Java
import java.util.HashMap;
import java.util.Map;
public class COCOMO {
// Pre-defined constants
private static final Map<String, Map<String, Double[]>> constants = new HashMap<>();
static {
// Constants for Basic COCOMO
constants.put(“basic”, Map.of(
“organic”, new Double[] {2.4, 1.05, 2.5, 0.38},
“semi_detached”, new Double[] {3.0, 1.12, 2.5, 0.35},
“embedded”, new Double[] {3.6, 1.20, 2.5, 0.32}
));
// Constants for Intermediate COCOMO
constants.put(“intermediate”, Map.of(
“organic”, new Double[] {3.2, 1.05, 2.5, 0.38},
“semi_detached”, new Double[] {3.0, 1.12, 2.5, 0.35},
“embedded”, new Double[] {2.8, 1.20, 2.5, 0.32}
));
// Constants for Detailed COCOMO
constants.put(“detailed”, Map.of(
“organic”, new Double[] {3.2, 1.05, 2.5, 0.38},
“semi_detached”, new Double[] {3.0, 1.12, 2.5, 0.35},
“embedded”, new Double[] {2.8, 1.20, 2.5, 0.32}
));
}
public static double[] cocomo(String modelType, double sizeKLOC) {
// Determine project type based on KLOC size
String projectType;
if (sizeKLOC >= 2 && sizeKLOC <= 50) {
projectType = “organic”;
} else if (sizeKLOC > 50 && sizeKLOC <= 300) {
projectType = “semi_detached”;
} else if (sizeKLOC > 300) {
projectType = “embedded”;
} else {
throw new IllegalArgumentException(“Invalid size KLOC”);
}
// Retrieve constants for the specified model type and project type
Double[] modelConstants = constants.get(modelType).get(projectType);
double a = modelConstants[0];
double b = modelConstants[1];
double c = modelConstants[2];
double d = modelConstants[3];
// Calculate effort, development time, and estimated staff required
double effort = a * Math.pow(sizeKLOC, b);
double tdev = c * Math.pow(effort, d);
double persons = effort / tdev;
return new double[] {effort, tdev, persons};
}
public static void main(String[] args) {
String modelType = “intermediate”; // ‘basic’, ‘intermediate’, ‘detailed’
double sizeKLOC = 200;
double[] results = cocomo(modelType, sizeKLOC);
// Outputs
System.out.println(“–> Effort: ” + results[0] + ” Person-Months”);
System.out.println(“–> Development Time: ” + results[1] + ” Months”);
System.out.println(“–> Estimated Staff Required: ” + results[2] + ” Persons”);
}
}
Output
C#
using System;
public class COCOMO
{
// Predefined constants as a 2D array
private static readonly double[,][] constants =
{
// Basic
{
new double[] {2.4, 1.05, 2.5, 0.38},
new double[] {3.0, 1.12, 2.5, 0.35},
new double[] {3.6, 1.20, 2.5, 0.32}
},
// Intermediate
{
new double[] {3.2, 1.05, 2.5, 0.38},
new double[] {3.0, 1.12, 2.5, 0.35},
new double[] {2.8, 1.20, 2.5, 0.32}
},
// Detailed
{
new double[] {3.2, 1.05, 2.5, 0.38},
new double[] {3.0, 1.12, 2.5, 0.35},
new double[] {2.8, 1.20, 2.5, 0.32}
}
};
public static double[] Cocomo(string modelType, double sizeKLOC)
{
// Determine project type based on KLOC size
string projectType;
int mode;
if (sizeKLOC >= 2 && sizeKLOC <= 50)
{
projectType = “organic”;
mode = 0;
}
else if (sizeKLOC > 50 && sizeKLOC <= 300)
{
projectType = “semi_detached”;
mode = 1;
}
else if (sizeKLOC > 300)
{
projectType = “embedded”;
mode = 2;
}
else
{
throw new ArgumentException(“Invalid size KLOC”);
}
// Retrieve constants for the specified model type and project type
double[] modelConstants = constants[mode, 0]; // Point to the right 1D array
double a = modelConstants[0];
double b = modelConstants[1];
double c = modelConstants[2];
double d = modelConstants[3];
// Calculate effort, development time, and estimated staff required
double effort = a * Math.Pow(sizeKLOC, b);
double tdev = c * Math.Pow(effort, d);
double persons = effort / tdev;
return new double[] { effort, tdev, persons };
}
public static void Main(string[] args)
{
string modelType = “detailed”; // ‘basic’, ‘intermediate’, ‘detailed’
double sizeKLOC = 250;
double[] results = Cocomo(modelType, sizeKLOC);
// Outputs
Console.WriteLine(“–> Effort: ” + results[0] + ” Person-Months”);
Console.WriteLine(“–> Development Time: ” + results[1] + ” Months”);
Console.WriteLine(“–> Estimated Staff Required: ” + results[2] + ” Persons”);
}
}
Output
JavaScript
const constants = [
[
[2.4, 1.05, 2.5, 0.38],
[3.0, 1.12, 2.5, 0.35],
[3.6, 1.20, 2.5, 0.32]
],
[
[3.2, 1.05, 2.5, 0.38],
[3.0, 1.12, 2.5, 0.35],
[2.8, 1.20, 2.5, 0.32]
],
[
[3.2, 1.05, 2.5, 0.38],
[3.0, 1.12, 2.5, 0.35],
[2.8, 1.20, 2.5, 0.32]
]
];
function cocomo(modelType, sizeKLOC) {
let mode;
if (sizeKLOC >= 2 && sizeKLOC <= 50) {
mode = 0;
} else if (sizeKLOC > 50 && sizeKLOC <= 300) {
mode = 1;
} else if (sizeKLOC > 300) {
mode = 2;
} else {
throw new Error(“Invalid size KLOC”);
}
const modelConstants = constants[mode][0];
const a = modelConstants[0];
const b = modelConstants[1];
const c = modelConstants[2];
const d = modelConstants[3];
const effort = a * Math.pow(sizeKLOC, b);
const tdev = c * Math.pow(effort, d);
const persons = effort / tdev;
return [effort, tdev, persons];
}
const modelType = “basic”; // basic, intermediate or detailed
const sizeKLOC = 20;
const results = cocomo(modelType, sizeKLOC);
console.log(“–> Effort: ” + results[0] + ” Person-Months”);
console.log(“–> Development Time: ” + results[1] + ” Months”);
console.log(“–> Estimated Staff Required: ” + results[2] + ” Persons”);
Output