Lineares Optimierungsproblem: Unterschied zwischen den Versionen

 
(Eine dazwischenliegende Version desselben Benutzers wird nicht angezeigt)
Zeile 55: Zeile 55:
:<math>Z = 3x + 5y \rightarrow \max</math>
:<math>Z = 3x + 5y \rightarrow \max</math>


=== Grafische Darstellung (JSXGraph) ===
<html>
<html>
<head>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jsxgraph/1.4.6/jsxgraphcore.js"></script>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jsxgraph/1.4.6/jsxgraphcore.js"></script>
    <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/jsxgraph/1.4.6/jsxgraph.css" />
</head>
</head>
<body>
<body>
<div id="lp1" style="width:400px;height:300px;"></div>
    <div id="box_lop" class="jxgbox" style="width: 400px; height: 400px; margin-top:20px;"></div>
<script>
    <script type="text/javascript">
var board = JXG.JSXGraph.initBoard('lp1',{
        (function () {
boundingbox:[-1,9,9,-1], axis:true, grid:true
            var board = JXG.JSXGraph.initBoard('box_lop', {
});
                boundingbox: [-1, 9, 9, -1],
                axis: true,
                grid: true,
                showCopyright: false,
                defaultAxes: {
                    x: {
                        withLabel: true,
                        name: 'x',
                        label: { position: 'rt', offset: [-10, 15] }
                    },
                    y: {
                        withLabel: true,
                        name: 'y',
                        label: { position: 'rt', offset: [10, -5] }
                    }
                }
            });


var g1 = board.create('line', [[0,8],[4,0]]);
            // Nebenbedingung: 2x + y = 8  -> y = -2x + 8
var g2 = board.create('line', [[0,4],[8,0]]);
            var nb1 = board.create('functiongraph', [
                function (x) { return -2 * x + 8; }
            ], {
                strokeColor: 'red',
                name: '2x + y = 8',
                withLabel: true,
                label: { offset: [-60, 20] }
            });


board.create('text',[5,5,'Zulässiger Bereich']);
            // Nebenbedingung: x + 2y = 8  -> y = -0.5x + 4
</script>
            var nb2 = board.create('functiongraph', [
                function (x) { return -0.5 * x + 4; }
            ], {
                strokeColor: 'blue',
                name: 'x + 2y = 8',
                withLabel: true,
                label: { offset: [10, -20] }
            });
 
            // Zulässiger Bereich
            board.create('polygon', [
                [0, 0],
                [4, 0],
                [8 / 3, 8 / 3],
                [0, 4]
            ], {
                fillColor: '#0055aa',
                fillOpacity: 0.2,
                borders: { visible: false }
            });
 
            // Slider für Zielfunktion Z = 3x + 5y
            var Z = board.create('slider', [[0.5, 8.6], [6.5, 8.6], [0, 0, 40]], {
                name: 'Z'
            });
 
            // Zielfunktion: 3x + 5y = Z  -> y = (Z - 3x)/5
            board.create('functiongraph', [
                function (x) { return (Z.Value() - 3 * x) / 5; }
            ], {
                strokeColor: 'green',
                dash: 2,
                name: 'Zielfunktion',
                withLabel: true
            });
 
        })();
    </script>
</body>
</body>
</html>
</html>