ইঞ্জিনটি একটি লিনিয়ার প্রোগ্রামের মডেল এবং সমাধান করতে ব্যবহৃত হয়। নীচের উদাহরণ নিম্নলিখিত লিনিয়ার প্রোগ্রাম সমাধান করে:
দুটি ভেরিয়েবল, x
এবং y
:
0 ≤ x ≤ 10
0 ≤ y ≤ 5
সীমাবদ্ধতা:
0 ≤ 2 * x + 5 * y ≤ 10
0 ≤ 10 * x + 3 * y ≤ 20
উদ্দেশ্য:
x + y
সর্বাধিক করুন
const engine = LinearOptimizationService.createEngine(); // Add variables, constraints and define the objective with addVariable(), // addConstraint(), etc Add two variables, 0 <= x <= 10 and 0 <= y <= 5 engine.addVariable('x', 0, 10); engine.addVariable('y', 0, 5); // Create the constraint: 0 <= 2 * x + 5 * y <= 10 let constraint = engine.addConstraint(0, 10); constraint.setCoefficient('x', 2); constraint.setCoefficient('y', 5); // Create the constraint: 0 <= 10 * x + 3 * y <= 20 constraint = engine.addConstraint(0, 20); constraint.setCoefficient('x', 10); constraint.setCoefficient('y', 3); // Set the objective to be x + y engine.setObjectiveCoefficient('x', 1); engine.setObjectiveCoefficient('y', 1); // Engine should maximize the objective engine.setMaximization(); // Solve the linear program const solution = engine.solve(); if (!solution.isValid()) { Logger.log(`No solution ${solution.getStatus()}`); } else { Logger.log(`Value of x: ${solution.getVariableValue('x')}`); Logger.log(`Value of y: ${solution.getVariableValue('y')}`); }
পদ্ধতি
বিস্তারিত ডকুমেন্টেশন
add Constraint(lowerBound, upperBound)
মডেলে একটি নতুন রৈখিক সীমাবদ্ধতা যোগ করে। সীমাবদ্ধতার উপরের এবং নিম্ন সীমাটি সৃষ্টির সময় সংজ্ঞায়িত করা হয়। ভেরিয়েবলের সহগগুলিকে Linear Optimization Constraint.setCoefficient(variableName, coefficient)
কলের মাধ্যমে সংজ্ঞায়িত করা হয়।
const engine = LinearOptimizationService.createEngine(); // Create a linear constraint with the bounds 0 and 10 const constraint = engine.addConstraint(0, 10); // Create a variable so we can add it to the constraint engine.addVariable('x', 0, 5); // Set the coefficient of the variable in the constraint. The constraint is now: // 0 <= 2 * x <= 5 constraint.setCoefficient('x', 2);
পরামিতি
নাম | টাইপ | বর্ণনা |
---|---|---|
lower Bound | Number | সীমাবদ্ধতার নিম্ন সীমানা |
upper Bound | Number | সীমাবদ্ধতার উপরের সীমানা |
প্রত্যাবর্তন
Linear Optimization Constraint
— তৈরি করা সীমাবদ্ধতা
add Constraints(lowerBounds, upperBounds, variableNames, coefficients)
মডেলে ব্যাচে সীমাবদ্ধতা যোগ করে।
const engine = LinearOptimizationService.createEngine(); // Add a boolean variable 'x' (integer >= 0 and <= 1) and a real (continuous >= // 0 and <= 100) variable 'y'. engine.addVariables( ['x', 'y'], [0, 0], [1, 100], [ LinearOptimizationService.VariableType.INTEGER, LinearOptimizationService.VariableType.CONTINUOUS, ], ); // Adds two constraints: // 0 <= x + y <= 3 // 1 <= 10 * x - y <= 5 engine.addConstraints( [0.0, 1.0], [3.0, 5.0], [ ['x', 'y'], ['x', 'y'], ], [ [1, 1], [10, -1], ], );
পরামিতি
নাম | টাইপ | বর্ণনা |
---|---|---|
lower Bounds | Number[] | সীমাবদ্ধতার নিম্ন সীমানা |
upper Bounds | Number[] | সীমাবদ্ধতার উপরের সীমানা |
variable Names | String[][] | ভেরিয়েবলের নাম যার জন্য সহগ সেট করা হচ্ছে |
coefficients | Number[][] | সহগ সেট করা হচ্ছে |
প্রত্যাবর্তন
Linear Optimization Engine
- একটি লিনিয়ার অপ্টিমাইজেশান ইঞ্জিন
add Variable(name, lowerBound, upperBound)
মডেলে একটি নতুন ক্রমাগত পরিবর্তনশীল যোগ করে। পরিবর্তনশীল তার নাম দ্বারা উল্লেখ করা হয়. ধরনটি Variable Type.CONTINUOUS
সেট করা হয়েছে।
const engine = LinearOptimizationService.createEngine(); const constraint = engine.addConstraint(0, 10); // Add a boolean variable (integer >= 0 and <= 1) engine.addVariable('x', 0, 1, LinearOptimizationService.VariableType.INTEGER); // Add a real (continuous) variable. Notice the lack of type specification. engine.addVariable('y', 0, 100);
পরামিতি
নাম | টাইপ | বর্ণনা |
---|---|---|
name | String | ভেরিয়েবলের অনন্য নাম |
lower Bound | Number | ভেরিয়েবলের নিম্ন সীমা |
upper Bound | Number | ভেরিয়েবলের উপরের সীমা |
প্রত্যাবর্তন
Linear Optimization Engine
- একটি লিনিয়ার অপ্টিমাইজেশান ইঞ্জিন
add Variable(name, lowerBound, upperBound, type)
মডেলে একটি নতুন ভেরিয়েবল যোগ করে। পরিবর্তনশীল তার নাম দ্বারা উল্লেখ করা হয়.
const engine = LinearOptimizationService.createEngine(); const constraint = engine.addConstraint(0, 10); // Add a boolean variable (integer >= 0 and <= 1) engine.addVariable('x', 0, 1, LinearOptimizationService.VariableType.INTEGER); // Add a real (continuous) variable engine.addVariable( 'y', 0, 100, LinearOptimizationService.VariableType.CONTINUOUS, );
পরামিতি
নাম | টাইপ | বর্ণনা |
---|---|---|
name | String | ভেরিয়েবলের অনন্য নাম |
lower Bound | Number | ভেরিয়েবলের নিম্ন সীমা |
upper Bound | Number | ভেরিয়েবলের উপরের সীমা |
type | Variable Type | ভেরিয়েবলের টাইপ, Variable Type একটি হতে পারে |
প্রত্যাবর্তন
Linear Optimization Engine
- একটি লিনিয়ার অপ্টিমাইজেশান ইঞ্জিন
add Variable(name, lowerBound, upperBound, type, objectiveCoefficient)
মডেলে একটি নতুন ভেরিয়েবল যোগ করে। পরিবর্তনশীল তার নাম দ্বারা উল্লেখ করা হয়.
const engine = LinearOptimizationService.createEngine(); const constraint = engine.addConstraint(0, 10); // Add a boolean variable (integer >= 0 and <= 1) engine.addVariable( 'x', 0, 1, LinearOptimizationService.VariableType.INTEGER, 2, ); // The objective is now 2 * x. // Add a real (continuous) variable engine.addVariable( 'y', 0, 100, LinearOptimizationService.VariableType.CONTINUOUS, -5, ); // The objective is now 2 * x - 5 * y.
পরামিতি
নাম | টাইপ | বর্ণনা |
---|---|---|
name | String | ভেরিয়েবলের অনন্য নাম |
lower Bound | Number | ভেরিয়েবলের নিম্ন সীমা |
upper Bound | Number | ভেরিয়েবলের উপরের সীমা |
type | Variable Type | ভেরিয়েবলের টাইপ, Variable Type একটি হতে পারে |
objective Coefficient | Number | ভেরিয়েবলের উদ্দেশ্য সহগ |
প্রত্যাবর্তন
Linear Optimization Engine
- একটি লিনিয়ার অপ্টিমাইজেশান ইঞ্জিন
add Variables(names, lowerBounds, upperBounds, types, objectiveCoefficients)
মডেলে ব্যাচে ভেরিয়েবল যোগ করে। ভেরিয়েবল তাদের নামের দ্বারা উল্লেখ করা হয়.
const engine = LinearOptimizationService.createEngine(); // Add a boolean variable 'x' (integer >= 0 and <= 1) and a real (continuous >=0 // and <= 100) variable 'y'. engine.addVariables( ['x', 'y'], [0, 0], [1, 100], [ LinearOptimizationService.VariableType.INTEGER, LinearOptimizationService.VariableType.CONTINUOUS, ], );
পরামিতি
নাম | টাইপ | বর্ণনা |
---|---|---|
names | String[] | ভেরিয়েবলের অনন্য নাম |
lower Bounds | Number[] | ভেরিয়েবলের নিম্ন সীমা |
upper Bounds | Number[] | ভেরিয়েবলের উপরের সীমানা |
types | Variable Type[] | ভেরিয়েবলের প্রকার, Variable Type একটি হতে পারে |
objective Coefficients | Number[] | ভেরিয়েবলের উদ্দেশ্য সহগ |
প্রত্যাবর্তন
Linear Optimization Engine
- একটি লিনিয়ার অপ্টিমাইজেশান ইঞ্জিন
set Maximization()
রৈখিক উদ্দেশ্য ফাংশন সর্বাধিক করার জন্য অপ্টিমাইজেশান দিক সেট করে।
const engine = LinearOptimizationService.createEngine(); // Add a real (continuous) variable. Notice the lack of type specification. engine.addVariable('y', 0, 100); // Set the coefficient of 'y' in the objective. // The objective is now 5 * y engine.setObjectiveCoefficient('y', 5); // We want to maximize. engine.setMaximization();
প্রত্যাবর্তন
Linear Optimization Engine
- একটি লিনিয়ার অপ্টিমাইজেশান ইঞ্জিন
set Minimization()
রৈখিক উদ্দেশ্য ফাংশন ছোট করার জন্য অপ্টিমাইজেশান দিক সেট করে।
const engine = LinearOptimizationService.createEngine(); // Add a real (continuous) variable. Notice the lack of type specification. engine.addVariable('y', 0, 100); // Set the coefficient of 'y' in the objective. // The objective is now 5 * y engine.setObjectiveCoefficient('y', 5); // We want to minimize engine.setMinimization();
প্রত্যাবর্তন
Linear Optimization Engine
- একটি লিনিয়ার অপ্টিমাইজেশান ইঞ্জিন
set Objective Coefficient(variableName, coefficient)
রৈখিক উদ্দেশ্য ফাংশনে একটি ভেরিয়েবলের সহগ নির্ধারণ করে।
const engine = LinearOptimizationService.createEngine(); // Add a real (continuous) variable. Notice the lack of type specification. engine.addVariable('y', 0, 100); // Set the coefficient of 'y' in the objective. // The objective is now 5 * y engine.setObjectiveCoefficient('y', 5);
পরামিতি
নাম | টাইপ | বর্ণনা |
---|---|---|
variable Name | String | ভেরিয়েবলের নাম যার জন্য সহগ সেট করা হচ্ছে |
coefficient | Number | উদ্দেশ্য ফাংশনে ভেরিয়েবলের সহগ |
প্রত্যাবর্তন
Linear Optimization Engine
- একটি লিনিয়ার অপ্টিমাইজেশান ইঞ্জিন
solve()
30 সেকেন্ডের ডিফল্ট সময়সীমার সাথে বর্তমান লিনিয়ার প্রোগ্রামটি সমাধান করে। পাওয়া সমাধান প্রদান করে।
const engine = LinearOptimizationService.createEngine(); // Add variables, constraints and define the objective with addVariable(), // addConstraint(), etc engine.addVariable('x', 0, 10); // ... // Solve the linear program const solution = engine.solve(); if (!solution.isValid()) { throw `No solution ${solution.getStatus()}`; } Logger.log(`Value of x: ${solution.getVariableValue('x')}`);
প্রত্যাবর্তন
Linear Optimization Solution
— অপ্টিমাইজেশানের সমাধান
solve(seconds)
বর্তমান লিনিয়ার প্রোগ্রাম সমাধান করে। পাওয়া সমাধান প্রদান করে। এবং যদি এটি একটি সর্বোত্তম সমাধান হয়।
const engine = LinearOptimizationService.createEngine(); // Add variables, constraints and define the objective with addVariable(), // addConstraint(), etc engine.addVariable('x', 0, 10); // ... // Solve the linear program const solution = engine.solve(300); if (!solution.isValid()) { throw `No solution ${solution.getStatus()}`; } Logger.log(`Value of x: ${solution.getVariableValue('x')}`);
পরামিতি
নাম | টাইপ | বর্ণনা |
---|---|---|
seconds | Number | সমস্যা সমাধানের সময়সীমা, সেকেন্ডে; সর্বোচ্চ সময়সীমা 300 সেকেন্ড |
প্রত্যাবর্তন
Linear Optimization Solution
— অপ্টিমাইজেশানের সমাধান